Sha256: 55073657f619e1962a579c10fb16333197dde342eca247860e3cc713ad004573

Contents?: true

Size: 748 Bytes

Versions: 2

Compression:

Stored size: 748 Bytes

Contents

class DigitalAssetLookupService

  def self.find_documents_by_fund_code(fund_code)
    da=[]
    taxonomy_term = TaxonomyTerm.send(:fund_code_is, fund_code)
    unless taxonomy_term.empty?
      p "Found product_id => #{taxonomy_term[0].term_id} for fund_code => #{fund_code} from Taxonomy."
      da = DigitalAsset.send(:product_in, [taxonomy_term[0].term_id])
    end
    da
  end

  def self.fund_code_from_id(taxonomy_id)
    TaxonomyTerm.term_id_is(taxonomy_id).try(:term_type).try([], 'FUND_CODE')
  end

  def self.fund_documents(fund_codes)
    # return a hash containing fund_code => [docs]
    fund_codes.reduce({}) do |sum, code|
      sum[code] = find_documents_by_fund_code(code) 
      sum
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
daengine-0.2.17 app/service/digital_asset_lookup_service.rb
daengine-0.2.16 app/service/digital_asset_lookup_service.rb