103103
104104A forge builds objects, using attributes hash:
105105``` ruby
106- ObjectForge [ :point ]
106+ ObjectForge .call( :point )
107107 # => #<Point:0x00007f6109dcad40 @id="a", @x=0.17176955469852973, @y=0.3423901951181103>
108108# Positional arguments define used traits:
109109ObjectForge .build(:point , :z )
@@ -112,17 +112,17 @@ ObjectForge.build(:point, :z)
112112ObjectForge .forge(:point , x: 10 )
113113 # => #<Point:0x00007f6109aabf88 @id="c", @x=10, @y=-0.3458802496120402>
114114# Traits and overrides are combined in the given order:
115- ObjectForge [ :point , :z , :invalid , id: " NaN" ]
115+ ObjectForge .call( :point , :z , :invalid , id: " NaN" )
116116 # => #<Point:0x00007f6109b82e48 @id="NaN", @x=0.0, @y=NaN>
117117# A Proc override behaves the same as an attribute definition:
118- ObjectForge [ :point , :z , x: -> { rand (100 ..200 ) + delta }]
118+ ObjectForge .call( :point , :z , x: -> { rand (100 ..200 ) + delta })
119119 # => #<Point:0x00007f6109932418 @id="Z_d", @x=135.0, @y=0.0>
120120# A block can be passed to do something with the created object:
121- ObjectForge [ :point , :z ] { puts " #{ _1 .id} : #{ _1 .x} ,#{ _1 .y} " }
121+ ObjectForge .call( :point , :z ) { puts " #{ _1 .id} : #{ _1 .x} ,#{ _1 .y} " }
122122 # outputs "Z_e: 0.0,0.0"
123123```
124124> [ !TIP]
125- > Forging can be done through any of ` #[] ` , ` #forge ` , or ` #build ` methods, they are aliases.
125+ > Forging can be done through any of ` #call ` , ` #forge ` , or ` #build ` methods, they are aliases.
126126
127127### Separate forgeyards and forges
128128
@@ -140,13 +140,13 @@ end
140140
141141Now, this forgeyard can be used just like the default one:
142142``` ruby
143- forgeyard[ :point , :z , id: " 0" ]
143+ forgeyard.forge( :point , :z , id: " 0" )
144144 # => #<Point:0x00007f6109b719e0 @id="0", @x=0, @y=0>
145145```
146146
147147Note how the forge isn't registered in the default forgeyard:
148148``` ruby
149- ObjectForge [ :point ]
149+ ObjectForge .forge( :point )
150150 # ArgumentError: unknown forge: point
151151```
152152
@@ -159,7 +159,7 @@ forge = ObjectForge::Forge.define(Point) do |f|
159159 f.radius { 0.5 }
160160 f.trait :z do f.radius { 0 } end
161161end
162- forge[ :z , id: " 0" ]
162+ forge.( :z , id: " 0" )
163163 # => #<Point:0x00007f6109b719e0 @id="0", @x=0, @y=0>
164164```
165165
@@ -169,7 +169,7 @@ forge.build
169169 # => #<Point:0x00007f610deae578 @id="a", @x=0.3317733939650964, @y=-0.1363936629550252>
170170forge.forge(:z )
171171 # => #<Point:0x00007f61099f6520 @id="b", @x=0, @y=0>
172- forge[ radius: 500 ]
172+ forge.( radius: 500 )
173173 # => #<Point:0x00007f6109960048 @id="c", @x=-141, @y=109>
174174```
175175
@@ -237,7 +237,7 @@ General:
237237
238238Forge definition:
239239- Class specification for a forge is non-optional, there is no assumption about the class name.
240- - If DSL block declares a block argument, ` self ` context is not changed, so DSL methods can't be called with an implicit receiver.
240+ - If the DSL block declares a block argument, ` self ` context is not changed, and DSL methods can't be called with an implicit receiver.
241241
242242Attributes:
243243- For now, transient attributes have no difference to regular ones, they just aren't set in the final object.
@@ -249,7 +249,7 @@ Traits:
249249- There are no default traits.
250250
251251Sequences:
252- - There is no way to define shared sequences, unless you pass the same object yourself to multiple ` sequence ` calls.
252+ - There is no explicit way to define shared sequences, unless you pass the same object yourself to multiple ` sequence ` calls.
253253- Sequences work with values implementing ` #succ ` , not ` #next ` , expressly prohibiting ` Enumerator ` . This may be relaxed in the future.
254254
255255## Current and planned features (roadmap)
0 commit comments