Class: Clickwrap::Document
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Clickwrap::Document
- Defined in:
- lib/clickwrap/models/document.rb
Overview
A logical document — :terms, :privacy_notice — separate from the
immutable versions that carry its actual bytes.
Instance Method Summary collapse
-
#current_version(locale: I18n.locale, at: Clickwrap.now) ⇒ Object
The version a policy should present right now for a locale: published, already effective, and not retired.
- #to_s ⇒ Object
- #version(label, locale: I18n.locale) ⇒ Object
Instance Method Details
#current_version(locale: I18n.locale, at: Clickwrap.now) ⇒ Object
The version a policy should present right now for a locale: published,
already effective, and not retired. A version scheduled for the future is
deliberately not presentable yet — that is what effective_at is for.
The version to present right now: published, already effective, and not
retired. A version scheduled for the future is deliberately not
presentable yet — that is what effective_at is for.
The ordering is by effective time, then by publication time as a
tie-breaker for two versions scheduled for the same instant. Publishing
always writes an effective_at, so no NULL reaches this comparison and
PostgreSQL and SQLite agree about which document the server offered.
30 31 32 33 34 35 36 37 38 |
# File 'lib/clickwrap/models/document.rb', line 30 def current_version(locale: I18n.locale, at: Clickwrap.now) versions .published .effective_at_or_before(at) .not_retired_at(at) .for_locale(locale) .order(effective_at: :desc, published_at: :desc, created_at: :desc) .first end |
#to_s ⇒ Object
44 |
# File 'lib/clickwrap/models/document.rb', line 44 def to_s = document_key |
#version(label, locale: I18n.locale) ⇒ Object
40 41 42 |
# File 'lib/clickwrap/models/document.rb', line 40 def version(label, locale: I18n.locale) versions.for_locale(locale).find_by(version_label: label) end |