lib/snfoil/context.rb in snfoil-context-0.0.4 vs lib/snfoil/context.rb in snfoil-context-1.0.0

- old
+ new

@@ -62,15 +62,15 @@ # rubocop:disable reason: These are builder/mapping methods that are just too complex to simplify without # making them more complex. If anyone has a better way please let me know class_methods do # rubocop:disable Metrics/BlockLength def define_workflow(name) - interval format('setup_%s', name) - interval format('before_%s', name) - interval format('after_%s_success', name) - interval format('after_%s_failure', name) - interval format('after_%s', name) + interval "setup_#{name}" + interval "before_#{name}" + interval "after_#{name}_success" + interval "after_#{name}_failure" + interval "after_#{name}" end def define_action_primary(name, method, block) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength define_method(name) do |*_args, **options| # rubocop:disable Metrics/MethodLength options[:action] ||= name.to_sym @@ -92,13 +92,13 @@ def define_singleton_methods(method_name) singleton_var = "snfoil_#{method_name}_hooks" instance_variable_set("@#{singleton_var}", []) define_singleton_method(singleton_var) { instance_variable_get("@#{singleton_var}") } - define_singleton_method(method_name) do |method = nil, **options, &block| - raise SnFoil::Context::ArgumentError, "\##{method_name} requires either a method name or a block" if method.nil? && block.nil? + define_singleton_method(method_name) do |with: nil, **options, &block| + raise SnFoil::Context::ArgumentError, "\##{method_name} requires either a method name or a block" if with.nil? && block.nil? - instance_variable_get("@#{singleton_var}") << { method: method, + instance_variable_get("@#{singleton_var}") << { method: with, block: block, if: options[:if], unless: options[:unless] } end end