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
Returns a new instance of HasOne.
6 7 8 9 |
# File 'lib/active_mocker/mock/has_one.rb', line 6 def initialize(item, child_self:, foreign_key:) item.send(:write_attribute, foreign_key, item.try(:id)) unless item.try(:id).nil? super end |
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
4 5 6 |
# File 'lib/active_mocker/mock/has_one.rb', line 4 def item @item end |