Skip to content

Commit f351ac7

Browse files
committed
Fix enum column prefix/suffix
1 parent 21f132c commit f351ac7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/simple_master/master/column/enum_column.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class EnumColumn < self
1313
def initialize(name, options)
1414
@enum = options[:enum]
1515
@const_name = "ENUM_FOR_#{name.upcase}"
16-
@prefix = "#{name}_" if options[:prefix]
17-
@suffix = "_#{options[:suffix]}" if options[:suffix]
16+
@prefix = "#{options[:prefix] == true ? name : options[:prefix]}_" if options[:prefix]
17+
@suffix = "_#{options[:suffix] == true ? name : options[:suffix]}" if options[:suffix]
1818

1919
super
2020
end
@@ -64,7 +64,7 @@ def #{name}_before_type_cast
6464

6565
enum.each_key do |enum_name|
6666
# Skip generating helpers for names that start with a digit
67-
next if enum_name.match?(/\A\d/)
67+
next if enum_name.match?(/\A\d/) && prefix.nil?
6868
master_class.simple_master_module.class_eval <<-RUBY, __FILE__, __LINE__ + 1
6969
def #{prefix}#{enum_name}#{suffix}?
7070
#{name} == :#{enum_name}

0 commit comments

Comments
 (0)