class JsResponder
Constants
- VERSION
Attributes
instructions[RW]
Public Class Methods
new()
click to toggle source
# File lib/js_responder.rb, line 6 def initialize @instructions = [] end
Public Instance Methods
error(text)
click to toggle source
# File lib/js_responder.rb, line 32 def error(text) instructions << ['error', text] end
log(text)
click to toggle source
# File lib/js_responder.rb, line 24 def log(text) instructions << ['log', text] end
method_missing(method, *args)
click to toggle source
Introduce some flexibility by catching other commands
# File lib/js_responder.rb, line 37 def method_missing(method, *args) instructions << [[method.to_s], args].flatten! end
redirect(url)
click to toggle source
Default instruction set
# File lib/js_responder.rb, line 20 def redirect(url) instructions << ['redirect', url] end
success(text)
click to toggle source
# File lib/js_responder.rb, line 28 def success(text) instructions << ['success', text] end
transcode(context=nil, &block)
click to toggle source
# File lib/js_responder.rb, line 10 def transcode(context=nil, &block) if block_given? instance_exec(context, &block) else raise 'Expecting a block' end return instructions end