Class: Inferx::Adapter
- Inherits:
-
Object
- Object
- Inferx::Adapter
- Defined in:
- lib/inferx/adapter.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#categories_key ⇒ String
Get the key for access to categories.
-
#initialize(redis, options = {}) ⇒ Adapter
constructor
A new instance of Adapter.
-
#make_categories_key ⇒ String
Make the key for access to categories.
-
#make_category_key(category_name) ⇒ String
Make the key for access to scores stored each by word.
-
#manual? ⇒ Boolean
Determine if manual save.
-
#spawn(klass, *args) ⇒ Object
Spawn an instance of any class.
Constructor Details
#initialize(redis, options = {}) ⇒ Adapter
Returns a new instance of Adapter.
8 9 10 11 12 13 |
# File 'lib/inferx/adapter.rb', line 8 def initialize(redis, = {}) @redis = redis = @namespace = [:namespace] @manual = !![:manual] end |
Instance Method Details
#categories_key ⇒ String
Get the key for access to categories.
25 26 27 |
# File 'lib/inferx/adapter.rb', line 25 def categories_key @categories_key ||= make_categories_key end |
#make_categories_key ⇒ String
Make the key for access to categories.
32 33 34 35 36 |
# File 'lib/inferx/adapter.rb', line 32 def make_categories_key parts = %w(inferx categories) parts.insert(1, @namespace) if @namespace parts.join(':') end |
#make_category_key(category_name) ⇒ String
Make the key for access to scores stored each by word.
42 43 44 |
# File 'lib/inferx/adapter.rb', line 42 def make_category_key(category_name) "#{categories_key}:#{category_name}" end |
#manual? ⇒ Boolean
Determine if manual save.
18 19 20 |
# File 'lib/inferx/adapter.rb', line 18 def manual? @manual end |
#spawn(klass, *args) ⇒ Object
Spawn an instance of any class.
52 53 54 |
# File 'lib/inferx/adapter.rb', line 52 def spawn(klass, *args) klass.new(@redis, *args, ) end |