Class: PrettyApi::Parameters::NestedAttributes

Inherits:
Object
  • Object
show all
Defined in:
lib/pretty_api/parameters/nested_attributes.rb

Instance Method Summary collapse

Constructor Details

#initialize(nested_tree:) ⇒ NestedAttributes

Returns a new instance of NestedAttributes.



4
5
6
# File 'lib/pretty_api/parameters/nested_attributes.rb', line 4

def initialize(nested_tree:)
  @nested_tree = nested_tree
end

Instance Method Details

#parse(record, params) ⇒ Object



8
9
10
11
12
# File 'lib/pretty_api/parameters/nested_attributes.rb', line 8

def parse(record, params)
  return params if nested_tree[record.class].blank?

  parse_nested_attributes(record, params, nested_tree[record.class])
end