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.0 lib/spree/api/responders/rabl_template.rb
spree_api-3.2.0.rc3 lib/spree/api/responders/rabl_template.rb
spree_api-3.2.0.rc2 lib/spree/api/responders/rabl_template.rb
spree_api-3.2.0.rc1 lib/spree/api/responders/rabl_template.rb