Class: Breakpoint::CommandBundle::Client
- Defined in:
- lib/action_controller/support/breakpoint.rb
Overview
Proxy to a Breakpoint client. Lets you directly execute code in the context of the client.
Instance Method Summary collapse
-
#eval(code) ⇒ Object
Executes the specified code at the client.
-
#initialize(eval_handler) ⇒ Client
constructor
:nodoc:.
-
#method_missing(method, *args, &block) ⇒ Object
Will execute the specified statement at the client.
Constructor Details
#initialize(eval_handler) ⇒ Client
:nodoc:
124 125 126 |
# File 'lib/action_controller/support/breakpoint.rb', line 124 def initialize(eval_handler) # :nodoc: @eval_handler = eval_handler end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Will execute the specified statement at the client.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/action_controller/support/breakpoint.rb', line 139 def method_missing(method, *args, &block) if args.empty? and not block result = eval "#{method}" else # This is a bit ugly. The alternative would be using an # eval context instead of an eval handler for executing # the code at the client. The problem with that approach # is that we would have to handle special expressions # like "self", "nil" or constants ourself which is hard. remote = eval %{ result = lambda { |block, *args| #{method}(*args, &block) } def result.call_with_block(*args, &block) call(block, *args) end result } remote.call_with_block(*args, &block) end return result end |
Instance Method Details
#eval(code) ⇒ Object
Executes the specified code at the client.
134 135 136 |
# File 'lib/action_controller/support/breakpoint.rb', line 134 def eval(code) @eval_handler.call(code) end |