Class: RedisModel::BelongedTo
- Defined in:
- lib/redis_model/belonged_to.rb
Overview
Internal: Base class for instance-level RedisModel attributes. Instances of this object should have reference to parent object.
Instance Attribute Summary collapse
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#parent_id ⇒ Object
Internal: ID of parent model.
Instance Method Summary collapse
-
#initialize(attrs = {}, options = {}) ⇒ BelongedTo
constructor
Internal: Instantiates new RedisModel::BelongedTo object with given options.
Methods inherited from Base
connection, custom_key_label, data_type, #key_label, redis_model_schema, #to_value
Constructor Details
#initialize(attrs = {}, options = {}) ⇒ BelongedTo
Internal: Instantiates new RedisModel::BelongedTo object with given options.
options - Options for new object.
:parent - Parent object.
:parent_id - ID of parent object.
Returns newly instantiated RedisModel::BelongedTo object.
15 16 17 18 |
# File 'lib/redis_model/belonged_to.rb', line 15 def initialize(attrs = {}, = {}) @parent = attrs[:parent] @parent_id = attrs[:parent_id] end |
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
5 6 7 |
# File 'lib/redis_model/belonged_to.rb', line 5 def parent @parent end |
#parent_id ⇒ Object
Internal: ID of parent model.
Returns ID of parent model.
23 24 25 |
# File 'lib/redis_model/belonged_to.rb', line 23 def parent_id @parent_id end |