Class: Locomotive::ContentAsset
- Inherits:
-
Object
- Object
- Locomotive::ContentAsset
- 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
- #as_json(options = nil) ⇒ Object
-
#content_type ⇒ Object
fields ##.
- #extname ⇒ Object
-
#ordered ⇒ Object
scopes ##.
-
#site ⇒ Object
associations ##.
-
#source ⇒ Object
behaviours ##.
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( = nil) super.merge( thumbnail_url: self.big_vignette_url ) end |
#content_type ⇒ Object
fields ##
12 |
# File 'app/models/locomotive/content_asset.rb', line 12 field :content_type, type: String |
#extname ⇒ Object
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 |
#ordered ⇒ Object
scopes ##
28 |
# File 'app/models/locomotive/content_asset.rb', line 28 scope :ordered, -> { order_by(created_at: :desc) } |
#site ⇒ Object
associations ##
19 |
# File 'app/models/locomotive/content_asset.rb', line 19 belongs_to :site, class_name: 'Locomotive::Site', validate: false, autosave: false |
#source ⇒ Object
behaviours ##
22 |
# File 'app/models/locomotive/content_asset.rb', line 22 validates_presence_of :source |