Class: ObjectJSONMapper::Associations::HasOne

Inherits:
Association
  • Object
show all
Defined in:
lib/object_json_mapper/associations/has_one.rb

Instance Attribute Summary

Attributes inherited from Association

#name, #params

Instance Method Summary collapse

Methods inherited from Association

#endpoint, #initialize, #klass

Constructor Details

This class inherits a constructor from ObjectJSONMapper::Associations::Association

Instance Method Details

#call(object) ⇒ ObjectJSONMapper::Base

Parameters:

Returns:



6
7
8
9
10
11
# File 'lib/object_json_mapper/associations/has_one.rb', line 6

def call(object)
  attributes = object[name]
  attributes ||= HTTP.parse_json(object.client[endpoint].get.body)

  klass.persist(attributes)
end