Module: DSL
- Defined in:
- lib/dsl.rb
Class Method Summary collapse
Instance Method Summary collapse
- #action_stack ⇒ Object
- #domain(*path, &block) ⇒ Object
- #path(method, name, c = nil, &block) ⇒ Object
Class Method Details
.extended(obj) ⇒ Object
142 143 144 145 146 147 148 149 150 151 |
# File 'lib/dsl.rb', line 142 def self.extended obj # add stacks and a context to an extended object. obj.instance_variable_set(:@action_stack, []) obj.instance_variable_set(:@domain_stack, []) obj.instance_variable_set(:@context_stack, [{}]) obj.extend Action obj.extend Annotation obj.extend ExtExpression obj.extend SyntaxSugar end |
.parse(file) ⇒ Object
178 179 180 181 182 183 |
# File 'lib/dsl.rb', line 178 def self.parse(file) obj = Object.new obj.extend DSL obj.instance_eval(open(file){|f|f.read}) obj.action_stack end |
Instance Method Details
#action_stack ⇒ Object
152 153 154 |
# File 'lib/dsl.rb', line 152 def action_stack @action_stack end |
#domain(*path, &block) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/dsl.rb', line 156 def domain(*path , &block) # annotations don't effect over domain clear_annotaion @domain_stack.push *path @context_stack.push(@context_stack.last.clone) block.call @context_stack.pop @domain_stack.pop path.length # annotations don't effect over domain clear_annotaion end |
#path(method, name, c = nil, &block) ⇒ Object
168 169 170 171 172 173 174 175 176 |
# File 'lib/dsl.rb', line 168 def path(method, name, c=nil, &block) = @context_stack.last.clone [:method] = method [:name] = name [:domain] = @domain_stack.clone [:action] = block clear_annotaion # annotations effect only a path. @action_stack.push end |