Module: Squire::Base::ClassMethods

Included in:
Proxy
Defined in:
lib/squire/base.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Serves as a bridge between config for convenient calling of setting on class level.



45
46
47
# File 'lib/squire/base.rb', line 45

def method_missing(method, *args, &block)
  config.send(method, *args, &block)
end

Instance Method Details

#config(&block) ⇒ Object

Return loaded configuration and settings

config.a # => 1
config.b = 2


38
39
40
# File 'lib/squire/base.rb', line 38

def config(&block)
  squire.settings(&block)
end

#squire(&block) ⇒ Object

Return an object for configurating internal loading of settings and setting a namespace, source, etc.

Examples

squire.namespace 'namespace'
squire.source 'file.yml'
squire.reload!

Accepts a block for more DSL-like way:

squire do |squire|
  ...
end

squire do
  namespace ...
emd


23
24
25
26
27
28
29
30
31
# File 'lib/squire/base.rb', line 23

def squire(&block)
  @squire ||= Squire::Configuration.new

  if block_given?
    block.arity > 0 ? block.call(@squire) : @squire.instance_eval(&block)
  end

  @squire
end