Class: Garlic::Configurator::BlockParser
- Inherits:
-
Object
- Object
- Garlic::Configurator::BlockParser
- Defined in:
- lib/garlic/configurator.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#whitelist ⇒ Object
readonly
Returns the value of attribute whitelist.
Instance Method Summary collapse
-
#initialize(options, whitelist = [], &block) ⇒ BlockParser
constructor
A new instance of BlockParser.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(options, whitelist = [], &block) ⇒ BlockParser
Returns a new instance of BlockParser.
44 45 46 47 48 |
# File 'lib/garlic/configurator.rb', line 44 def initialize(, whitelist = [], &block) = @whitelist = whitelist instance_eval(&block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/garlic/configurator.rb', line 50 def method_missing(method, *args, &block) if block_given? && args.empty? && (whitelist.empty? || whitelist.include?(method)) [method.to_sym] = block else raise ArgumentError, "Don't know how to parse #{method} #{args.inspect unless args.empty?}" end end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
42 43 44 |
# File 'lib/garlic/configurator.rb', line 42 def end |
#whitelist ⇒ Object (readonly)
Returns the value of attribute whitelist.
42 43 44 |
# File 'lib/garlic/configurator.rb', line 42 def whitelist @whitelist end |