Module: Her::Model::ORM::SerializationMethods

Extended by:
ActiveSupport::Concern
Included in:
Her::Model::ORM
Defined in:
lib/her/model/orm/serialization_methods.rb

Instance Method Summary collapse

Instance Method Details

#hashObject

Delegate to @data, allowing models to act correctly in code like:

[ Model.find(1), Model.find(1) ].uniq # => [ Model.find(1) ]


9
10
11
# File 'lib/her/model/orm/serialization_methods.rb', line 9

def hash
  @data.hash
end

#to_paramsObject

Convert into a hash of request parameters

Examples:

@user.to_params
# => { id: 1, name: 'John Smith' }


18
19
20
21
22
23
24
# File 'lib/her/model/orm/serialization_methods.rb', line 18

def to_params
  if self.class.include_root_in_json
    { (self.class.include_root_in_json == true ? self.class.root_element : self.class.include_root_in_json) => @data.dup }
  else
    @data.dup
  end
end