fixing broken spec and minor improvements to tableized_conditions method
This commit is contained in:
@@ -34,21 +34,16 @@ module CanCan
|
||||
end
|
||||
end
|
||||
|
||||
def tableized_conditions(c=nil)
|
||||
conditions = c || @conditions
|
||||
if conditions
|
||||
conditions.inject({}) do |tableized_conditions, (name, value)|
|
||||
if value.kind_of? Hash
|
||||
name = name.to_s.tableize.to_sym
|
||||
value = tableized_conditions(value)
|
||||
end
|
||||
tableized_conditions[name] = value
|
||||
tableized_conditions
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def tableized_conditions(conditions = @conditions)
|
||||
conditions.inject({}) do |result_hash, (name, value)|
|
||||
if value.kind_of? Hash
|
||||
name = name.to_s.tableize.to_sym
|
||||
value = tableized_conditions(value)
|
||||
end
|
||||
result_hash[name] = value
|
||||
result_hash
|
||||
end
|
||||
end
|
||||
|
||||
def only_block?
|
||||
conditions_empty? && !@block.nil?
|
||||
|
||||
Reference in New Issue
Block a user