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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63f6c7600246d2a616c443cfe4f1f40d97dfdfc7
4
- data.tar.gz: df342015cfb8dd239fa9fbab926772d4ba06f023
3
+ metadata.gz: 3bf1a185c7e419f212a6191338886551776c72db
4
+ data.tar.gz: 65cc299c8b6d9e50f1f25ac125bca674b3fb13df
5
5
  SHA512:
6
- metadata.gz: d1913a5783bbfc4989a912f3483612fa9dea69548c02a08bc365576395eec0ce64713f5104afea0cceeafa9fa1a1ca00f95676e35a85005da628943dbf8b9e9d
7
- data.tar.gz: dfff237fd6789080b8713f12e2ace38d273cc7e3191e35b40b6b16995836fd9c2ae54e35bb1389cbc2b69ec62e38d8d5127e83a650f66cf145c4211e02ab6eac
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
- def generate_value(name, params)
122
- if params[:count]
123
- name = Fabrication::Support.singularize(name.to_s)
124
- proc { Fabricate.build(params[:fabricator] || name) }
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
- proc { Fabricate(params[:fabricator] || name) }
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
@@ -1,3 +1,3 @@
1
1
  module Fabrication
2
- VERSION = '2.13.0'
2
+ VERSION = '2.13.1'
3
3
  end
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.13.0
4
+ version: 2.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Elliott