Class: CustomFields::Model::CustomFieldType
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- CustomFields::Model::CustomFieldType
- Includes:
- Zen::Model::Helper
- Defined in:
- lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_type.rb
Overview
Model for managing custom field types.
Constant Summary
Constant Summary
Constants included from Zen::Model::Helper
Zen::Model::Helper::NoRegexpSupport
Class Method Summary (collapse)
-
+ (Mixed) search(query)
Searches for a set of custom field types.
-
+ (Hash) type_hash
Returns a hash where the keys are the IDs of all custom field types and the values the full language strings based on the value of the column "language_string".
Instance Method Summary (collapse)
-
- (Object) validate
Validates the model before inserting/updating the database record.
Methods included from Zen::Model::Helper
Methods inherited from Sequel::Model
Class Method Details
+ (Mixed) search(query)
Searches for a set of custom field types.
22 23 24 25 |
# File 'lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_type.rb', line 22 def self.search(query) return filter(search_column(:custom_field_types__name, query)) \ .eager(:custom_field_method) end |
+ (Hash) type_hash
Returns a hash where the keys are the IDs of all custom field types and the values the full language strings based on the value of the column "language_string".
35 36 37 38 39 40 41 42 43 |
# File 'lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_type.rb', line 35 def self.type_hash rows = {} CustomFieldType.select(:id, :language_string).each do |row| rows[row.id] = lang(row.language_string) end return rows end |
Instance Method Details
- (Object) validate
Validates the model before inserting/updating the database record.
50 51 52 53 54 55 56 57 |
# File 'lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_type.rb', line 50 def validate validates_presence([:name, :language_string, :custom_field_method_id]) validates_integer(:custom_field_method_id) validates_type(TrueClass, [:serialize, :allow_markup]) validates_format(/^[a-zA-Z\-_0-9\s]*$/, [:html_class]) validates_max_length(255, [:name, :language_string, :html_class]) end |