Class: DigitalAsset

Inherits:
Object
  • 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

Returns:

  • (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

#audienceObject



124
125
126
# File 'app/models/digital_asset.rb', line 124

def audience
  TaxonomyTerm.label_for_term(audiences[0])
end

#content_orgObject



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_labelObject



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

Returns:

  • (Boolean)


96
97
98
# File 'app/models/digital_asset.rb', line 96

def expired?
  expires_at < Time.now
end

#guidObject



72
73
74
# File 'app/models/digital_asset.rb', line 72

def guid
  super || digital_asset_id
end

#has_finra?Boolean

Returns:

  • (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?

Returns:

  • (Boolean)


105
106
107
# File 'app/models/digital_asset.rb', line 105

def is_institutional_use?
  audiences.index(DigitalAsset::Audience::INSTITUTIONAL_USE)
end

#is_investor_approved?Boolean Also known as: investor_approved?

Returns:

  • (Boolean)


100
101
102
# File 'app/models/digital_asset.rb', line 100

def is_investor_approved?
  audiences.index(DigitalAsset::Audience::INVESTOR_APPROVED)
end

#latest_doc_changed_atObject



80
81
82
# File 'app/models/digital_asset.rb', line 80

def latest_doc_changed_at
  doc_changed_at
end

#primary_extensionObject



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_pathObject



128
129
130
# File 'app/models/digital_asset.rb', line 128

def primary_path
  path
end

#productObject



110
111
112
# File 'app/models/digital_asset.rb', line 110

def product
  TaxonomyTerm.label_for_term(product_ids[0])
end

#programObject



113
114
115
# File 'app/models/digital_asset.rb', line 113

def program
  TaxonomyTerm.label_for_term(program_ids[0])
end

#validate_future_expirationObject



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