Class: Alchemy::ResourceFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/alchemy/resource_filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filter, resource_name) ⇒ ResourceFilter

Returns a new instance of ResourceFilter.


7
8
9
10
11
12
# File 'lib/alchemy/resource_filter.rb', line 7

def initialize(filter, resource_name)
  @filter = filter
  @name = filter[:name]
  @resource_name = resource_name
  @values = filter[:values].presence || []
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.


5
6
7
# File 'lib/alchemy/resource_filter.rb', line 5

def name
  @name
end

Instance Method Details

#options_for_selectObject


14
15
16
# File 'lib/alchemy/resource_filter.rb', line 14

def options_for_select
  translated_values.zip(values)
end

#valuesObject


18
19
20
21
22
23
24
# File 'lib/alchemy/resource_filter.rb', line 18

def values
  if translated?
    @values.map { |v| v[1] }
  else
    @values
  end
end