Module: Conflow::Redis::Identifier Private

Included in:
Flow, Job, Promise
Defined in:
lib/conflow/redis/identifier.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

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

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

ID of the model



60
61
62
# File 'lib/conflow/redis/identifier.rb', line 60

def id
  @id
end

Class Method Details

.included(base) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Extends base class with ClassMethods



11
12
13
# File 'lib/conflow/redis/identifier.rb', line 11

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#initialize(id = self.class.generate_id) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Overrides logic of Field#initialize, allowing creating objects with ID instead of full key

Parameters:

  • id (Integer) (defaults to: self.class.generate_id)

    ID of the model



64
65
66
67
# File 'lib/conflow/redis/identifier.rb', line 64

def initialize(id = self.class.generate_id)
  @id = id.to_i
  super(format(self.class.key_template, id: id))
end