Class: Dotmation::ConfigReader
- Inherits:
-
Object
- Object
- Dotmation::ConfigReader
- Defined in:
- lib/dotmation/config_reader.rb
Instance Method Summary collapse
- #method_missing(methd, *argv, &block) ⇒ Object
-
#read(config_data, config_filename = nil) ⇒ Object
returns a list of links and a hash of any other values given outside standard blocks.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(methd, *argv, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dotmation/config_reader.rb', line 17 def method_missing(methd, *argv, &block) if Dotmation::Repo::Link::METHODS.include?(methd) @repos.last.links << Dotmation::Repo::Link.new(methd, *argv) elsif @available_repos.include?(methd) && block @repos << Repo.const_get(methd.to_s.capitalize).new( *argv ) instance_eval(&block) else arg = (argv.size==1 ? argv.first : argv) @data[methd] = arg end end |
Instance Method Details
#read(config_data, config_filename = nil) ⇒ Object
returns a list of links and a hash of any other values given outside standard blocks
8 9 10 11 12 13 14 15 |
# File 'lib/dotmation/config_reader.rb', line 8 def read(config_data, config_filename=nil) @available_repos = Repo.classes_as_lc_symbols @data = {} @repos = [] args = [config_filename].compact eval( config_data, binding, *args ) [@data, @repos] end |