Class: ActiveFedora::Associations::ContainsAssociation
- Inherits:
-
CollectionAssociation
- Object
- Association
- CollectionAssociation
- ActiveFedora::Associations::ContainsAssociation
- Defined in:
- lib/active_fedora/associations/contains_association.rb
Overview
:nodoc:
Direct Known Subclasses
BasicContainsAssociation, DirectlyContainsAssociation, IndirectlyContainsAssociation
Instance Attribute Summary
Attributes inherited from CollectionAssociation
Attributes inherited from Association
#inversed, #owner, #reflection, #target
Instance Method Summary collapse
- #include?(other) ⇒ Boolean
- #insert_record(record, force = true, validate = true) ⇒ Object
- #reader ⇒ Object
Methods inherited from CollectionAssociation
#add_to_target, #any?, #build, #concat, #concat_records, #count, #create, #create!, #delete, #delete_all, #destroy, #destroy_all, #empty?, #find, #first, #ids_reader, #ids_writer, #last, #load_from_solr, #load_target, #null_scope?, #replace, #reset, #scope, #select, #size, #target=, #to_ary, #writer
Methods inherited from Association
#association_scope, #initialize, #initialize_attributes, #load_target, #loaded!, #loaded?, #reload, #reset, #reset_scope, #scope, #set_inverse_instance, #stale_target?, #target_scope
Constructor Details
This class inherits a constructor from ActiveFedora::Associations::Association
Instance Method Details
#include?(other) ⇒ Boolean
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/active_fedora/associations/contains_association.rb', line 17 def include?(other) if loaded? target.include?(other) elsif container_predicate = [:has_member_relation] owner.resource.query(predicate: container_predicate, object: ::RDF::URI(other.uri)).present? else # is_member_of_relation # This will force a load, so it's slowest and the least preferable option target.include?(other) end end |
#insert_record(record, force = true, validate = true) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/active_fedora/associations/contains_association.rb', line 5 def insert_record(record, force = true, validate = true) if force record.save! else record.save(validate: validate) end end |
#reader ⇒ Object
13 14 15 |
# File 'lib/active_fedora/associations/contains_association.rb', line 13 def reader @records ||= ContainerProxy.new(self) end |