Module: Xail::DSL
- Defined in:
- lib/xail/config.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/xail/config.rb', line 56
def method_missing(name, *args, &block)
abort "internal error #{name} #{args} #{block}" unless name
filterClass = FilterRegistry::get_filter(name.downcase)
filter_scope(filterClass.new(*args)) do
block.yield if block
end
filter_in_scope << filter
rescue StreamLineStop => stop
raise stop
rescue UnknownFilter => error
abort error.to_s
rescue => error
abort "#{filter_in_scope} will not accept #{name} as subfilter: #{error}"
end
|
Instance Attribute Details
#has_final ⇒ Object
Returns the value of attribute has_final.
39
40
41
|
# File 'lib/xail/config.rb', line 39
def has_final
@has_final
end
|
Instance Method Details
#filter(&block) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/xail/config.rb', line 19
def filter(&block)
filter_in_scope << Class.new(AbstractFilter) do
def streamLine(line)
block(line)
end
end
end
|
#filter_in_scope ⇒ Object
51
52
53
54
|
# File 'lib/xail/config.rb', line 51
def filter_in_scope
@filter_stack ||= [FilterCascade.new]
@filter_stack.last
end
|
#filter_scope(compound) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/xail/config.rb', line 10
def filter_scope(compound)
filter_in_scope << compound
@filter_stack << compound
yield
@filter_stack.pop
end
|
#get_binding ⇒ Object
6
7
8
|
# File 'lib/xail/config.rb', line 6
def get_binding
binding
end
|
#group(name, &filters) ⇒ Object
TODO add support for explicitly listing sources def stream(name, source = null)
source ||= name
end
32
33
34
35
36
37
|
# File 'lib/xail/config.rb', line 32
def group(name, &filters)
filter_scope(FilterComposition.new) {
filters.yield
}
end
|
#rest(&filters) ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/xail/config.rb', line 40
def rest(&filters)
if @has_final
raise "rest may only be specified once"
end
@has_final = true
filter_scope(FilterComposition.new) {
filters.yield
}
end
|