Sha256: a08bc06c2ba8b38c8df6152715a30085936aedc7d61415451a9afb0deef891d3

Contents?: true

Size: 653 Bytes

Versions: 2

Compression:

Stored size: 653 Bytes

Contents

class LabeledDigitalAsset < DelegateClass(DigitalAsset)
  def initialize(da)
    super(da)
  end

  def audiences
    auds = __getobj__.audiences
    auds.map do |a| 
      term = TaxonomyTerm.term_id_is(a).try(:first)
      label = term.try(:label)
      term => label
    end
  end

  def fund
    prods = __getobj__.product_ids
    # for any product ids that have a FUND_CODE, return the first
    prods.each do |p|
      term = TaxonomyTerm.term_id_is(p).try(:first)
      tt = term.try(:term_type)
      if(tt.try(:[], 'FUND_CODE'))
        return tt['FUND_CODE'] => term.label
      end
    end
    return nil
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
daengine-0.2.17 app/models/labeled_digital_asset.rb
daengine-0.2.16 app/models/labeled_digital_asset.rb