Class: ActiveMocker::HasOne
- Inherits:
-
SingleRelation
- Object
- SingleRelation
- ActiveMocker::HasOne
- Defined in:
- lib/active_mocker/mock/has_one.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
Returns the value of attribute item.
Instance Method Summary collapse
-
#initialize(item, child_self:, foreign_key:) ⇒ HasOne
constructor
A new instance of HasOne.
Methods inherited from SingleRelation
Constructor Details
#initialize(item, child_self:, foreign_key:) ⇒ HasOne
5 6 7 8 |
# File 'lib/active_mocker/mock/has_one.rb', line 5 def initialize(item, child_self:, foreign_key:) item.send(:write_attribute, foreign_key, item.try(:id)) if !item.try(:id).nil? super end |
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
3 4 5 |
# File 'lib/active_mocker/mock/has_one.rb', line 3 def item @item end |