class Locomotive::Steam::Models::BelongsToAssociation

Public Instance Methods

__attach__(entity) click to toggle source
Calls superclass method
# File lib/locomotive/steam/models/associations/belongs_to.rb, line 24
def __attach__(entity)
  # setting a default nil value for the target key
  entity[__target_key__] ||= nil
  super
end
__load__() click to toggle source
# File lib/locomotive/steam/models/associations/belongs_to.rb, line 6
def __load__
  target_id = @entity[__target_key__]
  target    = @repository.find(target_id)

  # replace the proxy class by the real target entity
  @entity[__name__] = target
end
__serialize__(attributes) click to toggle source
# File lib/locomotive/steam/models/associations/belongs_to.rb, line 14
def __serialize__(attributes)
  attributes[__target_key__] = attributes[__name__].try(:_id)

  attributes.delete(__name__)
end
__target_key__() click to toggle source
# File lib/locomotive/steam/models/associations/belongs_to.rb, line 20
def __target_key__
  :"#{__name__}_id"
end