Class: Fairy::BScript
- Inherits:
-
Object
- Object
- Fairy::BScript
- Defined in:
- lib/fairy/share/block-source.rb
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(block_source, context, exception_handler) ⇒ BScript
constructor
A new instance of BScript.
Constructor Details
#initialize(block_source, context, exception_handler) ⇒ BScript
Returns a new instance of BScript.
23 24 25 26 27 |
# File 'lib/fairy/share/block-source.rb', line 23 def initialize(block_source, context, exception_handler) @block_source = block_source.dc_deep_copy @context = context @exception_handler = exception_handler end |
Instance Method Details
#evaluate ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fairy/share/block-source.rb', line 29 def evaluate match = /^(.*):([0-9]+)/.match(@block_source.backtrace.first) begin $stdout.replace_stdout do eval(@block_source.source, @context.bind, match[1], match[2].to_i) end rescue Exception Log::warn(self) do |sio| sio.puts "Warn: Exception raised:" sio.puts $! for l in $@ sio.puts "\t#{l}" end end bt = $!.backtrace bt = bt.select{|l| /fairy.*(share|job|backend|node|processor|controller)|deep-connect|__FORWARDABLE__|bin.*processor/ !~ l} unless CONF.DEBUG_FULL_BACKTRACE if bt.first bt.first.sub!("bind", @block_source.caller_method) end bt.push *@block_source.backtrace.dc_deep_copy $!.set_backtrace(bt) @exception_handler.handle_exception($!) end end |