Class: RailsExecution::AppModel

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_execution/app_model.rb

Direct Known Subclasses

Activity, Comment, Label, Task, TaskLabel, TaskReview

Class Method Summary collapse

Class Method Details

.compat_enum(column, values, **options) ⇒ Object

Supports both old (< Rails 7.0) and new (>= Rails 7.0) enum syntax.



15
16
17
18
19
20
21
22
# File 'lib/rails_execution/app_model.rb', line 15

def self.compat_enum(column, values, **options)
  if ActiveRecord::VERSION::MAJOR >= 7
    enum column, values, **options
  else
    legacy_options = options.transform_keys { |key| :"_#{key}" }
    enum({ column => values }.merge(legacy_options))
  end
end