Class: ActiveStash::IndexLookup
- Inherits:
-
Object
- Object
- ActiveStash::IndexLookup
- Defined in:
- lib/active_stash/index_lookup.rb
Instance Attribute Summary collapse
-
#indexes ⇒ Object
readonly
Returns the value of attribute indexes.
Instance Method Summary collapse
- #concat(indexes) ⇒ Object
- #count_on(field) ⇒ Object
- #has?(field, index_type) ⇒ Boolean
-
#initialize(indexes) ⇒ IndexLookup
constructor
A new instance of IndexLookup.
- #on(field) ⇒ Object
- #on_and_of_type(field, index_type) ⇒ Object
Constructor Details
#initialize(indexes) ⇒ IndexLookup
Returns a new instance of IndexLookup.
5 6 7 |
# File 'lib/active_stash/index_lookup.rb', line 5 def initialize(indexes) @indexes = indexes end |
Instance Attribute Details
#indexes ⇒ Object (readonly)
Returns the value of attribute indexes.
3 4 5 |
# File 'lib/active_stash/index_lookup.rb', line 3 def indexes @indexes end |
Instance Method Details
#concat(indexes) ⇒ Object
9 10 11 |
# File 'lib/active_stash/index_lookup.rb', line 9 def concat(indexes) @indexes.concat(indexes) end |
#count_on(field) ⇒ Object
17 18 19 |
# File 'lib/active_stash/index_lookup.rb', line 17 def count_on(field) on(field).count end |
#has?(field, index_type) ⇒ Boolean
25 26 27 |
# File 'lib/active_stash/index_lookup.rb', line 25 def has?(field, index_type) on(field).any?{|idx| idx.type == index_type } end |
#on(field) ⇒ Object
13 14 15 |
# File 'lib/active_stash/index_lookup.rb', line 13 def on(field) @indexes.select{|idx| idx.field.to_s == field.to_s} end |
#on_and_of_type(field, index_type) ⇒ Object
21 22 23 |
# File 'lib/active_stash/index_lookup.rb', line 21 def on_and_of_type(field, index_type) @indexes.select{|idx| idx.field.to_s == field.to_s}.select{|idx| idx.type == index_type } end |