lib/rolify/adapters/mongoid/role_adapter.rb in rolify-5.0.0 vs lib/rolify/adapters/mongoid/role_adapter.rb in rolify-5.1.0
- old
+ new
@@ -7,16 +7,17 @@
conditions = build_conditions(relation, args)
relation.any_of(*conditions)
end
def where_strict(relation, args)
+ return relation.where(:name => args[:name]) if args[:resource].blank?
resource = if args[:resource].is_a?(Class)
{class: args[:resource].to_s, id: nil}
else
{class: args[:resource].class.name, id: args[:resource].id}
end
- relation.where(:name => args[:name], :resource_type => resource[:class], :resource_id => resource[:id])
+ relation.where(:name => args[:name], :resource_type => resource[:class], :resource_id => resource[:id])
end
def find_cached(relation, args)
resource_id = (args[:resource].nil? || args[:resource].is_a?(Class) || args[:resource] == :any) ? nil : args[:resource].id
resource_type = args[:resource].is_a?(Class) ? args[:resource].to_s : args[:resource].class.name