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