Class: HerdstWorker::Configuration::Facade

Inherits:
Object
  • Object
show all
Defined in:
lib/herdst_worker/configuration/facade.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#actionsObject

Returns the value of attribute actions.



13
14
15
# File 'lib/herdst_worker/configuration/facade.rb', line 13

def actions
  @actions
end

#envObject

Returns the value of attribute env.



13
14
15
# File 'lib/herdst_worker/configuration/facade.rb', line 13

def env
  @env
end

#metadataObject

Returns the value of attribute metadata.



13
14
15
# File 'lib/herdst_worker/configuration/facade.rb', line 13

def 
  @metadata
end

#pathsObject

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

Returns:

  • (Boolean)


44
45
46
# File 'lib/herdst_worker/configuration/facade.rb', line 44

def is_dev?
    self.env == "development"
end

#is_prod?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/herdst_worker/configuration/facade.rb', line 34

def is_prod?
    self.env == "production"
end

#is_test?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/herdst_worker/configuration/facade.rb', line 39

def is_test?
    self.env == "test"
end