fabrication 2.5.3 → 2.5.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -19,7 +19,7 @@ class Fabrication::Generator::Base
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def execute_callbacks(callbacks)
|
22
|
-
callbacks.each { |callback| __instance.
|
22
|
+
callbacks.each { |callback| __instance.instance_exec(__instance, __transient_attributes, &callback) } if callbacks
|
23
23
|
end
|
24
24
|
|
25
25
|
def create(attributes=[], callbacks=[])
|
@@ -73,7 +73,7 @@ class Fabrication::Generator::Base
|
|
73
73
|
|
74
74
|
protected
|
75
75
|
|
76
|
-
attr_accessor :__klass, :__instance
|
76
|
+
attr_accessor :__klass, :__instance, :__transient_attributes
|
77
77
|
|
78
78
|
def __attributes
|
79
79
|
@__attributes ||= {}
|
@@ -86,15 +86,12 @@ class Fabrication::Generator::Base
|
|
86
86
|
def post_initialize; end
|
87
87
|
|
88
88
|
def process_attributes(attributes)
|
89
|
+
self.__transient_attributes = Hash.new
|
89
90
|
attributes.each do |attribute|
|
90
|
-
__transient_fields << attribute.name if attribute.transient?
|
91
91
|
__attributes[attribute.name] = attribute.processed_value(__attributes)
|
92
|
+
__transient_attributes[attribute.name] = __attributes[attribute.name] if attribute.transient?
|
92
93
|
end
|
93
|
-
__attributes.reject! { |k|
|
94
|
-
end
|
95
|
-
|
96
|
-
def __transient_fields
|
97
|
-
@__transient_fields ||= []
|
94
|
+
__attributes.reject! { |k| __transient_attributes.keys.include?(k) }
|
98
95
|
end
|
99
96
|
|
100
97
|
end
|
@@ -5,7 +5,11 @@ class Fabrication::Generator::Mongoid < Fabrication::Generator::Base
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def build_instance
|
8
|
-
|
8
|
+
if Gem::Version.new(Mongoid::VERSION) >= Gem::Version.new('2.3.0')
|
9
|
+
self.__instance = __klass.new(__attributes, without_protection: true)
|
10
|
+
else
|
11
|
+
self.__instance = __klass.new(__attributes)
|
12
|
+
end
|
9
13
|
end
|
10
14
|
|
11
15
|
end
|
data/lib/fabrication/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fabrication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.4
|
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-01-
|
12
|
+
date: 2013-01-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|