Class: ConfigLoader::Base
- Inherits:
-
Object
- Object
- ConfigLoader::Base
- Defined in:
- lib/config_loader/base.rb
Instance Attribute Summary collapse
-
#ext ⇒ Object
readonly
Returns the value of attribute ext.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #as_hash ⇒ Object
-
#initialize(file_path, options = {}) ⇒ Base
constructor
will try root element if such exists.
- #load(*args) ⇒ Object
Constructor Details
#initialize(file_path, options = {}) ⇒ Base
will try root element if such exists
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/config_loader/base.rb', line 8 def initialize file_path, = {} @path = File.dirname file_path @file_name = File.basename file_path parts = file_name.split(/(ya?ml$)/) name = parts.first @ext = parts.last @locale = [:locale] @file_path = @locale ? File.join(@path, "#{@name}.#{@locale}.#{@ext}") : file_path @dir = [:dir] if [:dir] @root = ([:root] || file_name.split('.').first).to_s @root = nil unless mashie.send(@root) @mashie = mashie.send(@root) if @root end |
Instance Attribute Details
#ext ⇒ Object (readonly)
Returns the value of attribute ext.
5 6 7 |
# File 'lib/config_loader/base.rb', line 5 def ext @ext end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
5 6 7 |
# File 'lib/config_loader/base.rb', line 5 def file_name @file_name end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
5 6 7 |
# File 'lib/config_loader/base.rb', line 5 def file_path @file_path end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
5 6 7 |
# File 'lib/config_loader/base.rb', line 5 def locale @locale end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/config_loader/base.rb', line 5 def path @path end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
5 6 7 |
# File 'lib/config_loader/base.rb', line 5 def root @root end |
Instance Method Details
#as_hash ⇒ Object
24 25 26 |
# File 'lib/config_loader/base.rb', line 24 def as_hash @as_hash ||= mashie end |
#load(*args) ⇒ Object
28 29 |
# File 'lib/config_loader/base.rb', line 28 def load *args end |