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
91
92
93
|
# File 'app/models/digital_asset.rb', line 91
def self.bulk_processed?
(stale.count.to_f / self.count) <= 0.05
end
|
.purge! ⇒ Object
79
80
81
|
# File 'app/models/digital_asset.rb', line 79
def self.purge!
DigitalAsset.stale.destroy_all if bulk_processed?
end
|
Instance Method Details
#audience ⇒ Object
127
128
129
|
# File 'app/models/digital_asset.rb', line 127
def audience
TaxonomyTerm.label_for_term(audiences[0])
end
|
#content_org ⇒ Object
119
120
121
|
# File 'app/models/digital_asset.rb', line 119
def content_org
TaxonomyTerm.label_for_term(content_organization_ids[0])
end
|
#content_type_label ⇒ Object
123
124
125
|
# File 'app/models/digital_asset.rb', line 123
def content_type_label
TaxonomyTerm.label_for_term(content_type)
end
|
#expired? ⇒ Boolean
99
100
101
|
# File 'app/models/digital_asset.rb', line 99
def expired?
expires_at < Time.now
end
|
#guid ⇒ Object
75
76
77
|
# File 'app/models/digital_asset.rb', line 75
def guid
super || digital_asset_id
end
|
#has_finra? ⇒ Boolean
95
96
97
|
# File 'app/models/digital_asset.rb', line 95
def has_finra?
finra_path.present?
end
|
#is_institutional_use? ⇒ Boolean
Also known as:
institutional_use?
108
109
110
|
# File 'app/models/digital_asset.rb', line 108
def is_institutional_use?
audiences.index(DigitalAsset::Audience::INSTITUTIONAL_USE)
end
|
#is_investor_approved? ⇒ Boolean
Also known as:
investor_approved?
103
104
105
|
# File 'app/models/digital_asset.rb', line 103
def is_investor_approved?
audiences.index(DigitalAsset::Audience::INVESTOR_APPROVED)
end
|
#latest_doc_changed_at ⇒ Object
83
84
85
|
# File 'app/models/digital_asset.rb', line 83
def latest_doc_changed_at
doc_changed_at
end
|
#primary_extension ⇒ Object
135
136
137
|
# File 'app/models/digital_asset.rb', line 135
def primary_extension
self.try(:path).try(:split,'.').try(:last).try(:upcase)
end
|
#primary_path ⇒ Object
131
132
133
|
# File 'app/models/digital_asset.rb', line 131
def primary_path
path
end
|
#product ⇒ Object
113
114
115
|
# File 'app/models/digital_asset.rb', line 113
def product
TaxonomyTerm.label_for_term(product_ids[0])
end
|
#program ⇒ Object
116
117
118
|
# File 'app/models/digital_asset.rb', line 116
def program
TaxonomyTerm.label_for_term(program_ids[0])
end
|
#validate_future_expiration ⇒ Object
87
88
89
|
# File 'app/models/digital_asset.rb', line 87
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
|