Class: Section

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
ActiveSupport::Memoizable
Defined in:
app/models/section.rb

Direct Known Subclasses

Page

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inherited(child) ⇒ Object


16
17
18
19
# File 'app/models/section.rb', line 16

def inherited(child)
  types << child.name
  super
end

.type_namesObject


21
22
23
# File 'app/models/section.rb', line 21

def type_names
  @type_names ||= types.map(&:underscore)
end

Instance Method Details

#attributes_protected_by_defaultObject


38
39
40
41
42
# File 'app/models/section.rb', line 38

def attributes_protected_by_default
  default = [self.class.primary_key]
  default << 'id' unless self.class.primary_key.eql? 'id'
  default
end

#home?Boolean

Returns:

  • (Boolean)

34
35
36
# File 'app/models/section.rb', line 34

def home?
  root? && previous_sibling.nil?
end

#pathObject


30
31
32
# File 'app/models/section.rb', line 30

def path
  home? ? '' : super
end

#typeObject


26
27
28
# File 'app/models/section.rb', line 26

def type
  read_attribute(:type) || 'Page'
end