lib/grumlin/sugar.rb in grumlin-0.4.0 vs lib/grumlin/sugar.rb in grumlin-0.5.0
- old
+ new
@@ -1,35 +1,21 @@
# frozen_string_literal: true
module Grumlin
module Sugar
- # TODO: how to use it in specs?
HELPERS = [
Grumlin::U,
Grumlin::T,
Grumlin::P,
Grumlin::Pop,
Grumlin::Order
].freeze
def self.included(base)
- base.extend ClassMethods
- end
-
- module ClassMethods
- def const_missing(name)
- helper = HELPERS.find { |h| h.const_defined?(name) }
- super if helper.nil?
-
- const_set(name, helper)
+ HELPERS.each do |helper|
+ name = helper.name.split("::").last
+ base.const_set(name, helper)
end
- end
-
- def const_missing(name)
- helper = HELPERS.find { |h| h.const_defined?(name) }
- super if helper.nil?
-
- const_set(name, helper)
end
def __
Grumlin::U
end