lib/protector/cancan/ability.rb in protector-cancan-0.1.0 vs lib/protector/cancan/ability.rb in protector-cancan-0.1.1

- old
+ new

@@ -18,11 +18,17 @@ end def self.included(mod) mod.class_eval do - def can_with_protector?(action, entity, *extra_args) + def can_with_protector?(action, entity_set, *extra_args) + if entity_set.is_a? Hash + entity = entity_set.values.first + else + entity = entity_set + end + if entity.respond_to?(:restrict!) && @protector_subject_defined @protector_models ||= Set.new model = entity model = model.class unless model.is_a?(Class) @@ -40,14 +46,13 @@ @protector_models << model end end - can_without_protector? action, entity, *extra_args + can_without_protector? action, entity_set, *extra_args end alias_method_chain :can?, :protector - end end end end end \ No newline at end of file