Module: JsonSchematize::Cache::ClassMethods::Configuration
- Defined in:
- lib/json_schematize/cache/class_methods/configuration.rb
Instance Method Summary collapse
- #cache_client ⇒ Object
- #cache_client=(client) ⇒ Object
- #cache_configuration ⇒ Object
- #cache_namespace ⇒ Object
- #cache_namespace=(namespace) ⇒ Object
- #cache_options(key: nil, cache_client: nil, cache_namespace: nil, ttl: nil, update_on_change: nil, stochastic_cache_bust: nil) ⇒ Object
Instance Method Details
#cache_client ⇒ Object
40 41 42 |
# File 'lib/json_schematize/cache/class_methods/configuration.rb', line 40 def cache_client cache_configuration[:cache_client].is_a?(Proc) ? cache_configuration[:cache_client].call : cache_configuration[:cache_client] end |
#cache_client=(client) ⇒ Object
36 37 38 |
# File 'lib/json_schematize/cache/class_methods/configuration.rb', line 36 def cache_client=(client) cache_configuration[:cache_client] = client end |
#cache_configuration ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/json_schematize/cache/class_methods/configuration.rb', line 23 def cache_configuration @cache_configuration ||= begin { cache_client: JsonSchematize.configuration.cache_client, cache_namespace: JsonSchematize.configuration.cache_namespace, key: JsonSchematize.configuration.cache_key, stochastic_cache_bust: JsonSchematize.configuration.cache_stochastic_bust, ttl: JsonSchematize.configuration.cache_ttl, update_on_change: JsonSchematize.configuration.cache_update_on_change, } end end |
#cache_namespace ⇒ Object
15 16 17 |
# File 'lib/json_schematize/cache/class_methods/configuration.rb', line 15 def cache_namespace cache_configuration[:cache_namespace] ||= "jss:#{self.name.downcase}" end |
#cache_namespace=(namespace) ⇒ Object
19 20 21 |
# File 'lib/json_schematize/cache/class_methods/configuration.rb', line 19 def cache_namespace=(namespace) cache_configuration[:cache_namespace] = namespace end |
#cache_options(key: nil, cache_client: nil, cache_namespace: nil, ttl: nil, update_on_change: nil, stochastic_cache_bust: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/json_schematize/cache/class_methods/configuration.rb', line 5 def (key: nil, cache_client: nil, cache_namespace: nil, ttl: nil, update_on_change: nil, stochastic_cache_bust: nil) cache_configuration[:key] = key if key cache_configuration[:ttl] = ttl if ttl cache_configuration[:stochastic_cache_bust] = stochastic_cache_bust if stochastic_cache_bust cache_configuration[:update_on_change] = update_on_change if update_on_change cache_namespace = cache_configuration[:cache_namespace] = cache_namespace if cache_namespace self.cache_client = cache_configuration[:cache_client] = cache_client if cache_client end |