Sha256: fc46253bf1a239f72c46762a3eebd955bdf847e8982f054afbcbf6ca3c7e3565

Contents?: true

Size: 731 Bytes

Versions: 33

Compression:

Stored size: 731 Bytes

Contents

module Spree
  module Api
    module Responders
      module RablTemplate
        def to_format
          if template
            render template, :status => options[:status] || 200
          else
            super
          end

        rescue ActionView::MissingTemplate => e
          api_behavior(e)
        end

        def template
          request.headers['X-Spree-Template'] || controller.params[:template] || options[:default_template]
        end

        def api_behavior(error)
          if controller.params[:action] == "destroy"
            # Render a blank template
            super
          else
            # Do nothing and fallback to the default template
          end
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
spree_api-2.4.7 lib/spree/api/responders/rabl_template.rb
spree_api-2.3.10 lib/spree/api/responders/rabl_template.rb
spree_api-2.4.6 lib/spree/api/responders/rabl_template.rb
spree_api-2.3.9 lib/spree/api/responders/rabl_template.rb
spree_api-2.2.11 lib/spree/api/responders/rabl_template.rb
spree_api-2.2.10 lib/spree/api/responders/rabl_template.rb
spree_api-2.3.8 lib/spree/api/responders/rabl_template.rb
spree_api-2.4.5 lib/spree/api/responders/rabl_template.rb
spree_api-2.4.4 lib/spree/api/responders/rabl_template.rb
spree_api-2.3.7 lib/spree/api/responders/rabl_template.rb
spree_api-2.4.3 lib/spree/api/responders/rabl_template.rb
spree_api-2.2.9 lib/spree/api/responders/rabl_template.rb
spree_api-2.4.2 lib/spree/api/responders/rabl_template.rb
spree_api-2.3.6 lib/spree/api/responders/rabl_template.rb
spree_api-2.2.8 lib/spree/api/responders/rabl_template.rb
spree_api-2.4.1 lib/spree/api/responders/rabl_template.rb
spree_api-2.4.0 lib/spree/api/responders/rabl_template.rb
spree_api-2.3.5 lib/spree/api/responders/rabl_template.rb
spree_api-2.2.7 lib/spree/api/responders/rabl_template.rb
spree_api-2.4.0.rc3 lib/spree/api/responders/rabl_template.rb