Module: DHS::Collection::HandleNested::ClassMethods

Defined in:
lib/dhs/concerns/collection/handle_nested.rb

Instance Method Summary collapse

Instance Method Details

#access(input:, record: nil) ⇒ Object

Access potentially nested collection of items



19
20
21
# File 'lib/dhs/concerns/collection/handle_nested.rb', line 19

def access(input:, record: nil)
  input.dig(*items_key(record))
end

#concat(input:, items:, record: nil) ⇒ Object

Concats existing nested collection of items with given items



30
31
32
# File 'lib/dhs/concerns/collection/handle_nested.rb', line 30

def concat(input:, items:, record: nil)
  input.dig(*items_key(record)).concat(items)
end

#nest(input:, value: nil, record: nil) ⇒ Object

Initializes nested collection



24
25
26
# File 'lib/dhs/concerns/collection/handle_nested.rb', line 24

def nest(input:, value: nil, record: nil)
  input[items_key(record)] = value
end