Module: Fixably::Encoding

Included in:
ApplicationResource
Defined in:
lib/fixably/encoding.rb

Instance Method Summary collapse

Instance Method Details

#encode(_options = nil, attrs: nil) ⇒ Object

Since our monkey patch converts the keys to underscore, it is necessary to convert them back to camelcase when performing a create or update



7
8
9
10
11
12
13
14
# File 'lib/fixably/encoding.rb', line 7

def encode(_options = nil, attrs: nil)
  attrs ||= attributes
  remove_has_many_associations(attrs)
  remove_unallowed_parameters(attrs)
  nest_for_association(attrs).
    deep_transform_keys { _1.camelize(:lower) }.
    public_send("to_#{self.class.format.extension}")
end