Module: Treat::Core::DSL
- Included in:
- Builder
- Defined in:
- lib/treat/core/dsl.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
Map all classes in Treat::Entities to a global builder function (entity, word, phrase, punctuation, symbol, list, etc.).
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/treat/core/dsl.rb', line 7 def method_missing(sym,*args,&block) @@entities ||= Treat.core.entities.list @@learning ||= Treat.core.learning.list if @@entities.include?(sym) klass = Treat::Entities.const_get(sym.cc) return klass.build(*args) elsif @@learning.include?(sym) klass = Treat::Learning.const_get(sym.cc) return klass.new(*args) else super(sym,*args,&block) raise "Uncaught method ended up in Treat DSL." end end |
Class Method Details
.included(base) ⇒ Object
Map all classes in Treat::Entities to a global builder function (entity, word, phrase, punctuation, symbol, list, etc.)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/treat/core/dsl.rb', line 6 def self.included(base) def method_missing(sym,*args,&block) @@entities ||= Treat.core.entities.list @@learning ||= Treat.core.learning.list if @@entities.include?(sym) klass = Treat::Entities.const_get(sym.cc) return klass.build(*args) elsif @@learning.include?(sym) klass = Treat::Learning.const_get(sym.cc) return klass.new(*args) else super(sym,*args,&block) raise "Uncaught method ended up in Treat DSL." end end end |