Sha256: 2ec358d37981f52d5049c689ed6c1031adfe38653e5dca55fe92fc4c187c7914

Contents?: true

Size: 870 Bytes

Versions: 5

Compression:

Stored size: 870 Bytes

Contents

class Asset 
  
  include Mongoid::Document
  include Mongoid::Timestamps
  
  ## Extensions ##  
  include Models::Extensions::Asset::Vignette
  
  ## fields ##
  field :name, :type => String
  field :content_type, :type => String
  field :width, :type => Integer
  field :height, :type => Integer
  field :size, :type => Integer
  field :position, :type => Integer, :default => 0
  mount_uploader :source, AssetUploader
    
  ## associations ##
  embedded_in :collection, :class_name => 'AssetCollection', :inverse_of => :assets
  
  ## validations ##
  validates_presence_of :name, :source
  
  ## behaviours ##

  ## methods ##
  
  %w{image stylesheet javascript pdf video audio}.each do |type|
    define_method("#{type}?") do
      self.content_type == type
    end  
  end
  
  def to_liquid
    { :url => self.source.url }.merge(self.attributes)
  end
    
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
locomotive_cms-0.0.1.4 app/models/asset.rb
locomotive_cms-0.0.1.3 app/models/asset.rb
locomotive_cms-0.0.1.2 app/models/asset.rb
locomotive_cms-0.0.1.1 app/models/asset.rb
locomotive_cms-0.0.1 app/models/asset.rb