32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/spectre/mixin.rb', line 32
def run desc, with: []
raise "no mixin with desc '#{desc}' defined" unless @@mixins.key? desc
Spectre::Logging.log_debug "running mixin '#{desc}'"
params = with || {}
if params.empty?
params = {}
end
ctx = MixinContext.new(desc)
if params.is_a? Array
return_val = ctx._execute(*params, &@@mixins[desc])
elsif params.is_a? Hash
return_val = ctx._execute(OpenStruct.new(params), &@@mixins[desc])
else
return_val = ctx._execute(params, &@@mixins[desc])
end
return_val.is_a?(Hash) ? OpenStruct.new(return_val) : return_val
end
|