Module: Breadboard::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/breadboard/config.rb,
lib/breadboard/env_config.rb,
lib/breadboard/environment.rb

Defined Under Namespace

Classes: EnvConfig, Environment

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



35
36
37
# File 'lib/breadboard/config.rb', line 35

def method_missing(method_name, *args, &block)
  config_or_access method_name, &block
end

Instance Method Details

#configObject



5
6
7
# File 'lib/breadboard/config.rb', line 5

def config
  @config ||= {}
end

#default(&block) ⇒ Object



15
16
17
# File 'lib/breadboard/config.rb', line 15

def default(&block)
  config_or_access :default, &block
end

#env(&block) ⇒ Object



9
10
11
12
13
# File 'lib/breadboard/config.rb', line 9

def env(&block)
  @env ||= proc { Rails.env }
  return @env.call unless block
  @env = block 
end

#model(model_name, &block) ⇒ Object



19
20
21
# File 'lib/breadboard/config.rb', line 19

def model(model_name, &block)
  config_or_access model_name, &block
end

#models(*model_classes, &block) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/breadboard/config.rb', line 27

def models(*model_classes, &block)
  raise "You must pass a block to the `models` method" if block.nil?
  
  model_classes.each do |model_class|
    config_or_access model_class, &block
  end
end

#resetObject



23
24
25
# File 'lib/breadboard/config.rb', line 23

def reset
  @config = {}
end