module LHS::Collection::HandleNested::ClassMethods
Public Instance Methods
access(input:, record: nil)
click to toggle source
Access potentially nested collection of items
# File lib/lhs/concerns/collection/handle_nested.rb, line 19 def access(input:, record: nil) input.dig(*items_key(record)) end
concat(input:, items:, record: nil)
click to toggle source
Concats existing nested collection of items with given items
# File lib/lhs/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)
click to toggle source
Initializes nested collection
# File lib/lhs/concerns/collection/handle_nested.rb, line 24 def nest(input:, value: nil, record: nil) input[items_key(record)] = value end
Private Instance Methods
items_key(record)
click to toggle source
Takes configured items key to access collection of items of falls back to the default key
# File lib/lhs/concerns/collection/handle_nested.rb, line 38 def items_key(record) record&.items_key || LHS::Record.items_key end