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
BOOLEAN_VALUES = TRUE_VALUES + FALSE_VALUES
S_SORTS = %w(s sorts).freeze
ASC_DESC = %w(asc desc).freeze
AND_OR = %w(and or).freeze
IN_NOT_IN = %w(in not_in).freeze

View File

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