diff --git a/lib/enum/enum.rb b/lib/enum/enum.rb index e022305..fb6e0a4 100644 --- a/lib/enum/enum.rb +++ b/lib/enum/enum.rb @@ -19,10 +19,14 @@ def enum(columns) columns.each do |column, values| values = values.zip(values.map(&:to_s)).to_h if values.is_a?(Array) values.each do |method, value| - method_definitions << "def #{method}?; #{column} == #{value.inspect}; end" + class_eval <<~METHOD, __FILE__, __LINE__ + 1 + # frozen_string_literal: true + def #{method}? + #{column} == #{value.inspect} + end + METHOD end end - class_eval(method_definitions.uniq.join(";")) end def insert(record)