Class: DigitalAsset
- Inherits:
-
Object
show all
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/digital_asset.rb
Defined Under Namespace
Classes: Audience, ContentType, Document
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.bulk_processed? ⇒ Boolean
88
89
90
|
# File 'app/models/digital_asset.rb', line 88
def self.bulk_processed?
(stale.count.to_f / self.count) <= 0.05
end
|
.purge! ⇒ Object
76
77
78
|
# File 'app/models/digital_asset.rb', line 76
def self.purge!
DigitalAsset.stale.destroy_all if bulk_processed?
end
|
Instance Method Details
#content_org ⇒ Object
116
117
118
|
# File 'app/models/digital_asset.rb', line 116
def content_org
TaxonomyTerm.label_for_term(content_organization_ids[0])
end
|
#content_type_label ⇒ Object
120
121
122
|
# File 'app/models/digital_asset.rb', line 120
def content_type_label
TaxonomyTerm.label_for_term(content_type_id)
end
|
#expired? ⇒ Boolean
96
97
98
|
# File 'app/models/digital_asset.rb', line 96
def expired?
expires_at < Time.now
end
|
#guid ⇒ Object
72
73
74
|
# File 'app/models/digital_asset.rb', line 72
def guid
super || digital_asset_id
end
|
#has_finra? ⇒ Boolean
92
93
94
|
# File 'app/models/digital_asset.rb', line 92
def has_finra?
finra_path.present?
end
|
#is_institutional_use? ⇒ Boolean
Also known as:
institutional_use?
#is_investor_approved? ⇒ Boolean
Also known as:
investor_approved?
#latest_doc_changed_at ⇒ Object
80
81
82
|
# File 'app/models/digital_asset.rb', line 80
def latest_doc_changed_at
doc_changed_at
end
|
#primary_extension ⇒ Object
132
133
134
|
# File 'app/models/digital_asset.rb', line 132
def primary_extension
self.try(:path).try(:split,'.').try(:last).try(:upcase)
end
|
#primary_path ⇒ Object
128
129
130
|
# File 'app/models/digital_asset.rb', line 128
def primary_path
path
end
|
#validate_future_expiration ⇒ Object
84
85
86
|
# File 'app/models/digital_asset.rb', line 84
def validate_future_expiration
errors.add(:expires_at, "Expiration date must be at least 1 minute from now") unless expires_at and expires_at > 1.minute.from_now
end
|