Class: ActiveFedora::Merged
- Inherits:
-
AssociationHash
- Object
- AssociationHash
- ActiveFedora::Merged
- Defined in:
- lib/active_fedora/association_hash.rb
Overview
Note:
As the keys can come from multiple models, the attributes become
Represents the result of merging two association hashes. unwritable.
Instance Attribute Summary collapse
-
#first ⇒ Object
readonly
Returns the value of attribute first.
-
#second ⇒ Object
readonly
Returns the value of attribute second.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name) ⇒ Object
-
#initialize(first, second) ⇒ Merged
constructor
A new instance of Merged.
- #keys ⇒ Object
Methods inherited from AssociationHash
#association, #changed, #each, #each_value, #empty?, #freeze, #has_key?, #key?, #merge, #reflections, #select, #size, #values
Constructor Details
#initialize(first, second) ⇒ Merged
Returns a new instance of Merged.
100 101 102 103 |
# File 'lib/active_fedora/association_hash.rb', line 100 def initialize(first, second) @first = first @second = second end |
Instance Attribute Details
#first ⇒ Object (readonly)
Returns the value of attribute first.
98 99 100 |
# File 'lib/active_fedora/association_hash.rb', line 98 def first @first end |
#second ⇒ Object (readonly)
Returns the value of attribute second.
98 99 100 |
# File 'lib/active_fedora/association_hash.rb', line 98 def second @second end |
Instance Method Details
#[](name) ⇒ Object
105 106 107 |
# File 'lib/active_fedora/association_hash.rb', line 105 def [] (name) first[name] || second[name] end |
#[]=(name) ⇒ Object
109 110 111 |
# File 'lib/active_fedora/association_hash.rb', line 109 def []= (name) raise NotImplementedError, "Unable to set properties on a merged association hash." end |
#keys ⇒ Object
113 114 115 |
# File 'lib/active_fedora/association_hash.rb', line 113 def keys first.keys + second.keys end |