Class: Wings::ActiveFedoraConverter::PropertyApplicator
- Inherits:
-
Object
- Object
- Wings::ActiveFedoraConverter::PropertyApplicator
- Defined in:
- lib/wings/active_fedora_converter/default_work.rb
Overview
Constructs an ActiveFedora property from a Dry::Types schema key. This applicator is intended to handle details like assocation types, where needed.
Instance Method Summary collapse
-
#apply(klass) ⇒ void
Apply the property.
-
#definition_method ⇒ Symbol
The method name for property/association definition.
-
#initialize(key) ⇒ PropertyApplicator
constructor
A new instance of PropertyApplicator.
- #name ⇒ Symbol
- #options ⇒ Hash<Symbol, Object>
- #predicate ⇒ RDF::URI
Constructor Details
#initialize(key) ⇒ PropertyApplicator
Returns a new instance of PropertyApplicator.
20 21 22 |
# File 'lib/wings/active_fedora_converter/default_work.rb', line 20 def initialize(key) @key = key end |
Instance Method Details
#apply(klass) ⇒ void
Note:
this method is a silent no-op if the property is already defined or is a protected property on the target class
This method returns an undefined value.
Returns apply the property.
29 30 31 32 33 |
# File 'lib/wings/active_fedora_converter/default_work.rb', line 29 def apply(klass) return if klass.properties.keys.include?(name.to_s) || klass.protected_property_name?(name) klass.send(definition_method, name, ) end |
#definition_method ⇒ Symbol
Returns the method name for property/association definition.
37 38 39 40 41 |
# File 'lib/wings/active_fedora_converter/default_work.rb', line 37 def definition_method return :ordered_aggregation if @key.name == :member_ids return :indirectly_contains if @key.name == :member_of_collection_ids :property end |
#name ⇒ Symbol
45 46 47 48 49 |
# File 'lib/wings/active_fedora_converter/default_work.rb', line 45 def name return :members if @key.name == :member_ids return :member_of_collections if @key.name == :member_of_collection_ids @key.name end |
#options ⇒ Hash<Symbol, Object>
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/wings/active_fedora_converter/default_work.rb', line 53 def return { has_member_relation: predicate, class_name: 'ActiveFedora::Base', through: :list_source } if @key.name == :member_ids if @key.name == :member_of_collection_ids return { has_member_relation: predicate, class_name: 'ActiveFedora::Base', inserted_content_relation: RDF::Vocab::ORE.proxyFor, through: 'ActiveFedora::Aggregation::Proxy', foreign_key: :target } end { predicate: predicate } end |
#predicate ⇒ RDF::URI
68 69 70 71 72 73 |
# File 'lib/wings/active_fedora_converter/default_work.rb', line 68 def predicate return Hydra::PCDM::Vocab::PCDMTerms.hasMember if @key.name == :member_ids return Hydra::PCDM::Vocab::PCDMTerms.memberOf if @key.name == :member_of_collection_ids RDF::URI.intern("http://hyrax.samvera.org/ns/wings##{name}") end |