Class: ActiveFedora::Aggregation::Association
- Inherits:
-
Object
- Object
- ActiveFedora::Aggregation::Association
- Defined in:
- lib/active_fedora/aggregation/association.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #aggregation ⇒ Object
- #create(&block) ⇒ Object
- #first ⇒ Object
-
#initialize(parent, reflection) ⇒ Association
constructor
A new instance of Association.
- #klass ⇒ Object
- #save ⇒ Object
- #target=(vals) ⇒ Object
- #target_ids ⇒ Object
- #target_ids=(vals) ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(parent, reflection) ⇒ Association
Returns a new instance of Association.
7 8 9 10 |
# File 'lib/active_fedora/aggregation/association.rb', line 7 def initialize(parent, reflection) @parent = parent @reflection = reflection end |
Instance Method Details
#==(other) ⇒ Object
16 17 18 |
# File 'lib/active_fedora/aggregation/association.rb', line 16 def == other aggregation.to_a == other end |
#aggregation ⇒ Object
43 44 45 |
# File 'lib/active_fedora/aggregation/association.rb', line 43 def aggregation @aggregation ||= Aggregator.find_or_initialize(klass.uri_to_id(uri)) end |
#create(&block) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/active_fedora/aggregation/association.rb', line 20 def create(&block) klass.create(&block).tap do |created| aggregation << created end save #causes the (head/tail) pointers on the aggregation to be persisted end |
#first ⇒ Object
47 48 49 |
# File 'lib/active_fedora/aggregation/association.rb', line 47 def first aggregation.first end |
#klass ⇒ Object
12 13 14 |
# File 'lib/active_fedora/aggregation/association.rb', line 12 def klass @reflection.klass end |
#save ⇒ Object
27 28 29 |
# File 'lib/active_fedora/aggregation/association.rb', line 27 def save aggregation.save end |
#target=(vals) ⇒ Object
31 32 33 |
# File 'lib/active_fedora/aggregation/association.rb', line 31 def target=(vals) aggregation.target=(vals) end |
#target_ids ⇒ Object
39 40 41 |
# File 'lib/active_fedora/aggregation/association.rb', line 39 def target_ids aggregation.target_ids end |
#target_ids=(vals) ⇒ Object
35 36 37 |
# File 'lib/active_fedora/aggregation/association.rb', line 35 def target_ids=(vals) aggregation.target_ids=(vals) end |
#uri ⇒ Object
51 52 53 |
# File 'lib/active_fedora/aggregation/association.rb', line 51 def uri @parent.uri + '/files' end |