Module: Breadboard

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

Defined Under Namespace

Modules: Config

Instance Method Summary collapse

Instance Method Details

#configObject



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

def config
  Config
end

#configure(&block) ⇒ Object



12
13
14
# File 'lib/breadboard/breadboard.rb', line 12

def configure(&block)
  Config.instance_eval &block
end

#envObject



8
9
10
# File 'lib/breadboard/breadboard.rb', line 8

def env
  Config.env
end

#resetObject



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

def reset
  Config.reset
end

#service_for(model, environment = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/breadboard/breadboard.rb', line 16

def service_for(model, environment=nil)
  environment ||= Config.env.to_s.to_sym rescue :all
  model_superclass_chain = [model] + model.ancestors
  model_superclass_chain.each do |klass|
    klass_symbol = klass.to_s.to_sym
    site = config.send(klass_symbol).send(environment) || config.send(klass_symbol).send(:all)
    return site if site
  end
  return config.default.send(environment) || config.default.send(:all)
end