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.
-
#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
43 44 45 |
# File 'app/models/concerns/alchemy/publishable.rb', line 43 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.
36 37 38 |
# File 'app/models/concerns/alchemy/publishable.rb', line 36 def publishable? !public_on.nil? && still_public_for? end |
#still_public_for?(time = Time.current) ⇒ Boolean
Determines if this record is still public for given time
50 51 52 |
# File 'app/models/concerns/alchemy/publishable.rb', line 50 def still_public_for?(time = Time.current) public_until.nil? || public_until >= time end |