Sha256: 96ce2e58915ed64cdd743fd6727c4949261c8ed260f3d7c1a74943b13749e368

Contents?: true

Size: 862 Bytes

Versions: 3

Compression:

Stored size: 862 Bytes

Contents

class BigbluebuttonPlaybackFormat < ActiveRecord::Base
  include ActiveModel::ForbiddenAttributesProtection

  belongs_to :recording, :class_name => 'BigbluebuttonRecording'
  belongs_to :playback_type, :class_name => 'BigbluebuttonPlaybackType'

  delegate :name, :identifier, :visible, :visible?, :default, :default?, :description,
    to: :playback_type, allow_nil: true
  alias_attribute :format_type, :identifier

  validates :recording_id, :presence => true

  scope :ordered, -> {
    default = joins(:playback_type).where("bigbluebutton_playback_types.default = ?", true)
    if default.pluck(:id).empty?
      others = all
    else
      others = where("id NOT IN (?)", default.pluck(:id))
    end
    default.concat others
  }

  def length_in_secs
    if self.length.blank? || self.length < 0
      0
    else
      self.length * 60
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bigbluebutton_rails-2.2.0 app/models/bigbluebutton_playback_format.rb
bigbluebutton_rails-2.1.0 app/models/bigbluebutton_playback_format.rb
bigbluebutton_rails-2.0.0 app/models/bigbluebutton_playback_format.rb