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
Constructor Details
#initialize(active_record, options = {}) ⇒ Config
Returns a new instance of Config.
43 44 45 |
# File 'lib/cash/config.rb', line 43 def initialize(active_record, = {}) @active_record, @options = active_record, end |
Instance Attribute Details
#active_record ⇒ Object (readonly)
Returns the value of attribute active_record.
36 37 38 |
# File 'lib/cash/config.rb', line 36 def active_record @active_record end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
36 37 38 |
# File 'lib/cash/config.rb', line 36 def @options end |
Class Method Details
.create(active_record, options, indices = []) ⇒ Object
38 39 40 41 |
# File 'lib/cash/config.rb', line 38 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
55 56 57 |
# File 'lib/cash/config.rb', line 55 def indices @indices ||= active_record == ActiveRecord::Base ? [] : [Index.new(self, active_record, active_record.primary_key)] end |
#inherit(active_record) ⇒ Object
59 60 61 |
# File 'lib/cash/config.rb', line 59 def inherit(active_record) self.class.create(active_record, @options, indices) end |
#repository ⇒ Object
47 48 49 |
# File 'lib/cash/config.rb', line 47 def repository @options[:repository] end |
#ttl ⇒ Object
51 52 53 |
# File 'lib/cash/config.rb', line 51 def ttl @options[:ttl] end |