Class: Alchemy::PageVersion
- Inherits:
-
BaseRecord
- Object
- ActiveRecord::Base
- BaseRecord
- Alchemy::PageVersion
- Includes:
- Publishable
- Defined in:
- app/models/alchemy/page_version.rb
Constant Summary collapse
- METADATA_ATTRIBUTES =
Metadata attributes that are versioned (moved from Page)
%w[ title meta_description meta_keywords ].freeze
Constants included from SearchableResource
SearchableResource::SEARCHABLE_COLUMN_TYPES
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 Publishable
Methods included from ConfigMissing
Methods included from SearchableResource
#ransackable_associations, #ransackable_attributes, #ransackable_scopes, #ransortable_attributes
Instance Method Details
#already_public_for?(time = Time.current) ⇒ Boolean
Determines if this version is already public for given time
47 48 49 |
# File 'app/models/alchemy/page_version.rb', line 47 def already_public_for?(time = Time.current) !public_on.nil? && public_on <= time end |
#element_repository ⇒ Object
58 59 60 |
# File 'app/models/alchemy/page_version.rb', line 58 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.
40 41 42 |
# File 'app/models/alchemy/page_version.rb', line 40 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
54 55 56 |
# File 'app/models/alchemy/page_version.rb', line 54 def still_public_for?(time = Time.current) public_until.nil? || public_until >= time end |