-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,12 @@ class InvalidTransition < Error | |
def initialize(machine, from, to) | ||
@from = from | ||
@to = to | ||
@enum_const = machine.base_klass.const_get(machine.enum_const_name) | ||
super("Transition #{from.inspect} => #{to.inspect} not defined in enum_machine #{enum_const.name}") | ||
@enum_const = | ||
begin | ||
machine.base_klass.const_get(machine.enum_const_name) | ||
rescue NameError # rubocop:disable Lint/SuppressedException | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ermolaev
Author
Contributor
|
||
end | ||
super("Transition #{from.inspect} => #{to.inspect} not defined in enum_machine :#{machine.attr_name}") | ||
end | ||
|
||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,13 @@ | |
module EnumMachine | ||
class Machine | ||
|
||
attr_reader :enum_values, :base_klass, :enum_const_name | ||
attr_reader :enum_values, :base_klass, :enum_const_name, :attr_name | ||
|
||
def initialize(enum_values, base_klass = nil, enum_const_name = nil) # rubocop:disable Gp/OptArgParameters | ||
def initialize(enum_values, base_klass = nil, enum_const_name = nil, attr_name = nil) # rubocop:disable Gp/OptArgParameters | ||
@enum_values = enum_values | ||
@base_klass = base_klass | ||
@enum_const_name = enum_const_name | ||
@attr_name = attr_name | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ermolaev
Author
Contributor
|
||
@transitions = {} | ||
@before_transition = {} | ||
@after_transition = {} | ||
|
не понял, что за кейс и почему просто погасили ошибку?