Module: Spree::Api::Responders::RablTemplate

Included in:
AppResponder
Defined in:
lib/spree/api/responders/rabl_template.rb

Instance Method Summary collapse

Instance Method Details

#api_behaviorObject



19
20
21
22
23
24
25
26
# File 'lib/spree/api/responders/rabl_template.rb', line 19

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

#templateObject



15
16
17
# File 'lib/spree/api/responders/rabl_template.rb', line 15

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

#to_formatObject



5
6
7
8
9
10
11
12
13
# File 'lib/spree/api/responders/rabl_template.rb', line 5

def to_format
  if template
    render template, :status => options[:status] || 200
  else
    super
  end
rescue ActionView::MissingTemplate => e
  api_behavior
end