Module: Conflow::Redis::Identifier
Overview
Identifier changes logic of fields so that they can be found by an id. ID is a counter stored in redis under .counter_key Key is build with template stored in .key_template
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
ID of the model.
Class Method Summary collapse
-
.included(base) ⇒ Object
Extends base class with ClassMethods.
Instance Method Summary collapse
-
#initialize(id = self.class.generate_id) ⇒ Object
Overrides logic of Field#initialize, allowing creating objects with ID instead of full key.
Instance Attribute Details
#id ⇒ Object (readonly)
ID of the model
56 57 58 |
# File 'lib/conflow/redis/identifier.rb', line 56 def id @id end |
Class Method Details
.included(base) ⇒ Object
Extends base class with ClassMethods
10 11 12 |
# File 'lib/conflow/redis/identifier.rb', line 10 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#initialize(id = self.class.generate_id) ⇒ Object
Overrides logic of Field#initialize, allowing creating objects with ID instead of full key
60 61 62 63 |
# File 'lib/conflow/redis/identifier.rb', line 60 def initialize(id = self.class.generate_id) @id = id.to_i super(format(self.class.key_template, id: id)) end |