Class: Alchemy::PageVersion
- Inherits:
-
BaseRecord
- Object
- ActiveRecord::Base
- BaseRecord
- Alchemy::PageVersion
- Defined in:
- app/models/alchemy/page_version.rb
Constant Summary
Constants included from SearchableResource
SearchableResource::SEARCHABLE_COLUMN_TYPES
Class Method Summary collapse
Instance Method Summary collapse
-
#already_public_for?(time = Time.current) ⇒ Boolean
Determines if this version is already public for given time.
- #element_repository ⇒ Object
-
#public?(time = Time.current) ⇒ Boolean
Determines if this version is public.
-
#still_public_for?(time = Time.current) ⇒ Boolean
Determines if this version is still public for given time.
Methods included from SearchableResource
#ransackable_associations, #ransackable_attributes, #ransortable_attributes
Class Method Details
.public_on(time = Time.current) ⇒ Object
14 15 16 17 18 |
# File 'app/models/alchemy/page_version.rb', line 14 def self.public_on(time = Time.current) where("#{table_name}.public_on <= :time AND " \ "(#{table_name}.public_until IS NULL " \ "OR #{table_name}.public_until >= :time)", time: time) end |
Instance Method Details
#already_public_for?(time = Time.current) ⇒ Boolean
Determines if this version is already public for given time
37 38 39 |
# File 'app/models/alchemy/page_version.rb', line 37 def already_public_for?(time = Time.current) !public_on.nil? && public_on <= time end |
#element_repository ⇒ Object
48 49 50 |
# File 'app/models/alchemy/page_version.rb', line 48 def element_repository ElementsRepository.new(elements) end |
#public?(time = Time.current) ⇒ Boolean
Determines if this version 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.
30 31 32 |
# File 'app/models/alchemy/page_version.rb', line 30 def public?(time = Time.current) already_public_for?(time) && still_public_for?(time) end |
#still_public_for?(time = Time.current) ⇒ Boolean
Determines if this version is still public for given time
44 45 46 |
# File 'app/models/alchemy/page_version.rb', line 44 def still_public_for?(time = Time.current) public_until.nil? || public_until >= time end |