custom_fields 1.0.0.beta.18 → 1.0.0.beta.19
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/lib/custom_fields/types/has_many.rb +12 -7
- data/lib/custom_fields/types/has_one.rb +2 -0
- data/lib/custom_fields/version.rb +1 -1
- metadata +13 -11
@@ -21,14 +21,14 @@ module CustomFields
|
|
21
21
|
|
22
22
|
def #{self.safe_alias}=(ids_or_objects)
|
23
23
|
if @_#{self._name}.nil?
|
24
|
-
@_#{self._name} = ProxyCollection.new('#{self.target.to_s}'
|
24
|
+
@_#{self._name} = ProxyCollection.new('#{self.target.to_s}', ids_or_objects)
|
25
25
|
else
|
26
26
|
@_#{self._name}.update(ids_or_objects)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def #{self.safe_alias}
|
31
|
-
@_#{self._name} ||= ProxyCollection.new('#{self.target.to_s}'
|
31
|
+
@_#{self._name} ||= ProxyCollection.new('#{self.target.to_s}', read_attribute(:#{self._name}))
|
32
32
|
end
|
33
33
|
|
34
34
|
def #{self.safe_alias.singularize}_ids
|
@@ -53,8 +53,11 @@ module CustomFields
|
|
53
53
|
|
54
54
|
attr_accessor :target_klass, :ids, :values
|
55
55
|
|
56
|
-
def initialize(
|
57
|
-
self.target_klass =
|
56
|
+
def initialize(target_klass_name, array = [])
|
57
|
+
self.target_klass = target_klass_name.constantize rescue nil
|
58
|
+
|
59
|
+
array = [] if self.target_klass.nil?
|
60
|
+
|
58
61
|
self.update(array || [])
|
59
62
|
end
|
60
63
|
|
@@ -66,8 +69,8 @@ module CustomFields
|
|
66
69
|
def update(values)
|
67
70
|
values = [] if values.blank?
|
68
71
|
|
69
|
-
self.ids = values.collect { |obj| self.id_for_sure(obj) }
|
70
|
-
self.values = values.collect { |obj| self.object_for_sure(obj) }
|
72
|
+
self.ids = values.collect { |obj| self.id_for_sure(obj) }.compact
|
73
|
+
self.values = values.collect { |obj| self.object_for_sure(obj) }.compact
|
71
74
|
end
|
72
75
|
|
73
76
|
def <<(*args)
|
@@ -80,7 +83,7 @@ module CustomFields
|
|
80
83
|
alias :push :<<
|
81
84
|
|
82
85
|
def size
|
83
|
-
self.
|
86
|
+
self.values.size
|
84
87
|
end
|
85
88
|
|
86
89
|
alias :length :size
|
@@ -105,6 +108,8 @@ module CustomFields
|
|
105
108
|
self.target_klass.find(id_or_object)
|
106
109
|
end
|
107
110
|
end
|
111
|
+
rescue # target_klass does not exist anymore or the target element has been removed since
|
112
|
+
nil
|
108
113
|
end
|
109
114
|
|
110
115
|
end
|
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: 62196389
|
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
|
+
- 19
|
12
|
+
version: 1.0.0.beta.19
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Didier Lafforgue
|
@@ -17,12 +17,10 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-06-
|
20
|
+
date: 2011-06-21 00:00:00 -07:00
|
21
|
+
default_executable:
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
23
|
-
name: mongoid
|
24
|
-
prerelease: false
|
25
|
-
type: :runtime
|
26
24
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
27
25
|
none: false
|
28
26
|
requirements:
|
@@ -34,11 +32,11 @@ dependencies:
|
|
34
32
|
- 0
|
35
33
|
- 2
|
36
34
|
version: 2.0.2
|
37
|
-
requirement: *id001
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: activesupport
|
40
35
|
prerelease: false
|
36
|
+
requirement: *id001
|
41
37
|
type: :runtime
|
38
|
+
name: mongoid
|
39
|
+
- !ruby/object:Gem::Dependency
|
42
40
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
43
41
|
none: false
|
44
42
|
requirements:
|
@@ -50,7 +48,10 @@ dependencies:
|
|
50
48
|
- 0
|
51
49
|
- 7
|
52
50
|
version: 3.0.7
|
51
|
+
prerelease: false
|
53
52
|
requirement: *id002
|
53
|
+
type: :runtime
|
54
|
+
name: activesupport
|
54
55
|
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.
|
55
56
|
email:
|
56
57
|
- didier@nocoffee.fr
|
@@ -87,6 +88,7 @@ files:
|
|
87
88
|
- config/locales/en.yml
|
88
89
|
- config/locales/fr.yml
|
89
90
|
- config/locales/pt-BR.yml
|
91
|
+
has_rdoc: true
|
90
92
|
homepage: http://github.com/locomotivecms/custom_fields
|
91
93
|
licenses: []
|
92
94
|
|
@@ -118,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
120
|
requirements: []
|
119
121
|
|
120
122
|
rubyforge_project: nowarning
|
121
|
-
rubygems_version: 1.
|
123
|
+
rubygems_version: 1.6.2
|
122
124
|
signing_key:
|
123
125
|
specification_version: 3
|
124
126
|
summary: Custom fields extension for Mongoid
|