Class: JsonApiFilter::FilterBy

Inherits:
Object
  • Object
show all
Defined in:
lib/json_api_filter/filter_by.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attr, value) ⇒ FilterBy

Returns a new instance of FilterBy.



6
7
8
9
# File 'lib/json_api_filter/filter_by.rb', line 6

def initialize(attr, value)
  @attr = attr
  @value = value
end

Instance Attribute Details

#attrObject (readonly)

Returns the value of attribute attr.



4
5
6
# File 'lib/json_api_filter/filter_by.rb', line 4

def attr
  @attr
end

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/json_api_filter/filter_by.rb', line 4

def value
  @value
end

Instance Method Details

#to_hashObject



11
12
13
14
15
# File 'lib/json_api_filter/filter_by.rb', line 11

def to_hash
  return {} unless parsed_value.present?

  { key.to_sym => parsed_value }
end