Class: Sections::Model::Section

Inherits:
Sequel::Model show all
Includes:
Zen::Model::Helper
Defined in:
lib/zen/package/sections/lib/sections/model/section.rb

Overview

Model that represents a single section.

Since:

Constant Summary

Constant Summary

Constants included from Zen::Model::Helper

Zen::Model::Helper::NoRegexpSupport

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from Zen::Model::Helper

included

Methods inherited from Sequel::Model

pk_hash

Class Method Details

+ (Mixed) search(query)

Searches for a number of sections of which the title or description matches the search query.

Examples:

Sections::Model::Section.search('pages')

Parameters:

  • query (String)

    The search query.

Returns:

  • (Mixed)

Since:

  • 16-10-2011



35
36
37
38
39
# File 'lib/zen/package/sections/lib/sections/model/section.rb', line 35

def self.search(query)
  return filter(
    search_column(:name, query) | search_column(:description, query)
  )
end

Instance Method Details

- (Object) validate

Specifies all validation rules for each section.

Since:

  • 0.1



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/zen/package/sections/lib/sections/model/section.rb', line 46

def validate
  validates_presence([
    :name,
    :comment_allow,
    :comment_require_account,
    :comment_moderate,
    :comment_format
  ])

  validates_max_length(255, [:name, :slug])

  validates_type(
    TrueClass,
    [:comment_allow, :comment_require_account, :comment_moderate]
  )

  validates_unique(:slug)
end