Method: Conduct::ClassMethods#can

Defined in:
lib/conduct.rb

#can(action, subject, *args, &block) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/conduct.rb', line 40

def can(action, subject, *args, &block)
  options = args.extract_options!
  block = args.pop if args.last.kind_of?(Proc)
  if defined_action_exists?(action)
    collection = fetch_action_from_collection(action)
    collection.each { |name| define_rule(name, subject, options, &block) }
  end
  define_rule(action, subject, options, &block)
end