Class: ActiveFedora::Aggregation::Association
- Inherits:
-
Object
- Object
- ActiveFedora::Aggregation::Association
- Defined in:
- lib/active_fedora/aggregation/association.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #container ⇒ 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 container.to_a == other end |
#container ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/active_fedora/aggregation/association.rb', line 43 def container @container ||= begin ProxyContainer.find_or_initialize(klass.uri_to_id(uri)).tap do |container| container.parent = @parent end end 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| container << created end save #causes the (head/tail) pointers on the aggregation to be persisted end |
#first ⇒ Object
51 52 53 |
# File 'lib/active_fedora/aggregation/association.rb', line 51 def first container.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 container.save end |
#target=(vals) ⇒ Object
31 32 33 |
# File 'lib/active_fedora/aggregation/association.rb', line 31 def target=(vals) container.target=(vals) end |
#target_ids ⇒ Object
39 40 41 |
# File 'lib/active_fedora/aggregation/association.rb', line 39 def target_ids container.target_ids end |
#target_ids=(vals) ⇒ Object
35 36 37 |
# File 'lib/active_fedora/aggregation/association.rb', line 35 def target_ids=(vals) container.target_ids=(vals) end |
#uri ⇒ Object
55 56 57 |
# File 'lib/active_fedora/aggregation/association.rb', line 55 def uri @parent.uri + '/files' end |