Class: AridCache::Store::Configuration

Inherits:
Struct
  • Object
show all
Defined in:
lib/arid_cache/store.rb

Overview

Capture cache configurations and blocks and store them in the store.

A block is evaluated within the scope of this class. The blocks contains calls to methods which define the caches and give options for each cache.

Don’t instantiate directly. Rather instantiate the Instance- or ClassCacheConfiguration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, global_opts = {}) ⇒ Configuration

Returns a new instance of Configuration.



53
54
55
56
# File 'lib/arid_cache/store.rb', line 53

def initialize(klass, global_opts={})
  self.global_opts = global_opts
  self.klass = klass
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(key, *args, &block) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/arid_cache/store.rb', line 58

def method_missing(key, *args, &block)
  opts = global_opts.merge(args.empty? ? {} : args.first)
  case self
  when InstanceCacheConfiguration
    AridCache.store.add_instance_cache_configuration(klass, key, opts, block)
  else
    AridCache.store.add_class_cache_configuration(klass, key, opts, block)
  end
end

Instance Attribute Details

#global_optsObject

Returns the value of attribute global_opts

Returns:

  • (Object)

    the current value of global_opts



51
52
53
# File 'lib/arid_cache/store.rb', line 51

def global_opts
  @global_opts
end

#klassObject

Returns the value of attribute klass

Returns:

  • (Object)

    the current value of klass



51
52
53
# File 'lib/arid_cache/store.rb', line 51

def klass
  @klass
end