Class: ActiveMocker::Mock::HasOne
- Inherits:
-
SingleRelation
- Object
- SingleRelation
- ActiveMocker::Mock::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:, foreign_id:) ⇒ HasOne
constructor
A new instance of HasOne.
Methods inherited from SingleRelation
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
#item ⇒ Object (readonly)
Returns the value of attribute item.
6 7 8 |
# File 'lib/active_mocker/mock/has_one.rb', line 6 def item @item end |