Class: BitzerStore::Configure

Inherits:
Object
  • Object
show all
Defined in:
lib/bitzer_store/configure.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfigure

Returns a new instance of Configure.



15
16
17
# File 'lib/bitzer_store/configure.rb', line 15

def initialize
  @settings = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



27
28
29
# File 'lib/bitzer_store/configure.rb', line 27

def method_missing(name, *args, &block)
  set(name, *args)
end

Instance Attribute Details

#settingsObject (readonly)

Returns the value of attribute settings.



13
14
15
# File 'lib/bitzer_store/configure.rb', line 13

def settings
  @settings
end

Class Method Details

.setting(config) {|c| ... } ⇒ Object

Yields:

  • (c)

Raises:

  • (ArgumentError)


6
7
8
9
10
11
# File 'lib/bitzer_store/configure.rb', line 6

def self.setting(config)
  raise ArgumentError, "block not supplied" unless block_given?
  c = Configure.new
  yield(c)
  config.cache_store = :bitzer_store, c.settings
end

Instance Method Details

#common_setting(*args) ⇒ Object



31
32
33
34
# File 'lib/bitzer_store/configure.rb', line 31

def common_setting(*args)
  @common_options = args.extract_options!
  @common_args = args
end

#set(name, *args) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/bitzer_store/configure.rb', line 19

def set(name, *args)
  options = common_options.merge(args.extract_options!)
  args = args.presence || common_args
  args = args + [options] if options.present?

  @settings[name] = args
end