Sha256: 90977f95240db10f3b5c9a7277a51109380af9b562f81dbd395ab90db5f37c08

Contents?: true

Size: 720 Bytes

Versions: 5

Compression:

Stored size: 720 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
        end

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

        def api_behavior
          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

5 entries across 5 versions & 1 rubygems

Version Path
spree_api-3.0.1 lib/spree/api/responders/rabl_template.rb
spree_api-3.0.0 lib/spree/api/responders/rabl_template.rb
spree_api-3.0.0.rc4 lib/spree/api/responders/rabl_template.rb
spree_api-3.0.0.rc3 lib/spree/api/responders/rabl_template.rb
spree_api-3.0.0.rc1 lib/spree/api/responders/rabl_template.rb