Class: ApiSketch::DSL::AttributeParser
- Defined in:
- lib/api_sketch/dsl/attribute_parser.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(container_type, &block) ⇒ AttributeParser
constructor
A new instance of AttributeParser.
- #method_missing(method_name, *arguments, &block) ⇒ Object
- #to_h ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(container_type, &block) ⇒ AttributeParser
Returns a new instance of AttributeParser.
3 4 5 6 7 8 9 |
# File 'lib/api_sketch/dsl/attribute_parser.rb', line 3 def initialize(container_type, &block) @attribute_values = {} @container_type = container_type # INFO: Such long method name is used to ensure that we are would not have such value as key at hash define_singleton_method(:set_attributes_as_hash_value_format, block) set_attributes_as_hash_value_format end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Object
11 12 13 |
# File 'lib/api_sketch/dsl/attribute_parser.rb', line 11 def method_missing(method_name, *arguments, &block) @attribute_values[method_name] = arguments.first || block end |
Instance Method Details
#to_h ⇒ Object
15 16 17 |
# File 'lib/api_sketch/dsl/attribute_parser.rb', line 15 def to_h @attribute_values end |