Class: Cash::Config::Config
- Inherits:
-
Object
- Object
- Cash::Config::Config
- Defined in:
- lib/cash/config.rb
Instance Attribute Summary collapse
-
#active_record ⇒ Object
readonly
Returns the value of attribute active_record.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #indices ⇒ Object
- #inherit(active_record) ⇒ Object
-
#initialize(active_record, options = {}) ⇒ Config
constructor
A new instance of Config.
- #repository ⇒ Object
- #ttl ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(active_record, options = {}) ⇒ Config
Returns a new instance of Config.
49 50 51 |
# File 'lib/cash/config.rb', line 49 def initialize(active_record, = {}) @active_record, @options = active_record, end |
Instance Attribute Details
#active_record ⇒ Object (readonly)
Returns the value of attribute active_record.
42 43 44 |
# File 'lib/cash/config.rb', line 42 def active_record @active_record end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
42 43 44 |
# File 'lib/cash/config.rb', line 42 def @options end |
Class Method Details
.create(active_record, options, indices = []) ⇒ Object
44 45 46 47 |
# File 'lib/cash/config.rb', line 44 def self.create(active_record, , indices = []) active_record.cache_config = new(active_record, ) indices.each { |i| active_record.index i.attributes, i. } end |
Instance Method Details
#indices ⇒ Object
65 66 67 |
# File 'lib/cash/config.rb', line 65 def indices @indices ||= active_record == ActiveRecord::Base ? [] : [Index.new(self, active_record, active_record.primary_key)] end |
#inherit(active_record) ⇒ Object
69 70 71 |
# File 'lib/cash/config.rb', line 69 def inherit(active_record) self.class.create(active_record, @options, indices) end |
#repository ⇒ Object
53 54 55 |
# File 'lib/cash/config.rb', line 53 def repository @options[:repository] end |
#ttl ⇒ Object
57 58 59 |
# File 'lib/cash/config.rb', line 57 def ttl @options[:ttl] end |
#version ⇒ Object
61 62 63 |
# File 'lib/cash/config.rb', line 61 def version @options[:version] || 1 end |