Skip to content

Commit

Permalink
Merge pull request #17 from ontoportal-lirmm/pr/feautre/add-multiple-…
Browse files Browse the repository at this point in the history
…media-types-models

Feautre: Add multiple media types models
  • Loading branch information
alexskr authored Jul 18, 2024
2 parents 115cf36 + c320f44 commit 027c749
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions lib/ontologies_api_client/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ class Base
attr_accessor :context, :links

class << self
attr_accessor :media_type, :act_as_media_type, :include_attrs, :include_attrs_full, :attrs_always_present
attr_accessor :act_as_media_type, :include_attrs, :include_attrs_full, :attrs_always_present
def media_types
Array(@media_type)
end

def media_type
media_types.first
end

end

##
Expand All @@ -31,8 +39,11 @@ def self.map_classes
map = {}
classes = LinkedData::Client::Models.constants.map {|c| LinkedData::Client::Models.const_get(c)}
classes.each do |media_type_cls|
next if map[media_type_cls] || !media_type_cls.respond_to?(:media_type) || !media_type_cls.ancestors.include?(LinkedData::Client::Base)
map[media_type_cls.media_type] = media_type_cls
next if map[media_type_cls] || !media_type_cls.respond_to?(:media_types) || !media_type_cls.ancestors.include?(LinkedData::Client::Base)
media_type_cls.media_types.each do |type|
next if map[type]
map[type] = media_type_cls
end
media_type_cls.act_as_media_type.each {|mt| map[mt] = media_type_cls} if media_type_cls.act_as_media_type
end
return map
Expand Down
2 changes: 1 addition & 1 deletion lib/ontologies_api_client/models/class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Client
module Models
class Class < LinkedData::Client::Base
HTTP = LinkedData::Client::HTTP
@media_type = "http://www.w3.org/2002/07/owl#Class"
@media_type = %w[http://www.w3.org/2002/07/owl#Class http://www.w3.org/2004/02/skos/core#Concept]
@include_attrs = "prefLabel,definition,synonym,obsolete,hasChildren"
@include_attrs_full = "prefLabel,definition,synonym,obsolete,properties,hasChildren,children"
@attrs_always_present = :prefLabel, :definition, :synonym, :obsolete, :properties, :hasChildren, :children
Expand Down

0 comments on commit 027c749

Please sign in to comment.