Class: ActiveFedora::Merged

Inherits:
AssociationHash show all
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

Attributes inherited from AssociationHash

#base, #reflections

Instance Method Summary collapse

Methods inherited from AssociationHash

#association, #changed, #each, #each_value, #freeze, #key?, #merge, #select, #values

Constructor Details

#initialize(first, second) ⇒ Merged

Returns a new instance of Merged.



94
95
96
97
98
# File 'lib/active_fedora/association_hash.rb', line 94

def initialize(first, second)
  @first = first
  @base = first.base
  @second = second
end

Instance Attribute Details

#firstObject (readonly)

Returns the value of attribute first.



92
93
94
# File 'lib/active_fedora/association_hash.rb', line 92

def first
  @first
end

#secondObject (readonly)

Returns the value of attribute second.



92
93
94
# File 'lib/active_fedora/association_hash.rb', line 92

def second
  @second
end

Instance Method Details

#[](name) ⇒ Object



100
101
102
# File 'lib/active_fedora/association_hash.rb', line 100

def [](name)
  first[name] || second[name]
end

#[]=(_name) ⇒ Object

Raises:

  • (NotImplementedError)


104
105
106
# File 'lib/active_fedora/association_hash.rb', line 104

def []=(_name)
  raise NotImplementedError, "Unable to set properties on a merged association hash."
end

#keysObject



108
109
110
# File 'lib/active_fedora/association_hash.rb', line 108

def keys
  first.keys + second.keys
end