Module: Alchemy::Publishable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Element, PageVersion
- Defined in:
- app/models/concerns/alchemy/publishable.rb
Instance Method Summary collapse
-
#already_public_for?(at: Current.preview_time) ⇒ Boolean
Determines if this record is already public for given time.
-
#public?(at: Current.preview_time) ⇒ Boolean
(also: #public)
Determines if this record is public.
-
#publishable? ⇒ Boolean
Determines if this record is publishable.
- #scheduled?(at: Current.preview_time) ⇒ Boolean
-
#still_public_for?(at: Current.preview_time) ⇒ Boolean
Determines if this record is still public for given time.
Instance Method Details
#already_public_for?(at: Current.preview_time) ⇒ Boolean
Determines if this record is already public for given time
55 56 57 |
# File 'app/models/concerns/alchemy/publishable.rb', line 55 def already_public_for?(at: Current.preview_time) !public_on.nil? && public_on <= at end |
#public?(at: Current.preview_time) ⇒ Boolean Also known as: public
Determines if this record is public
Takes the two timestamps public_on and public_until and returns true if the time given (Time.current per default) is in this timespan.
34 35 36 |
# File 'app/models/concerns/alchemy/publishable.rb', line 34 def public?(at: Current.preview_time) already_public_for?(at:) && still_public_for?(at:) end |
#publishable? ⇒ Boolean
Determines if this record is publishable
A record is publishable if a public_on timestamp is set and not expired yet.
48 49 50 |
# File 'app/models/concerns/alchemy/publishable.rb', line 48 def publishable? !public_on.nil? && still_public_for? end |
#scheduled?(at: Current.preview_time) ⇒ Boolean
39 40 41 |
# File 'app/models/concerns/alchemy/publishable.rb', line 39 def scheduled?(at: Current.preview_time) (public_on.present? && public_on > at) || (public_until.present? && public_until > at) end |
#still_public_for?(at: Current.preview_time) ⇒ Boolean
Determines if this record is still public for given time
62 63 64 |
# File 'app/models/concerns/alchemy/publishable.rb', line 62 def still_public_for?(at: Current.preview_time) public_until.nil? || public_until > at end |