Class: Cash::Config::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/cash/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(active_record, options = {}) ⇒ Config

Returns a new instance of Config.



46
47
48
# File 'lib/cash/config.rb', line 46

def initialize(active_record, options = {})
  @active_record, @options = active_record, options
end

Instance Attribute Details

#active_recordObject (readonly)

Returns the value of attribute active_record.



39
40
41
# File 'lib/cash/config.rb', line 39

def active_record
  @active_record
end

#optionsObject (readonly)

Returns the value of attribute options.



39
40
41
# File 'lib/cash/config.rb', line 39

def options
  @options
end

Class Method Details

.create(active_record, options, indices = []) ⇒ Object



41
42
43
44
# File 'lib/cash/config.rb', line 41

def self.create(active_record, options, indices = [])
  active_record.cache_config = new(active_record, options)
  indices.each { |i| active_record.index i.attributes, i.options }
end

Instance Method Details

#indicesObject



62
63
64
# File 'lib/cash/config.rb', line 62

def indices
  @indices ||= active_record == ActiveRecord::Base ? [] : [Index.new(self, active_record, active_record.primary_key)]
end

#inherit(active_record) ⇒ Object



66
67
68
# File 'lib/cash/config.rb', line 66

def inherit(active_record)
  self.class.create(active_record, @options, indices)
end

#repositoryObject



50
51
52
# File 'lib/cash/config.rb', line 50

def repository
  @options[:repository]
end

#ttlObject



54
55
56
# File 'lib/cash/config.rb', line 54

def ttl
  @options[:ttl]
end

#versionObject



58
59
60
# File 'lib/cash/config.rb', line 58

def version
  @options[:version] || 1
end