Class: CustomFields::Model::CustomField

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

Overview

Model for managing retrieving custom fields.

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 set of custom fields.

Parameters:

  • query (String)

    The search query.

Returns:

  • (Mixed)

Since:

  • 16-10-2011



28
29
30
# File 'lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb', line 28

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

Instance Method Details

- (Object) validate

Validates rules used whenever the model is created or saved.

Since:

  • 0.1



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb', line 37

def validate
  validates_presence([
    :name,
    :format,
    :custom_field_group_id,
    :custom_field_type_id
  ])

  validates_max_length(255, [:name, :slug])
  validates_type(TrueClass, [:required, :text_editor])

  validates_integer([
    :sort_order,
    :textarea_rows,
    :text_limit,
    :custom_field_group_id,
    :custom_field_type_id
  ])

  validates_presence(:slug) unless new?
  validates_unique(:slug)
end