lib/runger_actions/base.rb in runger_actions-0.19.2 vs lib/runger_actions/base.rb in runger_actions-0.20.0
- old
+ new
@@ -37,11 +37,11 @@
@params[param_name]
end
end
def register_validator_klass(param_name, param_klass, blk)
- validator_klass = const_set("#{param_name.to_s.camelize}Validator", Class.new)
+ validator_klass = const_set(:"#{param_name.to_s.camelize}Validator", Class.new)
validator_klass.include(ActiveModel::Model)
validator_klass.attr_accessor(*param_klass.column_names)
validator_klass.class_eval(&blk)
validators[param_name] = validator_klass
end
@@ -52,11 +52,11 @@
result_klass.class_eval do
define_method(param_name) do
@return_values[param_name]
end
- define_method("#{param_name}=") do |value|
+ define_method(:"#{param_name}=") do |value|
if locked?
raise(RungerActions::MutatingLockedResult, <<~ERROR.squish)
You are attempting to assign a value to an instance of #{self.class} outside of the
#{self.class.module_parent}#execute method. This is not allowed; you may only assign
values to the `result` within the #execute method.
@@ -75,22 +75,22 @@
end
end
def fails_with(error_type)
result_klass.class_eval do
- define_method("#{error_type}!") do |error_message = nil|
+ define_method(:"#{error_type}!") do |error_message = nil|
@failure = error_type
@error_message = error_message
if @action.raise_on_failure?
raise(
RungerActions::RuntimeFailure,
"#{@action.class.name} action failed with `#{error_type}`",
)
end
end
- define_method("#{error_type}?") do
+ define_method(:"#{error_type}?") do
@failure == error_type
end
end
end
@@ -174,13 +174,14 @@
missing_return_values.map do |missing_return_value|
expected_shape = self.class.promised_values[missing_return_value]
"`#{missing_return_value}` (should be shaped like #{expected_shape})"
end
- raise(RungerActions::MissingResultValue, <<~ERROR.squish)
- #{self.class.name} failed to set all promised return values on its `result`. The
- following were missing on the `result`: #{violation_messages.join(', ')}.
- ERROR
+ raise(
+ RungerActions::MissingResultValue,
+ "#{self.class.name} failed to set all promised return values on its `result`. The " \
+ "following were missing on the `result`: #{violation_messages.join(', ')}.",
+ )
end
end
def run_custom_validations
self.class.required_params.each_key do |param_name|