Class: VER::Action
Direct Known Subclasses
Constant Summary
Constants inherited from Struct
Instance Attribute Summary collapse
-
#handler ⇒ Object
Returns the value of attribute handler.
-
#invocation ⇒ Object
Returns the value of attribute invocation.
-
#mode ⇒ Object
Returns the value of attribute mode.
Instance Method Summary collapse
- #call(widget, *given_args) ⇒ Object
- #combine(action) ⇒ Object
- #to_a ⇒ Object
- #to_method(widget) ⇒ Object
- #to_proc ⇒ Object
Methods inherited from Struct
Instance Attribute Details
#handler ⇒ Object
Returns the value of attribute handler
2 3 4 |
# File 'lib/ver/action.rb', line 2 def handler @handler end |
#invocation ⇒ Object
Returns the value of attribute invocation
2 3 4 |
# File 'lib/ver/action.rb', line 2 def invocation @invocation end |
#mode ⇒ Object
Returns the value of attribute mode
2 3 4 |
# File 'lib/ver/action.rb', line 2 def mode @mode end |
Instance Method Details
#call(widget, *given_args) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ver/action.rb', line 3 def call(, *given_args) case handler when Symbol .send(handler).send(*invocation, *given_args) when Module method, *args = *invocation handler.send(method, , *args, *given_args) when nil .send(*invocation, *given_args) else raise ArgumentError end rescue => ex VER.error("Exception from %p" % [self]) VER.error(ex) end |
#combine(action) ⇒ Object
20 21 22 23 |
# File 'lib/ver/action.rb', line 20 def combine(action) invocation = [*self.invocation, action] self.class.new(invocation, handler, mode) end |
#to_a ⇒ Object
45 46 47 |
# File 'lib/ver/action.rb', line 45 def to_a [mode, self] end |
#to_method(widget) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ver/action.rb', line 29 def to_method() case handler when Symbol method = [*invocation].first .send(handler).method(method) when Module method, *args = *invocation handler.method(method) when nil method = [*invocation].first .method(method) else raise ArgumentError end end |
#to_proc ⇒ Object
25 26 27 |
# File 'lib/ver/action.rb', line 25 def to_proc Proc.new{|, *args| call(, *args) } end |