Class: ApiSketch::DSL::AttributeParser

Inherits:
Base
  • Object
show all
Defined in:
lib/api_sketch/dsl/attribute_parser.rb

Direct Known Subclasses

ComplexAttributeParser

Instance Method Summary collapse

Methods inherited from Base

#use_shared_block

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_hObject



15
16
17
# File 'lib/api_sketch/dsl/attribute_parser.rb', line 15

def to_h
  @attribute_values
end