The purpose of the enhancement is to allow the .enum class_method to have a sole option.
Defining a sole leads to modify scopes and instance_methods.
It could be done like that:
enum :role, [:base, :default, :fallback, :lower_cost], sole: { except: :base }
The sole option:
- is false by default
- can accept a boolean → leads to modify all
scopesandinstance_methods - can accept a hash with
onlyandexceptkeys which themselves accept a value or an array of values → leads to modify allscopesandinstance_methodsfor/excluding the value(s) of the sole hash value
Then in ActiveRecord::Enum there will be define_sole_enum_methods:
scopesthat use the.find_sole_by#value!instance_methodthat first update the old sole object and assign the new sole object to self#value?instance_methodthat verify if the object (self) is the sole one
And in _enum class_method use define_enum_methods or define_sole_enum_methods depending of the sole option for each values.