lib/abstractivator/enum.rb in abstractivator-0.0.25 vs lib/abstractivator/enum.rb in abstractivator-0.0.26

- old
+ new

@@ -53,10 +53,14 @@ @class = value.class end end def define_enum(name, *fields) - const_set(name, make_enum(*fields)) + if respond_to?(:const_set) + const_set(name, make_enum(*fields)) + else # top-level + Kernel.send(:const_set, name, make_enum(*fields)) + end end def make_enum(*fields) if fields.size == 1 && fields.first.is_a?(Hash) && fields.first.keys.all?{|f| f.is_a?(Symbol)} fields = fields.first