Class: RedisModel::BelongedTo

Inherits:
Base
  • Object
show all
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

Instance Method Summary collapse

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 = {}, options = {})
  @parent = attrs[:parent]
  @parent_id = attrs[:parent_id]
end

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



5
6
7
# File 'lib/redis_model/belonged_to.rb', line 5

def parent
  @parent
end

#parent_idObject

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