fixing error on protected sanitize_sql - closes #111
This commit is contained in:
parent
7a17586eb3
commit
f8631dcc93
|
@ -71,7 +71,7 @@ module CanCan
|
|||
end
|
||||
|
||||
def sanitize_sql(conditions)
|
||||
@sanitizer.sanitize_sql(conditions)
|
||||
@sanitizer.send(:sanitize_sql, conditions)
|
||||
end
|
||||
|
||||
# Takes two hashes and does a deep merge.
|
||||
|
|
|
@ -19,25 +19,29 @@ class Ability
|
|||
end
|
||||
end
|
||||
|
||||
# this class helps out in testing nesting and SQL conditions
|
||||
# this class helps out in testing SQL conditions
|
||||
class Person
|
||||
def self.sanitize_sql(hash_cond)
|
||||
case hash_cond
|
||||
when Hash
|
||||
sanitize_hash(hash_cond).join(' AND ')
|
||||
when Array
|
||||
hash_cond.shift.gsub('?'){"#{hash_cond.shift.inspect}"}
|
||||
when String then hash_cond
|
||||
class << self
|
||||
protected
|
||||
|
||||
def sanitize_sql(hash_cond)
|
||||
case hash_cond
|
||||
when Hash
|
||||
sanitize_hash(hash_cond).join(' AND ')
|
||||
when Array
|
||||
hash_cond.shift.gsub('?'){"#{hash_cond.shift.inspect}"}
|
||||
when String then hash_cond
|
||||
end
|
||||
end
|
||||
|
||||
def sanitize_hash(hash)
|
||||
hash.map do |name, value|
|
||||
if Hash === value
|
||||
sanitize_hash(value).map{|cond| "#{name}.#{cond}"}
|
||||
else
|
||||
"#{name}=#{value}"
|
||||
end
|
||||
end.flatten
|
||||
end
|
||||
end
|
||||
|
||||
def self.sanitize_hash(hash)
|
||||
hash.map do |name, value|
|
||||
if Hash === value
|
||||
sanitize_hash(value).map{|cond| "#{name}.#{cond}"}
|
||||
else
|
||||
"#{name}=#{value}"
|
||||
end
|
||||
end.flatten
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user