Sha256: 77621a96e2a85c51243879d4effc670b71543cc8a92641752c82ea5347ea38a6

Contents?: true

Size: 743 Bytes

Versions: 63

Compression:

Stored size: 743 Bytes

Contents

module DigitalAssetsHelper

  def search_da(params)
    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.respond_to?(:each) ?  digital_assets : []
  end

end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
daengine-0.5.13 app/helpers/digital_assets_helper.rb
daengine-0.5.10 app/helpers/digital_assets_helper.rb
daengine-0.5.9 app/helpers/digital_assets_helper.rb
daengine-0.5.8 app/helpers/digital_assets_helper.rb
daengine-0.5.7 app/helpers/digital_assets_helper.rb
daengine-0.5.2 app/helpers/digital_assets_helper.rb
daengine-0.5.1 app/helpers/digital_assets_helper.rb
daengine-0.5.0 app/helpers/digital_assets_helper.rb
daengine-0.4.9 app/helpers/digital_assets_helper.rb
daengine-0.4.8 app/helpers/digital_assets_helper.rb
daengine-0.4.7.9 app/helpers/digital_assets_helper.rb
daengine-0.4.7.8 app/helpers/digital_assets_helper.rb
daengine-0.4.7.7 app/helpers/digital_assets_helper.rb
daengine-0.4.7.6 app/helpers/digital_assets_helper.rb
daengine-0.4.7.5 app/helpers/digital_assets_helper.rb
daengine-0.4.7.3 app/helpers/digital_assets_helper.rb
daengine-0.4.7.2 app/helpers/digital_assets_helper.rb
daengine-0.4.7.1 app/helpers/digital_assets_helper.rb
daengine-0.4.7 app/helpers/digital_assets_helper.rb
daengine-0.4.6.5 app/helpers/digital_assets_helper.rb