Class: ActiveMocker::Mock::HasOne

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from SingleRelation

#assign_associations

Constructor Details

#initialize(item, child_self:, foreign_key:, foreign_id:) ⇒ HasOne

Returns a new instance of HasOne.



8
9
10
11
# File 'lib/active_mocker/mock/has_one.rb', line 8

def initialize(item, child_self:, foreign_key:, foreign_id:)
  item.send(:write_attribute, foreign_key, foreign_id) if item.respond_to?("#{foreign_key}=") && !foreign_id.nil?
  super
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item.



6
7
8
# File 'lib/active_mocker/mock/has_one.rb', line 6

def item
  @item
end