Class: ActiveFedora::WithMetadata::DefaultStrategy

Inherits:
ActiveTriples::ExtensionStrategy
  • Object
show all
Defined in:
lib/active_fedora/with_metadata/default_strategy.rb

Class Method Summary collapse

Class Method Details

.apply(resource, property) ⇒ Object

override apply method to check if property already exists or receiver already has predicate defined. Do not add property if the rdf_resource already responds to the property name Do not add property if the rdf_resource already has a property with the same predicate.



6
7
8
9
10
# File 'lib/active_fedora/with_metadata/default_strategy.rb', line 6

def self.apply(resource, property)
  return if resource.respond_to?(property.name)
  return if resource.properties.any? { |p| p[1].predicate == property.predicate }
  resource.property property.name, property.to_h
end