Class: Spree::Api::BaseController

Inherits:
ActionController::Metal
  • Object
show all
Includes:
ActionController::Head, ActionController::Redirecting, ControllerSetup, Core::ControllerHelpers::SSL
Defined in:
app/controllers/spree/api/base_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ControllerSetup

included

Instance Attribute Details

#current_api_userObject

Returns the value of attribute current_api_user.



16
17
18
# File 'app/controllers/spree/api/base_controller.rb', line 16

def current_api_user
  @current_api_user
end

Instance Method Details

#map_nested_attributes_keys(klass, attributes) ⇒ Object



39
40
41
42
43
44
45
46
# File 'app/controllers/spree/api/base_controller.rb', line 39

def map_nested_attributes_keys(klass, attributes)
  nested_keys = klass.nested_attributes_options.keys
  attributes.inject({}) do |h, (k,v)|
    key = nested_keys.include?(k.to_sym) ? "#{k}_attributes" : k
    h[key] = v
    h
  end.with_indifferent_access
end

#set_jsonp_formatObject



32
33
34
35
36
37
# File 'app/controllers/spree/api/base_controller.rb', line 32

def set_jsonp_format
  if params[:callback] && request.get?
    self.response_body = "#{params[:callback]}(#{response.body})"
    headers["Content-Type"] = 'application/javascript'
  end
end