Module: DHS::Data::Extend

Extended by:
ActiveSupport::Concern
Included in:
DHS::Data
Defined in:
lib/dhs/concerns/data/extend.rb

Instance Method Summary collapse

Instance Method Details

#extend!(addition, key = nil) ⇒ Object

Extends already fetched data (self) with additionally fetched data (addition) using the given key



12
13
14
15
16
17
18
19
20
21
# File 'lib/dhs/concerns/data/extend.rb', line 12

def extend!(addition, key = nil)
  addition = cast_relation_class_for_extension(addition, key)
  if collection?
    extend_collection!(addition, key)
  elsif _raw.is_a?(Array) || self[key]._raw.is_a?(Array)
    extend_array!(addition, key)
  elsif item?
    extend_item!(addition, key)
  end
end