module SnFoil::Contexts::ChangeContext

Public Instance Methods

after_change(method = nil, **options, &block) click to toggle source
# File lib/sn_foil/contexts/change_context.rb, line 36
def after_change(method = nil, **options, &block)
  raise ArgumentError, '#after_change requires either a method name or a block' if method.nil? && block.nil?

  (@i_after_change_hooks ||= []) << { method: method, block: block, if: options[:if], unless: options[:unless] }
end
after_change_failure(method = nil, **options, &block) click to toggle source
# File lib/sn_foil/contexts/change_context.rb, line 48
def after_change_failure(method = nil, **options, &block)
  raise ArgumentError, '#after_change_failure requires either a method name or a block' if method.nil? && block.nil?

  (@i_after_change_failure_hooks ||= []) << { method: method, block: block, if: options[:if], unless: options[:unless] }
end
after_change_failure_hooks() click to toggle source
# File lib/sn_foil/contexts/change_context.rb, line 96
def after_change_failure_hooks
  self.class.i_after_change_failure_hooks || []
end
after_change_hooks() click to toggle source
# File lib/sn_foil/contexts/change_context.rb, line 88
def after_change_hooks
  self.class.i_after_change_hooks || []
end
after_change_success(method = nil, **options, &block) click to toggle source
# File lib/sn_foil/contexts/change_context.rb, line 42
def after_change_success(method = nil, **options, &block)
  raise ArgumentError, '#after_change_success requires either a method name or a block' if method.nil? && block.nil?

  (@i_after_change_success_hooks ||= []) << { method: method, block: block, if: options[:if], unless: options[:unless] }
end
after_change_success_hooks() click to toggle source
# File lib/sn_foil/contexts/change_context.rb, line 92
def after_change_success_hooks
  self.class.i_after_change_success_hooks || []
end
before_change(method = nil, **options, &block) click to toggle source
# File lib/sn_foil/contexts/change_context.rb, line 30
def before_change(method = nil, **options, &block)
  raise ArgumentError, '#before_change requires either a method name or a block' if method.nil? && block.nil?

  (@i_before_change_hooks ||= []) << { method: method, block: block, if: options[:if], unless: options[:unless] }
end
before_change_hooks() click to toggle source
# File lib/sn_foil/contexts/change_context.rb, line 84
def before_change_hooks
  self.class.i_before_change_hooks || []
end
param_names() click to toggle source
# File lib/sn_foil/contexts/change_context.rb, line 55
def param_names
  @param_names ||= self.class.i_params
end
params(*permitted_params) click to toggle source
# File lib/sn_foil/contexts/change_context.rb, line 19
def params(*permitted_params)
  @i_params ||= []
  @i_params |= permitted_params
end
setup_change(method = nil, **options, &block) click to toggle source
# File lib/sn_foil/contexts/change_context.rb, line 24
def setup_change(method = nil, **options, &block)
  raise ArgumentError, '#setup_change requires either a method name or a block' if method.nil? && block.nil?

  (@i_setup_change_hooks ||= []) << { method: method, block: block, if: options[:if], unless: options[:unless] }
end
setup_change_hooks() click to toggle source
# File lib/sn_foil/contexts/change_context.rb, line 80
def setup_change_hooks
  self.class.i_setup_change_hooks || []
end