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
|
# File 'app/controllers/landable/api/assets_controller.rb', line 11
def create
asset = Asset.new(asset_params)
if original = asset.duplicate_of
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
27
28
29
30
31
|
# File 'app/controllers/landable/api/assets_controller.rb', line 27
def destroy
@asset.try(:deactivate)
respond_with @asset
end
|
#index ⇒ Object
33
34
35
36
|
# File 'app/controllers/landable/api/assets_controller.rb', line 33
def index
search = Landable::AssetSearchEngine.new(search_params.merge(ids: params[:ids]))
respond_with search.results, meta: search.meta
end
|
#reactivate ⇒ Object
38
39
40
41
42
|
# File 'app/controllers/landable/api/assets_controller.rb', line 38
def reactivate
@asset.try(:reactivate)
respond_with @asset
end
|
#show ⇒ Object
44
45
46
|
# File 'app/controllers/landable/api/assets_controller.rb', line 44
def show
respond_with @asset
end
|
#update ⇒ Object
48
49
50
51
52
|
# File 'app/controllers/landable/api/assets_controller.rb', line 48
def update
@asset.update_attributes!(asset_params)
respond_with @asset
end
|