Closed Datyv closed 7 years ago
why would opts[:order_direction]
be frozen?
when the order_direction declaration in the view-controller is frozen. is there any szenario where the order_direction is case-insensitive?
So it's about string literals immutability in 2.3. Ok.
And your solution is remove this. That is not a solution. Do you see that a few lines below the code relies on opts[:order_direction]
being downcased?
Removing a line is not a solution. The solution is to create a new downcases String object and assign it to opts[:order_direction]
oh .. you're right. I completly overread that part. Shame. Is this better ?
order_direction = opts[:order_direction]
order_direction.downcase! if order_direction.is_a?(String)
# validate :order_direction
if order_direction && ! (order_direction == 'asc' || order_direction == :asc || order_direction == 'desc' ||
order_direction == :desc)
raise WiceGridArgumentError.new(":order_direction must be either 'asc' or 'desc'.")
end
No
opts[:order_direction] = opts[:order_direction].downcase
Sorry bothering you with this, but sadly this won't work. Still throws the same error.
But this works like a charm:
if opts[:order_direction] && ! (opts[:order_direction].to_s.casecmp('asc') == 0 || opts[:order_direction].to_s.casecmp('desc') == 0) raise WiceGridArgumentError.new(":order_direction must be either 'asc' or 'desc'.") end
What do do you mean this won't work.
irb(main):001:0> a = "ASC"
"ASC"
irb(main):002:0> a.freeze
"ASC"
irb(main):003:0> a.frozen?
true
irb(main):004:0> a = a.downcase
"asc"
irb(main):005:0> a.frozen?
false
oh yeah.. didn't see the missing bang, sorry
changed num_pages to total_pages (deprecated) remove a line that conflicts with
# frozen_string_literal: true