custom_fields 1.0.0.beta.12 → 1.0.0.beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/{README → README.textile} +8 -7
- data/lib/custom_fields/field.rb +8 -2
- data/lib/custom_fields/version.rb +1 -1
- data/lib/custom_fields.rb +16 -0
- metadata +19 -19
data/{README → README.textile}
RENAMED
@@ -1,18 +1,19 @@
|
|
1
|
-
CustomFields
|
2
|
-
===========
|
1
|
+
h1. CustomFields
|
3
2
|
|
4
3
|
Manage custom fields to a mongoid document or a collection. This module is one of the core features we implemented in our custom cms named Locomotive.
|
5
4
|
|
6
|
-
Requirements
|
7
|
-
=======
|
5
|
+
h2. Requirements
|
8
6
|
|
9
7
|
ActiveSupport 3.0.7, MongoDB 1.6 and Mongoid 2.0.1
|
10
8
|
|
11
9
|
|
12
|
-
Example
|
13
|
-
=======
|
10
|
+
h2. Example
|
14
11
|
|
15
12
|
Coming soon but take a look of the tests to see what CustomFields is capable of.
|
16
13
|
|
17
14
|
|
18
|
-
|
15
|
+
h2. Contact
|
16
|
+
|
17
|
+
Feel free to contact me at didier at nocoffee dot fr.
|
18
|
+
|
19
|
+
Copyright (c) 2011 NoCoffee, released under the MIT license
|
data/lib/custom_fields/field.rb
CHANGED
@@ -26,7 +26,10 @@ module CustomFields
|
|
26
26
|
|
27
27
|
## validations ##
|
28
28
|
validates_presence_of :label, :kind
|
29
|
-
validates_exclusion_of :_alias, :in =>
|
29
|
+
validates_exclusion_of :_alias, :in => Module.new {
|
30
|
+
def self.include?(el); CustomFields.options[:reserved_aliases].include?(el); end
|
31
|
+
}
|
32
|
+
validates_format_of :_alias, :with => /^[a-z]([A-Za-z0-9_]+)?$/
|
30
33
|
validate :uniqueness_of_label_and_alias
|
31
34
|
|
32
35
|
## other accessors ##
|
@@ -133,7 +136,10 @@ module CustomFields
|
|
133
136
|
|
134
137
|
def set_alias
|
135
138
|
return if self.label.blank? && self._alias.blank?
|
136
|
-
|
139
|
+
|
140
|
+
if self._alias.blank?
|
141
|
+
self._alias = self.label.parameterize('_').gsub('-', '_').downcase
|
142
|
+
end
|
137
143
|
end
|
138
144
|
|
139
145
|
def increment_counter!
|
data/lib/custom_fields.rb
CHANGED
@@ -3,6 +3,22 @@ $:.unshift File.expand_path(File.dirname(__FILE__))
|
|
3
3
|
require 'active_support'
|
4
4
|
require 'carrierwave/orm/mongoid'
|
5
5
|
|
6
|
+
module CustomFields
|
7
|
+
|
8
|
+
@@options = {
|
9
|
+
:reserved_aliases => Mongoid.destructive_fields
|
10
|
+
}
|
11
|
+
|
12
|
+
def self.options=(options)
|
13
|
+
@@options.merge!(options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.options
|
17
|
+
@@options
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
6
22
|
require 'custom_fields/version'
|
7
23
|
require 'custom_fields/extensions/mongoid/document'
|
8
24
|
require 'custom_fields/extensions/mongoid/relations/accessors'
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: custom_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 62196377
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 1.0.0.beta.
|
11
|
+
- 13
|
12
|
+
version: 1.0.0.beta.13
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Didier Lafforgue
|
@@ -17,13 +17,11 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-05-
|
20
|
+
date: 2011-05-24 00:00:00 -07:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
24
|
-
|
25
|
-
prerelease: false
|
26
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
27
25
|
none: false
|
28
26
|
requirements:
|
29
27
|
- - ~>
|
@@ -34,12 +32,12 @@ dependencies:
|
|
34
32
|
- 0
|
35
33
|
- 1
|
36
34
|
version: 2.0.1
|
35
|
+
prerelease: false
|
37
36
|
type: :runtime
|
38
|
-
|
37
|
+
requirement: *id001
|
38
|
+
name: mongoid
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
|
-
|
41
|
-
prerelease: false
|
42
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
43
41
|
none: false
|
44
42
|
requirements:
|
45
43
|
- - ">="
|
@@ -50,12 +48,12 @@ dependencies:
|
|
50
48
|
- 0
|
51
49
|
- 7
|
52
50
|
version: 3.0.7
|
51
|
+
prerelease: false
|
53
52
|
type: :runtime
|
54
|
-
|
53
|
+
requirement: *id002
|
54
|
+
name: activesupport
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
|
57
|
-
prerelease: false
|
58
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
59
57
|
none: false
|
60
58
|
requirements:
|
61
59
|
- - ">="
|
@@ -64,8 +62,10 @@ dependencies:
|
|
64
62
|
segments:
|
65
63
|
- 0
|
66
64
|
version: "0"
|
65
|
+
prerelease: false
|
67
66
|
type: :runtime
|
68
|
-
|
67
|
+
requirement: *id003
|
68
|
+
name: locomotive_carrierwave
|
69
69
|
description: Manage custom fields to a mongoid document or a collection. This module is one of the core features we implemented in our custom cms named Locomotive.
|
70
70
|
email:
|
71
71
|
- didier@nocoffee.fr
|
@@ -75,11 +75,11 @@ extensions: []
|
|
75
75
|
|
76
76
|
extra_rdoc_files:
|
77
77
|
- MIT-LICENSE
|
78
|
-
- README
|
78
|
+
- README.textile
|
79
79
|
files:
|
80
80
|
- init.rb
|
81
81
|
- MIT-LICENSE
|
82
|
-
- README
|
82
|
+
- README.textile
|
83
83
|
- lib/custom_fields/custom_fields_for.rb
|
84
84
|
- lib/custom_fields/extensions/mongoid/document.rb
|
85
85
|
- lib/custom_fields/extensions/mongoid/relations/accessors.rb
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
requirements: []
|
134
134
|
|
135
135
|
rubyforge_project: nowarning
|
136
|
-
rubygems_version: 1.
|
136
|
+
rubygems_version: 1.6.2
|
137
137
|
signing_key:
|
138
138
|
specification_version: 3
|
139
139
|
summary: Custom fields extension for Mongoid
|