Class: Dslh::Scope
- Inherits:
-
Object
- Object
- Dslh::Scope
- Defined in:
- lib/dslh.rb
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/dslh.rb', line 52 def method_missing(method_name, *args, &block) key_conv = @__options__[:key_conv] || @__options__[:conv] value_conv = @__options__[:value_conv] || @__options__[:conv] nested_hash = block ? Dslh.eval(@__options__, &block) : nil method_name = key_conv.call(method_name) if key_conv if args.empty? @__hash__[method_name] = nested_hash else value = args.length > 1 ? args : args[0] value = value_conv.call(value) if value_conv if nested_hash @__hash__[method_name] = { value => nested_hash } else @__hash__[method_name] = value end return @__hash__ end end |