app/models/digital_asset.rb in daengine-0.4.6 vs app/models/digital_asset.rb in daengine-0.4.6.2
- old
+ new
@@ -53,11 +53,10 @@
scope :orderable, -> {where(orderable: true)}
scope :has_finra, -> {where(:'documents.content_type' => ContentType::FINRA)}
scope :audience_in, ->(audience) {where(:audiences.in => audience)}
scope :alphabetical, order_by(:title => :asc)
scope :not_xbrl, -> {excludes(:'documents.content_type' => ContentType::XBRL_DOCUMENT)}
-
#scope :order_by_fund, order_by[[:product_ids, :asc]]
#default_scope {not_in(:'documents.content_type' => ["LDJDCMAIK"])}
# validations
validates_presence_of :guid, :title, :changed_at, :published_at,
@@ -107,10 +106,14 @@
def has_finra?
finra_document != nil
end
+ def expired?
+ expires_at < Time.now
+ end
+
def finra_document
finra_idx = documents.index {|d| d.content_type == ContentType::FINRA}
documents[finra_idx] if finra_idx
end
@@ -123,39 +126,34 @@
audiences.index(DigitalAsset::Audience::INSTITUTIONAL_USE)
end
alias :institutional_use? :is_institutional_use?
def product
- @product ||= TaxonomyTerm.label_for_term(product_ids[0])
+ TaxonomyTerm.label_for_term(product_ids[0])
end
def program
- @program ||= TaxonomyTerm.label_for_term(program_ids[0])
+ TaxonomyTerm.label_for_term(program_ids[0])
end
def content_org
- @content_org ||= TaxonomyTerm.label_for_term(content_organization_ids[0])
+ TaxonomyTerm.label_for_term(content_organization_ids[0])
end
def fund_code
- if @fund_code
- return @fund_code
- end
- pid = product_ids.find {|pid| TaxonomyTerm.find_term_by_id(pid).try(:fund_code)}
- @fund_code = pid and TaxonomyTerm.find_term_by_id(pid).try(:fund_code).try(:rjust, 5, '0')
+ pid = product_ids.find {|pid| TaxonomyTerm.term_id_is(pid).first.try(:fund_code)}
+ pid and TaxonomyTerm.term_id_is(pid)[0].try(:fund_code).try(:rjust, 5, '0')
end
def content_type
- @content_type_label ||= TaxonomyTerm.label_for_term(content_type_id)
+ TaxonomyTerm.label_for_term(content_type_id)
end
def content_type_id
first_non_finra.try(:content_type)
end
- def pages
- @pages ||= first_non_finra.pages
- end
+ def pages; first_non_finra.pages end
def audience
- @audience ||= TaxonomyTerm.label_for_term(audiences[0])
+ TaxonomyTerm.label_for_term(audiences[0])
end
def primary_path
first_non_finra.try(:path)
end