Module: Privileged::Actor

Defined in:
lib/privileged.rb

Instance Method Summary collapse

Instance Method Details

#privilege(actor_method, resource_method, options = {}) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/privileged.rb', line 3

def privilege(actor_method, resource_method, options = {})
  options = { :default => false }.merge(options) 
  define_method actor_method do |resource|
    return options[:default] unless resource.respond_to?(resource_method)
    resource.send(resource_method, self)
  end
end