fabrication 2.13.0 → 2.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fabrication/schematic/definition.rb +25 -16
- data/lib/fabrication/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bf1a185c7e419f212a6191338886551776c72db
|
4
|
+
data.tar.gz: 65cc299c8b6d9e50f1f25ac125bca674b3fb13df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3219c8c9d6349d9cb4e4f4866b1e48dc4d7043f7567bb2127499aa0d4ee217c889983c67a3c2125385e0386bd7ced152caf77016cefadff13b88f2a464fa7820
|
7
|
+
data.tar.gz: 4b855c9506ee8155dfa77fba9c979f5ab1713502f77b51d151a4b56e22d8297b5618e4d5ab6684b8d29aad42abe8982771a95a2d108c4ef0b203ddca6bf30ead
|
@@ -8,18 +8,11 @@ class Fabrication::Schematic::Definition
|
|
8
8
|
Fabrication::Generator::Base
|
9
9
|
]
|
10
10
|
|
11
|
-
attr_accessor :name, :options
|
11
|
+
attr_accessor :name, :options, :block
|
12
12
|
def initialize(name, options={}, &block)
|
13
13
|
self.name = name
|
14
14
|
self.options = options
|
15
|
-
|
16
|
-
if parent
|
17
|
-
merge_result = parent.merge(&block)
|
18
|
-
@attributes = merge_result.attributes
|
19
|
-
@callbacks = merge_result.callbacks
|
20
|
-
else
|
21
|
-
process_block(&block)
|
22
|
-
end
|
15
|
+
self.block = block
|
23
16
|
end
|
24
17
|
|
25
18
|
def process_block(&block)
|
@@ -42,11 +35,13 @@ class Fabrication::Schematic::Definition
|
|
42
35
|
|
43
36
|
attr_writer :attributes
|
44
37
|
def attributes
|
38
|
+
load_body
|
45
39
|
@attributes ||= []
|
46
40
|
end
|
47
41
|
|
48
42
|
attr_writer :callbacks
|
49
43
|
def callbacks
|
44
|
+
load_body
|
50
45
|
@callbacks ||= {}
|
51
46
|
end
|
52
47
|
|
@@ -109,6 +104,15 @@ class Fabrication::Schematic::Definition
|
|
109
104
|
self.attributes = original.attributes.clone
|
110
105
|
end
|
111
106
|
|
107
|
+
def generate_value(name, params)
|
108
|
+
if params[:count]
|
109
|
+
name = Fabrication::Support.singularize(name.to_s)
|
110
|
+
proc { Fabricate.build(params[:fabricator] || name) }
|
111
|
+
else
|
112
|
+
proc { Fabricate(params[:fabricator] || name) }
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
112
116
|
def merge(overrides={}, &block)
|
113
117
|
clone.tap do |definition|
|
114
118
|
definition.process_block(&block)
|
@@ -118,17 +122,22 @@ class Fabrication::Schematic::Definition
|
|
118
122
|
end
|
119
123
|
end
|
120
124
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
+
protected
|
126
|
+
|
127
|
+
def loaded?; !!@loaded end
|
128
|
+
def load_body
|
129
|
+
return if loaded?
|
130
|
+
@loaded = true
|
131
|
+
|
132
|
+
if parent
|
133
|
+
merge_result = parent.merge(&block)
|
134
|
+
@attributes = merge_result.attributes
|
135
|
+
@callbacks = merge_result.callbacks
|
125
136
|
else
|
126
|
-
|
137
|
+
process_block(&block)
|
127
138
|
end
|
128
139
|
end
|
129
140
|
|
130
|
-
protected
|
131
|
-
|
132
141
|
def parent
|
133
142
|
@parent ||= Fabrication.manager[options[:from].to_s] if options[:from]
|
134
143
|
end
|
data/lib/fabrication/version.rb
CHANGED