Class: MoulinRouge::CanCan::Method
- Inherits:
-
Object
- Object
- MoulinRouge::CanCan::Method
- Defined in:
- lib/moulin_rouge/cancan/method.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, *args, &block) ⇒ Method
constructor
A new instance of Method.
-
#send_to(object, proc_scope = nil) ⇒ Object
Send this method to the given object.
Constructor Details
#initialize(name, *args, &block) ⇒ Method
Returns a new instance of Method.
5 6 7 |
# File 'lib/moulin_rouge/cancan/method.rb', line 5 def initialize(name, *args, &block) @name, @args, @block = name, args, block end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
4 5 6 |
# File 'lib/moulin_rouge/cancan/method.rb', line 4 def args @args end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
4 5 6 |
# File 'lib/moulin_rouge/cancan/method.rb', line 4 def block @block end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/moulin_rouge/cancan/method.rb', line 4 def name @name end |
Instance Method Details
#send_to(object, proc_scope = nil) ⇒ Object
Send this method to the given object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/moulin_rouge/cancan/method.rb', line 10 def send_to(object, proc_scope = nil) # Evaluate any proc in args if args.last.is_a?(Hash) args.last.each do |key, value| if value.is_a?(Proc) args.last[key] = value.call(proc_scope || object) end end end # Send object.send(name, *args, &block) end |