Sha256: 0fa37b62a16e5ce59838121d90bcd2cf9644433df74fdbac9d5d3a9c39100e2f

Contents?: true

Size: 646 Bytes

Versions: 24

Compression:

Stored size: 646 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
          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

24 entries across 24 versions & 1 rubygems

Version Path
spree_api-3.2.9 lib/spree/api/responders/rabl_template.rb
spree_api-3.3.6 lib/spree/api/responders/rabl_template.rb
spree_api-3.2.8 lib/spree/api/responders/rabl_template.rb
spree_api-3.3.5 lib/spree/api/responders/rabl_template.rb
spree_api-3.3.4 lib/spree/api/responders/rabl_template.rb
spree_api-3.2.7 lib/spree/api/responders/rabl_template.rb
spree_api-3.3.3 lib/spree/api/responders/rabl_template.rb
spree_api-3.2.6 lib/spree/api/responders/rabl_template.rb
spree_api-3.3.2 lib/spree/api/responders/rabl_template.rb
spree_api-3.2.5 lib/spree/api/responders/rabl_template.rb
spree_api-3.3.1 lib/spree/api/responders/rabl_template.rb
spree_api-3.2.4 lib/spree/api/responders/rabl_template.rb
spree_api-3.3.0 lib/spree/api/responders/rabl_template.rb
spree_api-3.3.0.rc4 lib/spree/api/responders/rabl_template.rb
spree_api-3.3.0.rc3 lib/spree/api/responders/rabl_template.rb
spree_api-3.2.3 lib/spree/api/responders/rabl_template.rb
spree_api-3.2.2 lib/spree/api/responders/rabl_template.rb
spree_api-3.3.0.rc2 lib/spree/api/responders/rabl_template.rb
spree_api-3.3.0.rc1 lib/spree/api/responders/rabl_template.rb
spree_api-3.2.1 lib/spree/api/responders/rabl_template.rb