lib/danica/dsl.rb in danica-2.7.1 vs lib/danica/dsl.rb in danica-2.7.2
- old
+ new
@@ -1,19 +1,23 @@
module Danica
module DSL
+ autoload :Builder, 'danica/dsl/builder'
+
class << self
def register_operator(method, clazz=nil)
register(method, clazz, 'Danica::Operator')
end
def register_wrapper(method, clazz=nil)
register(method, clazz, 'Danica::Wrapper')
end
def register(method, clazz=nil, base=nil)
- define_method method do |*args|
- clazz = [base.to_s, method.to_s.camelize].compact.join('::').constantize unless clazz
- clazz = [base, clazz.to_s].compact.join('::').constantize unless clazz.is_a? Class
+ Builder.new(method, clazz, base).build
+ end
+
+ def register_class(method, clazz)
+ define_method(method) do |*args|
clazz.new(*args)
end
end
def build(&block)