Class: Apia::DSLs::ArgumentSet
- Defined in:
- lib/apia/dsls/argument_set.rb
Direct Known Subclasses
Instance Method Summary collapse
Methods inherited from Apia::DSL
#description, #initialize, #name, #no_schema
Constructor Details
This class inherits a constructor from Apia::DSL
Instance Method Details
#argument(name, *args, type: nil, **options, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/apia/dsls/argument_set.rb', line 11 def argument(name, *args, type: nil, **, &block) type = args[0] if type.nil? argument = Definitions::Argument.new(name, id: "#{@definition.id}/#{Helpers.camelize(name.to_s)}Argument") if type.is_a?(Array) argument.type = type[0] argument.array = true else argument.type = type argument.array = false end argument.required = [:required] if .key?(:required) argument.default = [:default] if .key?(:default) argument.description = [:description] if .key?(:description) argument.dsl.instance_eval(&block) if block_given? @definition.arguments[name.to_sym] = argument end |