Class: Memcacheable::FetchByCriteria
- Defined in:
- lib/memcacheable/fetch_by_criteria.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#criteria ⇒ Object
Returns the value of attribute criteria.
-
#klass ⇒ Object
Returns the value of attribute klass.
Instance Method Summary collapse
- #criteria_cacheable? ⇒ Boolean
-
#initialize(klass, *args) ⇒ FetchByCriteria
constructor
A new instance of FetchByCriteria.
Methods inherited from Fetcher
Constructor Details
#initialize(klass, *args) ⇒ FetchByCriteria
Returns a new instance of FetchByCriteria.
9 10 11 12 13 14 |
# File 'lib/memcacheable/fetch_by_criteria.rb', line 9 def initialize(klass, *args) self.klass = klass self.criteria = args. raise "Only hash-style args accepted! Illegal args: #{args.inspect}" if args.any? raise "No cache_index found in #{klass.name} matching fields #{criteria.keys.inspect}!" unless criteria_cacheable? end |
Instance Attribute Details
#criteria ⇒ Object
Returns the value of attribute criteria.
3 4 5 |
# File 'lib/memcacheable/fetch_by_criteria.rb', line 3 def criteria @criteria end |
#klass ⇒ Object
Returns the value of attribute klass.
3 4 5 |
# File 'lib/memcacheable/fetch_by_criteria.rb', line 3 def klass @klass end |
Instance Method Details
#criteria_cacheable? ⇒ Boolean
5 6 7 |
# File 'lib/memcacheable/fetch_by_criteria.rb', line 5 def criteria_cacheable? klass.cached_indexes.include? criteria.keys.map(&:to_sym).sort end |