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?(time = Time.current) ⇒ Boolean
Determines if this record is already public for given time.
-
#public?(time = Time.current) ⇒ Boolean
(also: #public)
Determines if this record is public.
-
#publishable? ⇒ Boolean
Determines if this record is publishable.
- #scheduled? ⇒ Boolean
-
#still_public_for?(time = Time.current) ⇒ Boolean
Determines if this record is still public for given time.
Instance Method Details
#already_public_for?(time = Time.current) ⇒ Boolean
Determines if this record is already public for given time
47 48 49 |
# File 'app/models/concerns/alchemy/publishable.rb', line 47 def already_public_for?(time = Time.current) !public_on.nil? && public_on <= time end |
#public?(time = Time.current) ⇒ 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.
26 27 28 |
# File 'app/models/concerns/alchemy/publishable.rb', line 26 def public?(time = Time.current) already_public_for?(time) && still_public_for?(time) end |
#publishable? ⇒ Boolean
Determines if this record is publishable
A record is publishable if a public_on timestamp is set and not expired yet.
40 41 42 |
# File 'app/models/concerns/alchemy/publishable.rb', line 40 def publishable? !public_on.nil? && still_public_for? end |
#scheduled? ⇒ Boolean
31 32 33 |
# File 'app/models/concerns/alchemy/publishable.rb', line 31 def scheduled? public_on&.future? || public_until&.future? end |
#still_public_for?(time = Time.current) ⇒ Boolean
Determines if this record is still public for given time
54 55 56 |
# File 'app/models/concerns/alchemy/publishable.rb', line 54 def still_public_for?(time = Time.current) public_until.nil? || public_until >= time end |