Class: Halcyon::Config::Paths
- Inherits:
-
Object
- Object
- Halcyon::Config::Paths
- Defined in:
- lib/halcyon/config/paths.rb
Instance Attribute Summary collapse
-
#paths ⇒ Object
Returns the value of attribute paths.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Alias to
for
. -
#[]=(key, value) ⇒ Object
Alias for
define
. -
#defaults ⇒ Object
Default paths.
-
#define(key_or_hash, value = nil) ⇒ Object
Defines a path for the specified entity.
-
#for(key) ⇒ Object
Gets the path for the specified entity.
-
#initialize(paths = {}) ⇒ Paths
constructor
Creates a profile with the default paths.
- #inspect ⇒ Object
Constructor Details
#initialize(paths = {}) ⇒ Paths
Creates a profile with the default paths.
8 9 10 |
# File 'lib/halcyon/config/paths.rb', line 8 def initialize(paths={}) self.paths = Mash.new(self.defaults.merge(paths)) end |
Instance Attribute Details
#paths ⇒ Object
Returns the value of attribute paths.
5 6 7 |
# File 'lib/halcyon/config/paths.rb', line 5 def paths @paths end |
Instance Method Details
#[](key) ⇒ Object
Alias to for
.
24 25 26 |
# File 'lib/halcyon/config/paths.rb', line 24 def [](key) self.for(key) end |
#[]=(key, value) ⇒ Object
Alias for define
.
50 51 52 |
# File 'lib/halcyon/config/paths.rb', line 50 def []=(key, value) self.define(key, value) end |
#defaults ⇒ Object
Default paths.
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/halcyon/config/paths.rb', line 56 def defaults { :controller => Halcyon.root/'app', :model => Halcyon.root/'app'/'models', :lib => Halcyon.root/'lib', :config => Halcyon.root/'config', :init => Halcyon.root/'config'/'init', :log => Halcyon.root/'log' } end |
#define(key_or_hash, value = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/halcyon/config/paths.rb', line 38 def define(key_or_hash, value = nil) if key_or_hash.is_a?(Hash) and value.nil? key_or_hash.keys.each do |key| self.define(key, key_or_hash[key]) end else self.paths[key_or_hash] = value end end |
#for(key) ⇒ Object
18 19 20 |
# File 'lib/halcyon/config/paths.rb', line 18 def for(key) self.paths[key] or raise ArgumentError.new("Path is not defined") end |
#inspect ⇒ Object
67 68 69 |
# File 'lib/halcyon/config/paths.rb', line 67 def inspect "#<Halcyon::Config::Paths #{self.paths.keys.join(', ')}>" end |