Skip to content

Commit ca83014

Browse files
nitishrfloehopper
authored andcommitted
DRY up by subclassing State from StatePredicate
1 parent e3be26c commit ca83014

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

lib/mocha/state_machine.rb

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,11 @@ def mocha_inspect
2424
end
2525

2626
# Provides a mechanism to change the state of a {StateMachine} at some point in the future.
27-
class State
28-
# @private
29-
def initialize(state_machine, state, description, &active_check)
30-
@state_machine = state_machine
31-
@state = state
32-
@description = description
33-
@active_check = active_check
34-
end
35-
27+
class State < StatePredicate
3628
# @private
3729
def activate
3830
@state_machine.current_state = @state
3931
end
40-
41-
# @private
42-
def active?
43-
@active_check.call(@state_machine.current_state, @state)
44-
end
45-
46-
# @private
47-
def mocha_inspect
48-
"#{@state_machine.name} #{@description} #{@state.mocha_inspect}"
49-
end
5032
end
5133

5234
# @private

0 commit comments

Comments
 (0)