lib/canard/adapters/mongoid.rb in canard-0.4.2.pre vs lib/canard/adapters/mongoid.rb in canard-0.4.3
- old
+ new
@@ -28,11 +28,11 @@
def define_scopes_for_role(role)
include_scope = role.to_s.pluralize
exclude_scope = "non_#{include_scope}"
- scope include_scope, where("(this.#{roles_attribute_name} & #{mask_for(role)}) > 0")
- scope exclude_scope, any_of({roles_attribute_name => { "$exists" => false }}, {roles_attribute_name => nil}, {"$where" => "(this.#{roles_attribute_name} & #{mask_for(role)}) === 0"})
+ scope include_scope, lambda { where("(this.#{roles_attribute_name} & #{mask_for(role)}) > 0") }
+ scope exclude_scope, lambda { any_of({roles_attribute_name => { "$exists" => false }}, {roles_attribute_name => nil}, {"$where" => "(this.#{roles_attribute_name} & #{mask_for(role)}) === 0"}) }
end
end
end
end
\ No newline at end of file