Module: SimpleRest::ActionControllerResponderMethods
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/simple_rest/action_controller_responder_methods.rb
Instance Method Summary collapse
- #build_jsonp_message(data, options) ⇒ Object
- #simple_to_html ⇒ Object
- #simple_to_js ⇒ Object
- #to_jsonp ⇒ Object
- #to_pdf ⇒ Object
- #to_xml ⇒ Object
- #to_yaml ⇒ Object
Instance Method Details
#build_jsonp_message(data, options) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/simple_rest/action_controller_responder_methods.rb', line 49 def (data, ) = {:status => [:status] || 200, :data => data} json = .to_json() callback, variable = controller.params[:callback], controller.params[:variable] if callback && variable "var #{variable} = #{json};\n#{callback}(#{variable});" elsif variable "var #{variable} = #{json};" elsif callback "#{callback}(#{json});" else json end end |
#simple_to_html ⇒ Object
45 46 47 |
# File 'lib/simple_rest/action_controller_responder_methods.rb', line 45 def simple_to_html render end |
#simple_to_js ⇒ Object
21 22 23 24 |
# File 'lib/simple_rest/action_controller_responder_methods.rb', line 21 def simple_to_js status = [:status] || :ok render :json => resource.to_json([:serialize_opts] || {}), :status => status end |
#to_jsonp ⇒ Object
40 41 42 43 |
# File 'lib/simple_rest/action_controller_responder_methods.rb', line 40 def to_jsonp text = (resource, ) render ({:content_type => :js, :text => text}.merge(.merge(:status => :ok))) end |
#to_pdf ⇒ Object
31 32 33 |
# File 'lib/simple_rest/action_controller_responder_methods.rb', line 31 def to_pdf render ([:pdf_opts] || {}).merge(:layout => false) end |
#to_xml ⇒ Object
35 36 37 38 |
# File 'lib/simple_rest/action_controller_responder_methods.rb', line 35 def to_xml status = [:status] || :ok render :xml => resource.to_xml([:serialize_opts] || {}), :status => status end |
#to_yaml ⇒ Object
26 27 28 29 |
# File 'lib/simple_rest/action_controller_responder_methods.rb', line 26 def to_yaml status = [:status] || :ok render :partial => 'shared/inspect', :content_type => 'text/html', :locals => {:data => resource}, :status => status end |