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



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

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

.type_namesObject



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

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

Instance Method Details

#attributes_protected_by_defaultObject



48
49
50
51
52
# File 'app/models/section.rb', line 48

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)


44
45
46
# File 'app/models/section.rb', line 44

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

#pathObject



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

def path
  _path == site.home_section.send(:_path) ? '' : _path
end

#typeObject



36
37
38
# File 'app/models/section.rb', line 36

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