Class: CallResponder
- Inherits:
-
ActionController::Responder
- Object
- ActionController::Responder
- CallResponder
- Defined in:
- lib/call_responder.rb
Constant Summary collapse
- RESPONDER_FILE =
"config/responder.yml"
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
Instance Method Summary collapse
-
#initialize(controller, resources, options = {}) ⇒ CallResponder
constructor
A new instance of CallResponder.
- #to_format ⇒ Object
- #to_pdf ⇒ Object
Constructor Details
#initialize(controller, resources, options = {}) ⇒ CallResponder
Returns a new instance of CallResponder.
7 8 9 10 11 12 13 14 15 |
# File 'lib/call_responder.rb', line 7 def initialize(controller, resources, ={}) super @controller = controller @request = @controller.request @format = @controller.formats.first @formats = [ :report ] raise LoadError.new("You must have the file #{RESPONDER_FILE} with 'url: URL' string") unless File.exists?(RESPONDER_FILE) @config = YAML::load(File.open(RESPONDER_FILE)) end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
3 4 5 |
# File 'lib/call_responder.rb', line 3 def controller @controller end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
3 4 5 |
# File 'lib/call_responder.rb', line 3 def format @format end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/call_responder.rb', line 3 def end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
3 4 5 |
# File 'lib/call_responder.rb', line 3 def request @request end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
3 4 5 |
# File 'lib/call_responder.rb', line 3 def resource @resource end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
3 4 5 |
# File 'lib/call_responder.rb', line 3 def resources @resources end |
Instance Method Details
#to_format ⇒ Object
17 18 19 20 |
# File 'lib/call_responder.rb', line 17 def to_format to_pdf if @format == 'pdf' super end |
#to_pdf ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/call_responder.rb', line 22 def to_pdf stream = RestClient.post(@config["url"], { :file => controller.render_to_string(:formats => @formats) } ) controller.send_data( stream, :filename => @request.fullpath.gsub("/","") ) end |