fixjour 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fixjour/define.rb +21 -0
- metadata +3 -2
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fixjour
|
2
|
+
def self.define(object, options={}, &block)
|
3
|
+
if builder = options[:from]
|
4
|
+
name = builder.is_a?(Symbol) ? builder : Fixjour.send(:name_for, builder)
|
5
|
+
Fixjour.define_builder(builder, :as => object) do |klass, overrides|
|
6
|
+
# klass is NOT to be used in this case
|
7
|
+
instance = send("new_#{name}")
|
8
|
+
instance_exec(instance, &block)
|
9
|
+
overrides.each { |key, val| instance[key] = val }
|
10
|
+
instance
|
11
|
+
end
|
12
|
+
else
|
13
|
+
Fixjour.define_builder(object, options) do |klass, overrides|
|
14
|
+
instance = klass.new
|
15
|
+
instance_exec(instance, &block)
|
16
|
+
overrides.each { |key, val| instance[key] = val }
|
17
|
+
instance
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 0.5.
|
8
|
+
- 1
|
9
|
+
version: 0.5.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Pat Nakajima
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/fixjour/counter.rb
|
70
70
|
- lib/fixjour/definitions.rb
|
71
71
|
- lib/fixjour/deprecation.rb
|
72
|
+
- lib/fixjour/define.rb
|
72
73
|
- lib/fixjour/errors.rb
|
73
74
|
- lib/fixjour/generator.rb
|
74
75
|
- lib/fixjour/merging_proxy.rb
|