6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/conject/object_factory.rb', line 6
def construct_new(name, object_context)
object = nil
config = object_context.get_object_config(name)
lambda_constructor = config[:construct]
alias_for = config[:is]
if alias_for
begin
object = object_context.get(alias_for)
rescue Exception => ex
raise "(When attempting to fill alias '#{name}' with actual object '#{alias_for}') #{ex.message}"
end
elsif lambda_constructor
case lambda_constructor.arity
when 0
object = lambda_constructor[]
when 1
object = lambda_constructor[object_context]
when 2
object = lambda_constructor[name, object_context]
else
raise "Constructor lambda takes 0, 1 or 2 params; this lambda takes #{lambda_constructor.arity}"
end
else
object = type_1_constructor(name, object_context)
end
object.__send__(:instance_variable_set, :@_conject_object_context, object_context)
return object
end
|