Class: Alki::Dsl::Base
- Inherits:
-
Object
show all
- Extended by:
- Builder
- Defined in:
- lib/alki/dsl/base.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Builder
build
Constructor Details
#initialize(ctx, evaluator) ⇒ Base
Returns a new instance of Base.
50
51
52
53
|
# File 'lib/alki/dsl/base.rb', line 50
def initialize(ctx,evaluator)
@ctx = ctx
@evaluator = evaluator
end
|
Instance Attribute Details
#ctx ⇒ Object
Returns the value of attribute ctx.
55
56
57
|
# File 'lib/alki/dsl/base.rb', line 55
def ctx
@ctx
end
|
Class Method Details
.dsl_info ⇒ Object
42
43
44
|
# File 'lib/alki/dsl/base.rb', line 42
def self.dsl_info
{}
end
|
.generate(evaluator, ctx) ⇒ Object
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
37
38
39
40
|
# File 'lib/alki/dsl/base.rb', line 9
def self.generate(evaluator,ctx)
obj = new(ctx,evaluator)
result = {methods: {}}
info = self.dsl_info
result[:init] = obj.method(info[:init]) if info[:init]
result[:finish] = obj.method(info[:finish]) if info[:finish]
result[:requires] = info[:requires] if info[:requires]
if info[:methods]
info[:methods].each do |method|
if method.is_a?(Array)
name, method = method
else
name = method
end
result[:methods][name] = obj.method method
end
end
if info[:helpers]
info[:helpers].each do |method|
if method.is_a?(Array)
name, method = method
else
name = method
end
result[:helpers][name] = obj.method method
end
end
evaluator.update result
end
|
.helpers ⇒ Object
46
47
48
|
# File 'lib/alki/dsl/base.rb', line 46
def self.helpers
[]
end
|