1
0
Fork 0
mirror of https://github.com/activerecord-hackery/ransack.git synced 2022-11-09 13:47:45 -05:00

Use frozen array constant

This commit is contained in:
Jon Atack 2014-10-13 20:23:21 +02:00
parent 075b879604
commit eac62ff044
2 changed files with 2 additions and 1 deletions

View file

@ -27,6 +27,7 @@ module Ransack
FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE'].to_set FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE'].to_set
BOOLEAN_VALUES = TRUE_VALUES + FALSE_VALUES BOOLEAN_VALUES = TRUE_VALUES + FALSE_VALUES
S_SORTS = %w(s sorts).freeze
ASC_DESC = %w(asc desc).freeze ASC_DESC = %w(asc desc).freeze
AND_OR = %w(and or).freeze AND_OR = %w(and or).freeze
IN_NOT_IN = %w(in not_in).freeze IN_NOT_IN = %w(in not_in).freeze

View file

@ -36,7 +36,7 @@ module Ransack
def build(params) def build(params)
collapse_multiparameter_attributes!(params).each do |key, value| collapse_multiparameter_attributes!(params).each do |key, value|
if ['s', 'sorts'].include?(key) if Ransack::Constants::S_SORTS.include?(key)
send("#{key}=", value) send("#{key}=", value)
elsif base.attribute_method?(key) elsif base.attribute_method?(key)
base.send("#{key}=", value) base.send("#{key}=", value)