custom_fields 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/custom_fields/field.rb +6 -3
- data/lib/custom_fields/version.rb +1 -1
- metadata +3 -3
data/lib/custom_fields/field.rb
CHANGED
@@ -5,10 +5,12 @@ module CustomFields
|
|
5
5
|
include ::Mongoid::Document
|
6
6
|
include ::Mongoid::Timestamps
|
7
7
|
|
8
|
+
AVAILABLE_TYPES = %w(default string text email date boolean file select float integer money
|
9
|
+
tags relationship_default belongs_to has_many many_to_many)
|
10
|
+
|
8
11
|
## types ##
|
9
|
-
|
10
|
-
|
11
|
-
include "CustomFields::Types::#{type.classify}::Field".constantize
|
12
|
+
AVAILABLE_TYPES.each do |type|
|
13
|
+
include "CustomFields::Types::#{type.camelize}::Field".constantize
|
12
14
|
end
|
13
15
|
|
14
16
|
## fields ##
|
@@ -24,6 +26,7 @@ module CustomFields
|
|
24
26
|
## validations ##
|
25
27
|
validates_presence_of :label, :type
|
26
28
|
validates_exclusion_of :name, in: lambda { |f| CustomFields.options[:reserved_names].map(&:to_s) }
|
29
|
+
validates_inclusion_of :type, in: AVAILABLE_TYPES
|
27
30
|
validates_format_of :name, with: /^[a-z]([A-Za-z0-9_]+)?$/
|
28
31
|
validate :uniqueness_of_label_and_name
|
29
32
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: custom_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
@@ -252,7 +252,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
252
252
|
version: '0'
|
253
253
|
segments:
|
254
254
|
- 0
|
255
|
-
hash:
|
255
|
+
hash: -3863339637599729275
|
256
256
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
257
257
|
none: false
|
258
258
|
requirements:
|