Class: HerdstWorker::Configuration::Facade
- Inherits:
-
Object
- Object
- HerdstWorker::Configuration::Facade
- Defined in:
- lib/herdst_worker/configuration/facade.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#env ⇒ Object
Returns the value of attribute env.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#paths ⇒ Object
Returns the value of attribute paths.
Instance Method Summary collapse
- #config_for(name) ⇒ Object
-
#initialize(env, name) ⇒ Facade
constructor
A new instance of Facade.
- #is_dev? ⇒ Boolean
- #is_prod? ⇒ Boolean
- #is_test? ⇒ Boolean
Constructor Details
#initialize(env, name) ⇒ Facade
Returns a new instance of Facade.
16 17 18 19 20 21 22 |
# File 'lib/herdst_worker/configuration/facade.rb', line 16 def initialize(env, name) self.env = env.downcase self.paths = Paths.new self. = Metadata.new(env, name, self) self.actions = self.config_for(:actions) end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
13 14 15 |
# File 'lib/herdst_worker/configuration/facade.rb', line 13 def actions @actions end |
#env ⇒ Object
Returns the value of attribute env.
13 14 15 |
# File 'lib/herdst_worker/configuration/facade.rb', line 13 def env @env end |
#metadata ⇒ Object
Returns the value of attribute metadata.
13 14 15 |
# File 'lib/herdst_worker/configuration/facade.rb', line 13 def @metadata end |
#paths ⇒ Object
Returns the value of attribute paths.
13 14 15 |
# File 'lib/herdst_worker/configuration/facade.rb', line 13 def paths @paths end |
Instance Method Details
#config_for(name) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/herdst_worker/configuration/facade.rb', line 25 def config_for(name) file = "#{self.paths.config}/#{name}.yml" file_contents = ERB.new(File.new(file).read) yaml = YAML.load(file_contents.result(binding)).with_indifferent_access yaml.include?(self.env) ? yaml[self.env] : yaml end |
#is_dev? ⇒ Boolean
44 45 46 |
# File 'lib/herdst_worker/configuration/facade.rb', line 44 def is_dev? self.env == "development" end |
#is_prod? ⇒ Boolean
34 35 36 |
# File 'lib/herdst_worker/configuration/facade.rb', line 34 def is_prod? self.env == "production" end |
#is_test? ⇒ Boolean
39 40 41 |
# File 'lib/herdst_worker/configuration/facade.rb', line 39 def is_test? self.env == "test" end |