Class: Landable::Api::AssetsController
Constant Summary
Landable::ApiController::API_MEDIA_REGEX
Instance Method Summary
collapse
#api_media
Instance Method Details
#create ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/landable/api/assets_controller.rb', line 11
def create
asset = Asset.new(asset_params)
original = asset.duplicate_of
if original
head :moved_permanently, location: asset_url(original)
return
end
Asset.transaction do
asset.author = current_author
asset.save!
end
respond_with asset, status: :created, location: asset_url(asset)
end
|
#destroy ⇒ Object
28
29
30
31
32
|
# File 'app/controllers/landable/api/assets_controller.rb', line 28
def destroy
@asset.try(:deactivate)
respond_with @asset
end
|
#index ⇒ Object
34
35
36
37
|
# File 'app/controllers/landable/api/assets_controller.rb', line 34
def index
search = Landable::AssetSearchEngine.new(search_params.merge(ids: params[:ids]))
respond_with search.results, meta: search.meta
end
|
#reactivate ⇒ Object
39
40
41
42
43
|
# File 'app/controllers/landable/api/assets_controller.rb', line 39
def reactivate
@asset.try(:reactivate)
respond_with @asset
end
|
#show ⇒ Object
45
46
47
|
# File 'app/controllers/landable/api/assets_controller.rb', line 45
def show
respond_with @asset
end
|
#update ⇒ Object
49
50
51
52
53
|
# File 'app/controllers/landable/api/assets_controller.rb', line 49
def update
@asset.update_attributes!(asset_params)
respond_with @asset
end
|