Class: Hyperdrive::Filter

Inherits:
Param
  • Object
show all
Defined in:
lib/hyperdrive/filter.rb

Instance Attribute Summary

Attributes inherited from Param

#constraints, #description, #name, #required, #type

Instance Method Summary collapse

Methods inherited from Param

#required?, #to_hash

Constructor Details

#initialize(name, description, options = {}) ⇒ Filter

Returns a new instance of Filter.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/hyperdrive/filter.rb', line 5

def initialize(name, description, options = {})
  @name = name.to_s
  @description = description
  options = default_options.merge(options)
  @required = if options[:required] == true
                %w(GET HEAD)
              elsif options[:required] == false
                []
              else
                Array(options[:required])
              end
  @type = options[:type]
  @constraints = "#{required_constraint} #{options[:constraints]}"
end