Module: Conduct::ClassMethods

Defined in:
lib/conduct.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_userObject

Returns the value of attribute current_user.



15
16
17
# File 'lib/conduct.rb', line 15

def current_user
  @current_user
end

Instance Method Details

#actionsObject



29
30
31
# File 'lib/conduct.rb', line 29

def actions
  @@actions ||= {}
end

#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

#define_action(*args) ⇒ Object



33
34
35
36
37
38
# File 'lib/conduct.rb', line 33

def define_action(*args)
  options = args.extract_options!
  options.each do |key, value|
    actions[key] = value
  end
end

#rulesObject



25
26
27
# File 'lib/conduct.rb', line 25

def rules
  @@rules ||= {}
end