Class: ArCache::Configuration
- Inherits:
-
Object
- Object
- ArCache::Configuration
- Defined in:
- lib/ar_cache/configuration.rb
Instance Attribute Summary collapse
-
#cache_store ⇒ Object
readonly
Returns the value of attribute cache_store.
-
#coder ⇒ Object
readonly
Returns the value of attribute coder.
-
#column_length ⇒ Object
Returns the value of attribute column_length.
-
#disabled ⇒ Object
Returns the value of attribute disabled.
-
#expires_in ⇒ Object
Returns the value of attribute expires_in.
-
#read_uncommitted ⇒ Object
Returns the value of attribute read_uncommitted.
-
#select_disabled ⇒ Object
Returns the value of attribute select_disabled.
-
#tables_options ⇒ Object
readonly
Returns the value of attribute tables_options.
Class Method Summary collapse
- .cache_store=(cache_store) ⇒ Object
- .coder=(coder) ⇒ Object
- .configure ⇒ Object
- .get_table_options(name) ⇒ Object
- .tables_options=(options) ⇒ Object
Instance Attribute Details
#cache_store ⇒ Object (readonly)
Returns the value of attribute cache_store.
8 9 10 |
# File 'lib/ar_cache/configuration.rb', line 8 def cache_store @cache_store end |
#coder ⇒ Object (readonly)
Returns the value of attribute coder.
8 9 10 |
# File 'lib/ar_cache/configuration.rb', line 8 def coder @coder end |
#column_length ⇒ Object
Returns the value of attribute column_length.
7 8 9 |
# File 'lib/ar_cache/configuration.rb', line 7 def column_length @column_length end |
#disabled ⇒ Object
Returns the value of attribute disabled.
7 8 9 |
# File 'lib/ar_cache/configuration.rb', line 7 def disabled @disabled end |
#expires_in ⇒ Object
Returns the value of attribute expires_in.
7 8 9 |
# File 'lib/ar_cache/configuration.rb', line 7 def expires_in @expires_in end |
#read_uncommitted ⇒ Object
Returns the value of attribute read_uncommitted.
7 8 9 |
# File 'lib/ar_cache/configuration.rb', line 7 def read_uncommitted @read_uncommitted end |
#select_disabled ⇒ Object
Returns the value of attribute select_disabled.
7 8 9 |
# File 'lib/ar_cache/configuration.rb', line 7 def select_disabled @select_disabled end |
#tables_options ⇒ Object (readonly)
Returns the value of attribute tables_options.
8 9 10 |
# File 'lib/ar_cache/configuration.rb', line 8 def @tables_options end |
Class Method Details
.cache_store=(cache_store) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/ar_cache/configuration.rb', line 14 def self.cache_store=(cache_store) unless cache_store.is_a?(ActiveSupport::Cache::Store) raise ArgumentError, 'The cache_store must be an ActiveSupport::Cache::Store object' end @cache_store = cache_store end |
.coder=(coder) ⇒ Object
34 35 36 37 38 |
# File 'lib/ar_cache/configuration.rb', line 34 def self.coder=(coder) raise ArgumentError, 'The coder only support use YAML or JSON' unless [::YAML, ::JSON].include?(coder) @coder = coder end |
.configure ⇒ Object
10 11 12 |
# File 'lib/ar_cache/configuration.rb', line 10 def self.configure block_given? ? yield(self) : self end |
.get_table_options(name) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/ar_cache/configuration.rb', line 40 def self.(name) = [name.to_sym] || {} [:disabled] = disabled unless .key?(:disabled) [:select_disabled] = select_disabled unless .key?(:select_disabled) [:unique_indexes] = Array([:unique_indexes]).map { |index| Array(index).map(&:to_s).uniq }.uniq end |
.tables_options=(options) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ar_cache/configuration.rb', line 22 def self.() .each do |name, hash| raise ArgumentError, "The #{name.inspect} must be converted to Symbol type" unless name.is_a?(Symbol) hash.each_key do |k| raise ArgumentError, "The #{k.inspect} must be converted to Symbol type" unless k.is_a?(Symbol) end end @tables_options = end |