Class: HerdstWorker::Configuration::Paths

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePaths

Returns a new instance of Paths.



9
10
11
12
13
14
15
16
17
# File 'lib/herdst_worker/configuration/paths.rb', line 9

def initialize
    self.root_path = ENV["ROOT_PATH"] || Dir.pwd
    
    self.paths = ActiveSupport::HashWithIndifferentAccess.new
    self.paths[:root] = self.root_path
    self.paths[:app] = "#{self.root_path}/app"
    self.paths[:config] = "#{self.root_path}/config"
    self.paths[:temp] = "#{self.root_path}/tmp"
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/herdst_worker/configuration/paths.rb', line 30

def method_missing(name)
    if self.paths.include?(name)
        self.paths[name]
    else
        raise NoMethodError
    end                
end

Instance Attribute Details

#pathsObject

Returns the value of attribute paths.



6
7
8
# File 'lib/herdst_worker/configuration/paths.rb', line 6

def paths
  @paths
end

#root_pathObject

Returns the value of attribute root_path.



6
7
8
# File 'lib/herdst_worker/configuration/paths.rb', line 6

def root_path
  @root_path
end

Instance Method Details

#[](name) ⇒ Object



25
26
27
# File 'lib/herdst_worker/configuration/paths.rb', line 25

def [](name)
    self.paths[name]
end

#[]=(name, value) ⇒ Object



20
21
22
# File 'lib/herdst_worker/configuration/paths.rb', line 20

def []=(name, value)
    self.paths[name] = "#{self.root_path}/#{value}"
end