Class: OrdinaryCms::Page

Inherits:
Object
  • Object
show all
Includes:
ActsAsPage, Mongoid::Document, Mongoid::Orderable
Defined in:
app/models/ordinary_cms/page.rb

Instance Method Summary collapse

Instance Method Details

#matches?(factory) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)


25
26
27
28
29
30
31
# File 'app/models/ordinary_cms/page.rb', line 25

def matches?(factory)
  raise ArgumentError, 'Argument is not OrdinaryCms::Factories::Page' unless factory.is_a? Factories::Page
  factory.sections.each do |s|
    return false if self.sections.where(name: s.name).empty?
  end
  true
end

#section(name) ⇒ Object



16
17
18
# File 'app/models/ordinary_cms/page.rb', line 16

def section(name)
  sections.where(name: name).first
end

#set_as_root!Object



20
21
22
23
# File 'app/models/ordinary_cms/page.rb', line 20

def set_as_root!
  Page.where(root: true).update_all root: false
  self.update_attributes! root: true
end