lib/enum_help/i18n.rb in enum_help-0.0.17 vs lib/enum_help/i18n.rb in enum_help-0.0.18
- old
+ new
@@ -1,14 +1,28 @@
module EnumHelp
module I18n
- # overwrite the enum method
- def enum( definitions )
- super( definitions )
- definitions.each do |name, _|
- Helper.define_attr_i18n_method(self, name)
- Helper.define_collection_i18n_method(self, name)
+ if ActiveRecord::VERSION::MAJOR == 7
+ # overwrite the enum method
+ def enum(name = nil, values = nil, **options)
+ super(name, values, **options)
+
+ definitions = options.slice!(:_prefix, :_suffix, :_scopes, :_default)
+ definitions.each do |name, _|
+ Helper.define_attr_i18n_method(self, name)
+ Helper.define_collection_i18n_method(self, name)
+ end
+ end
+ end
+ if ActiveRecord::VERSION::MAJOR < 7
+ # overwrite the enum method
+ def enum( definitions )
+ super( definitions )
+ definitions.each do |name, _|
+ Helper.define_attr_i18n_method(self, name)
+ Helper.define_collection_i18n_method(self, name)
+ end
end
end
def self.extended(receiver)
# receiver.class_eval do