Class: Locomotive::ContentAsset

Inherits:
Object
  • Object
show all
Includes:
Locomotive::Concerns::Asset::Checksum, Locomotive::Concerns::Asset::Types, Locomotive::Concerns::Asset::Vignette, Mongoid::Document
Defined in:
app/models/locomotive/content_asset.rb

Instance Method Summary collapse

Methods included from Locomotive::Concerns::Asset::Vignette

#alternative_vignette_url, #big_vignette_url, #vignette_url

Instance Method Details

#as_json(options = nil) ⇒ Object


40
41
42
43
44
# File 'app/models/locomotive/content_asset.rb', line 40

def as_json(options = nil)
  super.merge(
    thumbnail_url: self.big_vignette_url
  )
end

#content_typeObject

fields ##


12
# File 'app/models/locomotive/content_asset.rb', line 12

field :content_type,  type: String

#extnameObject


35
36
37
38
# File 'app/models/locomotive/content_asset.rb', line 35

def extname
  return nil unless self.source? && self.source_filename
  File.extname(self.source_filename).gsub(/^\./, '')
end

#orderedObject

scopes ##


28
# File 'app/models/locomotive/content_asset.rb', line 28

scope :ordered, -> { order_by(created_at: :desc) }

#siteObject

associations ##


19
# File 'app/models/locomotive/content_asset.rb', line 19

belongs_to :site, class_name: 'Locomotive::Site', validate: false, autosave: false

#sourceObject

behaviours ##


22
# File 'app/models/locomotive/content_asset.rb', line 22

validates_presence_of :source