Class: Cash::Index
- Inherits:
-
Object
- Object
- Cash::Index
- Includes:
- Attributes, Commands
- Defined in:
- lib/cash/index.rb
Defined Under Namespace
Modules: Attributes, Commands
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#initialize(config, active_record, attributes, options = {}) ⇒ Index
constructor
A new instance of Index.
- #matches?(query) ⇒ Boolean
- #serialize_object(object) ⇒ Object
Methods included from Attributes
#buffer, #limit, #order, #order_column, #ttl, #window
Methods included from Commands
#add, #delete, #remove, #update
Constructor Details
#initialize(config, active_record, attributes, options = {}) ⇒ Index
Returns a new instance of Index.
7 8 9 |
# File 'lib/cash/index.rb', line 7 def initialize(config, active_record, attributes, = {}) @config, @active_record, @attributes, @options = config, active_record, Array(attributes).collect(&:to_s).sort, end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/cash/index.rb', line 3 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/cash/index.rb', line 3 def @options end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
11 12 13 14 15 16 17 18 |
# File 'lib/cash/index.rb', line 11 def ==(other) case other when Index attributes == other.attributes else attributes == Array(other) end end |
#matches?(query) ⇒ Boolean
76 77 78 79 80 |
# File 'lib/cash/index.rb', line 76 def matches?(query) query.calculation? || (query.order == [order_column, order] && (!limit || (query.limit && query.limit + query.offset <= limit))) end |
#serialize_object(object) ⇒ Object
72 73 74 |
# File 'lib/cash/index.rb', line 72 def serialize_object(object) primary_key? ? object.shallow_clone : object.id end |