app/controllers/digital_assets_controller.rb in daengine-0.2.1 vs app/controllers/digital_assets_controller.rb in daengine-0.2.2

- old
+ new

@@ -1,7 +1,7 @@ class DigitalAssetsController < ApplicationController - + include DigitalAssetsHelper respond_to :json, :html, :only => [:index, :show, :search] CACHE_LAST_PARSE_TIME = 'last_parse_time' # GET /digital_assets # GET /digital_assets.json @@ -18,18 +18,10 @@ end #/digital_assets/search/sami_code=92023 #/digital_assets/search/sami_code=NE00192&title=Fund%20Prospectus&fund_code=20293 def search - @digital_assets = [] - # loop thru each parameter that matches one of the method signatures - @digital_assets = params.keys.select do |pk| - DigitalAsset.respond_to?("#{pk}_is".to_sym) or DigitalAsset.respond_to?("#{pk}_in".to_sym) - end.reduce(DigitalAsset) do |sum, key| - # for each key, call the 'named query' method with the value given and chain... - method = DigitalAsset.respond_to?("#{key}_in".to_sym) ? "#{key}_in".to_sym : "#{key}_is".to_sym - sum.send(method, method.to_s.end_with?('in') ? params[key].to_a : params[key]) # should return result of the send call for chaining - end + @digital_assets = search_da(params) respond_with(@digital_assets) end def sync_assets time0 = Rails.cache.read(CACHE_LAST_PARSE_TIME)