lib/end_state/transition.rb in end_state-1.0.2 vs lib/end_state/transition.rb in end_state-1.1.0

- old
+ new

@@ -16,11 +16,11 @@ return conclude_failed unless conclude(params) true end def allowed?(params={}) - raise "Missing params: #{missing_params(params).join(',')}" unless missing_params(params).empty? + return params_not_provided(missing_params(params)) unless missing_params(params).empty? guards.all? { |guard| guard.new(object, state, params).allowed? } end def will_allow?(params={}) return false unless missing_params(params).empty? @@ -38,9 +38,13 @@ failed GuardFailed, 'blocked' end def conclude_failed failed ConcluderFailed, 'rolled back' + end + + def params_not_provided(params_list) + fail MissingParams, "Missing params: #{params_list.join(',')}" end def conclude(params={}) concluders.each_with_object([]) do |concluder, concluded| concluded << concluder