Class: ActiveMocker::BelongsTo

Inherits:
SingleRelation show all
Defined in:
lib/active_mocker/mock/belongs_to.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from SingleRelation

#assign_associations

Constructor Details

#initialize(item, child_self:, foreign_key:) ⇒ BelongsTo

Returns a new instance of BelongsTo.



6
7
8
9
10
# File 'lib/active_mocker/mock/belongs_to.rb', line 6

def initialize(item, child_self:, foreign_key:)
  save_item(item, child_self)
  assign_foreign_key(child_self, foreign_key, item.try(:id))
  super
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item.



4
5
6
# File 'lib/active_mocker/mock/belongs_to.rb', line 4

def item
  @item
end