Skip to content

Commit

Permalink
Swap arguments of some methods to be consistent (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
coorasse authored Mar 22, 2022
1 parent 3d43db2 commit 6c7b6d8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/cancan/conditions_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,21 @@ def matches_conditions_hash?(subject, conditions = @conditions)
return adapter.matches_conditions_hash?(subject, conditions)
end

matches_all_conditions?(adapter, conditions, subject)
matches_all_conditions?(adapter, subject, conditions)
end

def matches_all_conditions?(adapter, conditions, subject)
def matches_all_conditions?(adapter, subject, conditions)
if conditions.is_a?(Hash)
matches_hash_conditions(adapter, conditions, subject)
matches_hash_conditions(adapter, subject, conditions)
elsif conditions.respond_to?(:include?)
conditions.include?(subject)
else
puts "does #{subject} match #{conditions}?"
subject == conditions
end
end

def matches_hash_conditions(adapter, conditions, subject)
def matches_hash_conditions(adapter, subject, conditions)
conditions.all? do |name, value|
if adapter.override_condition_matching?(subject, name, value)
adapter.matches_condition?(subject, name, value)
Expand Down

0 comments on commit 6c7b6d8

Please sign in to comment.