Class: Spina::Admin::Conferences::PresentationType
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Spina::Admin::Conferences::PresentationType
- Defined in:
- app/models/spina/admin/conferences/presentation_type.rb
Overview
Instance Attribute Summary collapse
-
#conference ⇒ Conference?
Directly associated conference.
-
#duration ⇒ ActiveSupport::Duration?
The duration of dependent presentations.
-
#name ⇒ String?
The name of the presentation type.
-
#presentations ⇒ ActiveRecord::Relation
Presentations associated with #sessions.
-
#sessions ⇒ ActiveRecord::Relation
Directly associated sessions.
Instance Method Summary collapse
-
#minutes ⇒ Integer?
Duration in minutes.
-
#minutes=(minutes) ⇒ void
Sets the duration of the conference.
-
#sorted ⇒ ActiveRecord::Relation
All presentation types, ordered by name.
Instance Attribute Details
#conference ⇒ Conference?
Returns directly associated conference.
29 |
# File 'app/models/spina/admin/conferences/presentation_type.rb', line 29 belongs_to :conference, -> { includes(:translations) }, inverse_of: :presentation_types, touch: true |
#duration ⇒ ActiveSupport::Duration?
Returns the duration of dependent presentations.
25 |
# File 'app/models/spina/admin/conferences/presentation_type.rb', line 25 attribute :duration, :interval |
#name ⇒ String?
Returns the name of the presentation type.
18 |
# File 'app/models/spina/admin/conferences/presentation_type.rb', line 18 translates :name, fallbacks: true |
#presentations ⇒ ActiveRecord::Relation
Returns Presentations associated with #sessions.
39 |
# File 'app/models/spina/admin/conferences/presentation_type.rb', line 39 has_many :presentations, -> { distinct.includes(:translations) }, through: :sessions |
#sessions ⇒ ActiveRecord::Relation
Note:
A presentation type cannot be destroyed if it has dependent sessions.
Returns directly associated sessions.
34 |
# File 'app/models/spina/admin/conferences/presentation_type.rb', line 34 has_many :sessions, -> { includes(:translations) }, inverse_of: :presentation_type, dependent: :restrict_with_error |
Instance Method Details
#minutes ⇒ Integer?
Returns duration in minutes. Nil if the conference has no duration.
45 46 47 48 49 |
# File 'app/models/spina/admin/conferences/presentation_type.rb', line 45 def minutes return if duration.blank? duration.to_i / ActiveSupport::Duration::PARTS_IN_SECONDS[:minutes] end |
#minutes=(minutes) ⇒ void
This method returns an undefined value.
Sets the duration of the conference.
54 55 56 |
# File 'app/models/spina/admin/conferences/presentation_type.rb', line 54 def minutes=(minutes) self.duration = minutes.to_i.minutes end |
#sorted ⇒ ActiveRecord::Relation
Returns all presentation types, ordered by name.
21 |
# File 'app/models/spina/admin/conferences/presentation_type.rb', line 21 scope :sorted, -> { i18n.order :name } |