Method: WSDSL::Params#optional

Defined in:
lib/params.rb

#optional(param_name, opts = {}) ⇒ Array<WSDSL::Params::Rule>

Defines a new optional param rule

Examples:

Defining an optional service param called ‘id’ of ‘Integer` type

service.params.optional :id, :type => 'integer', :default => 9999

Parameters:

  • param_name (Symbol, String)

    The name of the param to define

  • opts (Hash) (defaults to: {})

    A hash representing the required param, the key being the param name name and the value being a hash of options.

Returns:

Since:

  • 0.0.3



315
316
317
318
319
320
321
322
# File 'lib/params.rb', line 315

def optional(param_name, opts={})
  # # recursive rule creation
  # if opts.size > 1
  #   opts.each_pair{|k,v| optional({k => v})}
  # else
  list_optional << Rule.new(param_name, opts)
  # end
end