Class: Buff::Config::Ruby::Evaluator
- Inherits:
-
Object
- Object
- Buff::Config::Ruby::Evaluator
- Defined in:
- lib/buff/config/ruby.rb
Class Method Summary collapse
-
.parse(contents) ⇒ Hash
Parse the contents of the Ruby file into a Hash.
Instance Method Summary collapse
-
#initialize(contents) ⇒ Evaluator
constructor
A new instance of Evaluator.
- #method_missing(m, *args, &block) ⇒ Object
- #platform_specific_path(path) ⇒ Object
Constructor Details
#initialize(contents) ⇒ Evaluator
Returns a new instance of Evaluator.
19 20 21 22 23 24 |
# File 'lib/buff/config/ruby.rb', line 19 def initialize(contents) @attributes = Hash.new instance_eval(contents) rescue Exception => ex raise Errors::InvalidConfig, ex end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/buff/config/ruby.rb', line 31 def method_missing(m, *args, &block) if args.size > 0 attributes[m.to_sym] = (args.length == 1) ? args[0] : args else super end end |
Class Method Details
.parse(contents) ⇒ Hash
Parse the contents of the Ruby file into a Hash.
13 14 15 |
# File 'lib/buff/config/ruby.rb', line 13 def parse(contents) self.new(contents).send(:attributes) end |
Instance Method Details
#platform_specific_path(path) ⇒ Object
27 28 29 |
# File 'lib/buff/config/ruby.rb', line 27 def platform_specific_path(path) Buff::Config::Ruby.platform_specific_path(path) end |