Sha256: 26b143c181e0706b93dfee43ebb64e4220ea55bebcf119ea30b006898e8cbb56

Contents?: true

Size: 774 Bytes

Versions: 2

Compression:

Stored size: 774 Bytes

Contents

module Flms
  class Block < ActiveRecord::Base
    attr_accessible :name, :title, :thumbnail

    has_many :blocks_pages, class_name: 'Flms::BlocksPage', dependent: :destroy
    has_many :pages, through: :blocks_pages, class_name: 'Flms::Page'
    has_many :layers

    mount_uploader :thumbnail, ThumbnailImageUploader

    validates :name, presence: true
    validates :name, :'flms/css_name' => true

    scope :ordered, order('ordering')

    # Return the total scroll duration for this block, taking in to account the fact that
    # layers can and will overlap.  Return 0 if block has no layers.
    def scroll_duration
      layers.map(&:scroll_end).max || 0
    end

  def thumbnail_uploaded_filename
    File.basename(thumbnail.path) if thumbnail?
  end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flms-0.9.0 app/models/flms/block.rb
flms-0.1.0 app/models/flms/block.rb