Class: Locomotive::Api::CurrentSiteController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/locomotive/api/current_site_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Locomotive::ActionController::LocaleHelpers

#back_to_default_site_locale, #current_content_locale, #localized?, #set_back_office_locale, #set_current_content_locale, #setup_i18n_fallbacks

Class Method Details

.descriptionObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/locomotive/api/current_site_controller.rb', line 26

def self.description
  {
    overall: %{Manage the current site related to the domain name used to make the API call},
    actions: {
      show: {
        description: %{Return the attributes of the current site},
        response: Locomotive::SitePresenter.getters_to_hash,
        example: {
          command: %{curl 'http://mysite.com/locomotive/api/tokens.json'},
          response: %(TODO)
        }
      },
      update: {
        description: %{Update the current site},
        params: Locomotive::SitePresenter.setters_to_hash,
        example: {
          command: %{curl -d '...' -X UPDATE 'http://mysite.com/locomotive/api/current_site.json?auth_token=dtsjkqs1TJrWiSiJt2gg'},
          response: %(TODO)
        }
      },
      destroy: {
        description: %{Delete the current site},
        example: {
          command: %{curl -X DELETE 'http://mysite.com/locomotive/api/current_site.json?auth_token=dtsjkqs1TJrWiSiJt2gg'},
          response: %(TODO)
        }
      }
    }
  }
end

Instance Method Details

#destroyObject



19
20
21
22
23
24
# File 'app/controllers/locomotive/api/current_site_controller.rb', line 19

def destroy
  @site = current_site
  authorize! :destroy, @site
  @site.destroy
  respond_with(@site)
end

#showObject



5
6
7
8
9
# File 'app/controllers/locomotive/api/current_site_controller.rb', line 5

def show
  @site = current_site
  authorize! :show, @site
  respond_with(@site)
end

#updateObject



11
12
13
14
15
16
17
# File 'app/controllers/locomotive/api/current_site_controller.rb', line 11

def update
	@site = current_site
	authorize! :update, @site
  @site.from_presenter(params[:site])
  @site.save
	respond_with(@site)
end