Class: Sift::Parameter

Inherits:
Object
  • Object
show all
Defined in:
lib/sift/parameter.rb

Overview

Value Object that wraps some handling of filter params

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(param, type, internal_name = param) ⇒ Parameter

Returns a new instance of Parameter.



6
7
8
9
10
# File 'lib/sift/parameter.rb', line 6

def initialize(param, type, internal_name = param)
  @param = param
  @type = type
  @internal_name = internal_name
end

Instance Attribute Details

#internal_nameObject (readonly)

Returns the value of attribute internal_name.



4
5
6
# File 'lib/sift/parameter.rb', line 4

def internal_name
  @internal_name
end

#paramObject (readonly)

Returns the value of attribute param.



4
5
6
# File 'lib/sift/parameter.rb', line 4

def param
  @param
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/sift/parameter.rb', line 4

def type
  @type
end

Instance Method Details

#handlerObject



21
22
23
24
25
26
27
# File 'lib/sift/parameter.rb', line 21

def handler
  if type == :scope
    ScopeHandler.new(self)
  else
    WhereHandler.new(self)
  end
end

#parse_optionsObject



12
13
14
15
16
17
18
19
# File 'lib/sift/parameter.rb', line 12

def parse_options
  {
    supports_boolean: supports_boolean?,
    supports_ranges: supports_ranges?,
    supports_json: supports_json?,
    supports_json_object: supports_json_object?
  }
end