Class: ApiSketch::DSL::Attributes
- Defined in:
- lib/api_sketch/dsl/attributes.rb
Constant Summary collapse
- TYPES =
[:integer, :string, :float, :boolean, :datetime, :timestamp, :document, :array, :file]
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(container_type, &block) ⇒ Attributes
constructor
A new instance of Attributes.
- #to_a ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(container_type, &block) ⇒ Attributes
Returns a new instance of Attributes.
5 6 7 8 9 10 |
# File 'lib/api_sketch/dsl/attributes.rb', line 5 def initialize(container_type, &block) @container_type = container_type @params = [] define_singleton_method(:initialize_attributes, block) initialize_attributes end |
Class Method Details
.build_by(data_type, attribute_name, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/api_sketch/dsl/attributes.rb', line 33 def build_by(data_type, attribute_name, &block) = {data_type: data_type} [:name] = attribute_name if attribute_name case data_type when :document, :array ::ApiSketch::Model::Attribute.new(::ApiSketch::DSL::ComplexAttributeParser.new(data_type, &block).to_h.merge()) else ::ApiSketch::Model::Attribute.new(::ApiSketch::DSL::AttributeParser.new(data_type, &block).to_h.merge()) end end |
Instance Method Details
#to_a ⇒ Object
12 13 14 |
# File 'lib/api_sketch/dsl/attributes.rb', line 12 def to_a @params end |