Class: Snapshot::PageVariant

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/postnhost/snapshot/page_variant.rb

Constant Summary collapse

SCALAR_ATTRIBUTES =
%i[language_id title title_tag og_title meta_description content].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



22
23
24
25
26
27
28
29
30
31
# File 'app/models/postnhost/snapshot/page_variant.rb', line 22

def self.footer_links_for(language)
  for_language(language)
    .joins(:page_snapshot)
    .merge(Postnhost::Snapshot::Page.where.not(slug: nil))
    .select(
      Postnhost::Snapshot::Page.arel_table[:slug].as("slug"),
      arel_table[:title].as("title")
    )
    .order(arel_table[:title], Postnhost::Snapshot::Page.arel_table[:slug])
end

Instance Method Details

#differs_from?(draft) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/models/postnhost/snapshot/page_variant.rb', line 37

def differs_from?(draft)
  SCALAR_ATTRIBUTES.any? { |attribute| public_send(attribute) != draft.public_send(attribute) }
end

#published?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/models/postnhost/snapshot/page_variant.rb', line 33

def published?
  true
end