Class: DigitalAssetsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- DigitalAssetsController
- Includes:
- DigitalAssetsHelper
- Defined in:
- app/controllers/digital_assets_controller.rb
Instance Method Summary collapse
- #destroy ⇒ Object
- #fund_docs ⇒ Object
-
#index ⇒ Object
(also: #search)
GET /digital_assets GET /digital_assets.json /digital_assets/search/sami_code=92023 /digital_assets/search/sami_code=NE00192&title=Fund%20Prospectus&fund_code=20293.
-
#show ⇒ Object
GET /digital_assets/1 GET /digital_assets/1.json.
- #update ⇒ Object (also: #create)
- #updated_time ⇒ Object
Methods included from DigitalAssetsHelper
Instance Method Details
#destroy ⇒ Object
44 45 46 47 48 |
# File 'app/controllers/digital_assets_controller.rb', line 44 def destroy da = DigitalAsset.find(params[:id]) da.delete head :ok end |
#fund_docs ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/controllers/digital_assets_controller.rb', line 60 def fund_docs @digital_assets = [] fund_doctypes = {:doctype => [ DigitalAsset::ContentType::PROSPECTUS, DigitalAsset::ContentType::SUMMARY_PROSPECTUS, DigitalAsset::ContentType::SAI, DigitalAsset::ContentType::ANNUAL_REPORT, DigitalAsset::ContentType::SEMIANNUAL_REPORT, DigitalAsset::ContentType::FACTSHEET, DigitalAsset::ContentType::COMMENTARY ]} @digital_assets = search_da(fund_doctypes) # remove anything that doesn't have a fundcode @digital_assets = @digital_assets.reject {|da| da.fund_code.nil?} respond_with(@digital_assets) end |
#index ⇒ Object Also known as: search
GET /digital_assets GET /digital_assets.json /digital_assets/search/sami_code=92023 /digital_assets/search/sami_code=NE00192&title=Fund%20Prospectus&fund_code=20293
15 16 17 18 19 20 |
# File 'app/controllers/digital_assets_controller.rb', line 15 def index search_params = params[:search] || request.query_parameters @digital_assets = search_params ? search_da(search_params) : DigitalAsset.all # respond_with(@digital_assets) render json: @digital_assets end |
#show ⇒ Object
GET /digital_assets/1 GET /digital_assets/1.json
25 26 27 28 |
# File 'app/controllers/digital_assets_controller.rb', line 25 def show @digital_asset = /\w{4,8}\.\d{0,3}/ =~ params[:id] ? DigitalAsset.sami_is(params[:id]).desc(:changed_at).first : DigitalAsset.find(params[:id]) respond_with(@digital_asset) end |
#update ⇒ Object Also known as: create
30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/digital_assets_controller.rb', line 30 def update da_passed = params[:digital_asset] da = DigitalAsset.find_or_initialize_by(digital_asset_id: da_passed[:digital_asset_id]) creating = da.new? da.update_attributes! da_passed if(creating) head :created, location: digital_asset_path(da) else head :ok end end |
#updated_time ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/digital_assets_controller.rb', line 50 def updated_time ids = params[:ids] updated_time = Hash.new ids.each do |id| da = DigitalAsset.where(:digital_asset_id => id) updated_time[id] = da[0].doc_changed_at if da.present? end render json: updated_time.to_json, status: :ok end |