Class: SpreeCmCommissioner::ShowEpisode
- Inherits:
-
Spree::Product
- Object
- Spree::Product
- SpreeCmCommissioner::ShowEpisode
- Includes:
- StoreMetadata
- Defined in:
- app/models/spree_cm_commissioner/show_episode.rb
Class Method Summary collapse
- .current_or_next_upcoming(now = Time.current) ⇒ Object
- .model_name ⇒ Object
- .polymorphic_name ⇒ Object
Instance Method Summary collapse
Class Method Details
.current_or_next_upcoming(now = Time.current) ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/models/spree_cm_commissioner/show_episode.rb', line 33 def self.current_or_next_upcoming(now = Time.current) current(now).or(upcoming(now)) .reorder( Arel.sql("CAST((spree_products.private_metadata #>> '{}')::jsonb ->> 'scheduled_at' AS timestamp) ASC"), Arel.sql("CAST((spree_products.private_metadata #>> '{}')::jsonb ->> 'episode_number' AS integer) ASC") ) end |
.model_name ⇒ Object
54 55 56 |
# File 'app/models/spree_cm_commissioner/show_episode.rb', line 54 def self.model_name Spree::Product.model_name end |
.polymorphic_name ⇒ Object
58 59 60 |
# File 'app/models/spree_cm_commissioner/show_episode.rb', line 58 def self.polymorphic_name name end |
Instance Method Details
#current? ⇒ Boolean
41 42 43 44 |
# File 'app/models/spree_cm_commissioner/show_episode.rb', line 41 def current? (scheduled_at.present? && scheduled_at <= Time.current) && (ends_at >= Time.current) end |
#show ⇒ Object
50 51 52 |
# File 'app/models/spree_cm_commissioner/show_episode.rb', line 50 def show @show ||= event end |
#upcoming? ⇒ Boolean
46 47 48 |
# File 'app/models/spree_cm_commissioner/show_episode.rb', line 46 def upcoming? scheduled_at.present? && scheduled_at > Time.current end |
#votable_id ⇒ Object
66 67 68 |
# File 'app/models/spree_cm_commissioner/show_episode.rb', line 66 def votable_id ['votable_id'] end |
#votable_type ⇒ Object
62 63 64 |
# File 'app/models/spree_cm_commissioner/show_episode.rb', line 62 def votable_type ['votable_type'] end |