Module: LHS::Collection::HandleNested::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

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

Access potentially nested collection of items



17
18
19
# File 'lib/lhs/concerns/collection/handle_nested.rb', line 17

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



28
29
30
# File 'lib/lhs/concerns/collection/handle_nested.rb', line 28

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

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

Initializes nested collection



22
23
24
# File 'lib/lhs/concerns/collection/handle_nested.rb', line 22

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