Skip to content

Instantly share code, notes, and snippets.

@yhirano55
Created June 5, 2019 01:56
Show Gist options
  • Save yhirano55/918211308c95f8189d41e8d5d2b93c53 to your computer and use it in GitHub Desktop.
Save yhirano55/918211308c95f8189d41e8d5d2b93c53 to your computer and use it in GitHub Desktop.

Generated by trace_location at 2019-06-05 10:56:45 +0900

activemodel-5.2.3/lib/active_model/secure_password.rb:55
ActiveModel::SecurePassword::ClassMethods#has_secure_password
def has_secure_password(options = {})
  # Load bcrypt gem only when has_secure_password is used.
  # This is to avoid ActiveModel (and by extension the entire framework)
  # being dependent on a binary library.
  begin
    require "bcrypt"
  rescue LoadError
    $stderr.puts "You don't have bcrypt installed in your application. Please add it to your Gemfile and run bundle install"
    raise
  end

  include InstanceMethodsOnActivation

  if options.fetch(:validations, true)
    include ActiveModel::Validations

    # This ensures the model has a password by checking whether the password_digest
    # is present, so that this works with both new and existing records. However,
    # when there is an error, the message is added to the password attribute instead
    # so that the error message will make sense to the end-user.
    validate do |record|
      record.errors.add(:password, :blank) unless record.password_digest.present?
    end

    validates_length_of :password, maximum: ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED
    validates_confirmation_of :password, allow_blank: true
  end
end
# called from /Users/yhirano/dev/src/github.com/yhirano55/testcode_app/app/models/user.rb:3
activesupport-5.2.3/lib/active_support/dependencies.rb:289
ActiveSupport::Dependencies::Loadable#require
def require(file)
  result = false
  load_dependency(file) { result = super }
  result
end
# called from activemodel-5.2.3/lib/active_model/secure_password.rb:60
activesupport-5.2.3/lib/active_support/dependencies.rb:251
ActiveSupport::Dependencies::Loadable#load_dependency
def load_dependency(file)
  if Dependencies.load? && Dependencies.constant_watch_stack.watching?
    descs = Dependencies.constant_watch_stack.watching.flatten.uniq

    Dependencies.new_constants_in(*descs) { yield }
  else
    yield
  end
rescue Exception => exception  # errors from loading file
  exception.blame_file! file if exception.respond_to? :blame_file!
  raise
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:291
activesupport-5.2.3/lib/active_support/dependencies.rb:328
ActiveSupport::Dependencies#load?
def load?
  mechanism == :load
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:252
activesupport-5.2.3/lib/active_support/core_ext/module/attribute_accessors.rb:60
ActiveSupport::Dependencies.mechanism
def self.#{sym}
  @@#{sym}
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:329
activesupport-5.2.3/lib/active_support/core_ext/module/attribute_accessors.rb:60
ActiveSupport::Dependencies.constant_watch_stack
def self.#{sym}
  @@#{sym}
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:252
activesupport-5.2.3/lib/active_support/dependencies.rb:111
ActiveSupport::Dependencies::WatchStack#watching?
def watching?
  !@watching.empty?
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:252
activesupport-5.2.3/lib/active_support/core_ext/module/attribute_accessors.rb:60
ActiveSupport::Dependencies.constant_watch_stack
def self.#{sym}
  @@#{sym}
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:253
activesupport-5.2.3/lib/active_support/dependencies.rb:656
ActiveSupport::Dependencies#new_constants_in
def new_constants_in(*descs)
  constant_watch_stack.watch_namespaces(descs)
  success = false

  begin
    yield # Now yield to the code that is to define new constants.
    success = true
  ensure
    new_constants = constant_watch_stack.new_constants

    return new_constants if success

    # Remove partially loaded constants.
    new_constants.each { |c| remove_constant(c) }
  end
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:255
activesupport-5.2.3/lib/active_support/core_ext/module/attribute_accessors.rb:60
ActiveSupport::Dependencies.constant_watch_stack
def self.#{sym}
  @@#{sym}
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:657
activesupport-5.2.3/lib/active_support/dependencies.rb:154
ActiveSupport::Dependencies::WatchStack#watch_namespaces
def watch_namespaces(namespaces)
  @watching << namespaces.map do |namespace|
    module_name = Dependencies.to_constant_name(namespace)
    original_constants = Dependencies.qualified_const_defined?(module_name) ?
      Inflector.constantize(module_name).constants(false) : []

    @stack[module_name] << original_constants
    module_name
  end
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:657
activesupport-5.2.3/lib/active_support/dependencies.rb:675
ActiveSupport::Dependencies#to_constant_name
def to_constant_name(desc) #:nodoc:
  case desc
  when String then desc.sub(/^::/, "")
  when Symbol then desc.to_s
  when Module
    desc.name ||
      raise(ArgumentError, "Anonymous modules have no name to be referenced by")
  else raise TypeError, "Not a valid constant descriptor: #{desc.inspect}"
  end
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:156
activesupport-5.2.3/lib/active_support/dependencies.rb:394
ActiveSupport::Dependencies#qualified_const_defined?
def qualified_const_defined?(path)
  Object.const_defined?(path, false)
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:157
activesupport-5.2.3/lib/active_support/inflector/methods.rb:272
ActiveSupport::Inflector#constantize
def constantize(camel_cased_word)
  names = camel_cased_word.split("::".freeze)

  # Trigger a built-in NameError exception including the ill-formed constant in the message.
  Object.const_get(camel_cased_word) if names.empty?

  # Remove the first blank element in case of '::ClassName' notation.
  names.shift if names.size > 1 && names.first.empty?

  names.inject(Object) do |constant, name|
    if constant == Object
      constant.const_get(name)
    else
      candidate = constant.const_get(name)
      next candidate if constant.const_defined?(name, false)
      next candidate unless Object.const_defined?(name)

      # Go down the ancestors to check if it is owned directly. The check
      # stops when we reach Object or the end of ancestors tree.
      constant = constant.ancestors.inject(constant) do |const, ancestor|
        break const    if ancestor == Object
        break ancestor if ancestor.const_defined?(name, false)
        const
      end

      # owner is in Object, so raise
      constant.const_get(name, false)
    end
  end
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:158
activesupport-5.2.3/lib/active_support/core_ext/module/attribute_accessors.rb:60
ActiveSupport::Dependencies.constant_watch_stack
def self.#{sym}
  @@#{sym}
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:664
activesupport-5.2.3/lib/active_support/dependencies.rb:117
ActiveSupport::Dependencies::WatchStack#new_constants
def new_constants
  constants = []

  # Grab the list of namespaces that we're looking for new constants under
  @watching.last.each do |namespace|
    # Retrieve the constants that were present under the namespace when watch_namespaces
    # was originally called
    original_constants = @stack[namespace].last

    mod = Inflector.constantize(namespace) if Dependencies.qualified_const_defined?(namespace)
    next unless mod.is_a?(Module)

    # Get a list of the constants that were added
    new_constants = mod.constants(false) - original_constants

    # @stack[namespace] returns an Array of the constants that are being evaluated
    # for that namespace. For instance, if parent.rb requires child.rb, the first
    # element of @stack[Object] will be an Array of the constants that were present
    # before parent.rb was required. The second element will be an Array of the
    # constants that were present before child.rb was required.
    @stack[namespace].each do |namespace_constants|
      namespace_constants.concat(new_constants)
    end

    # Normalize the list of new constants, and add them to the list we will return
    new_constants.each do |suffix|
      constants << ([namespace, suffix] - ["Object"]).join("::".freeze)
    end
  end
  constants
ensure
  # A call to new_constants is always called after a call to watch_namespaces
  pop_modules(@watching.pop)
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:664
activesupport-5.2.3/lib/active_support/dependencies.rb:394
ActiveSupport::Dependencies#qualified_const_defined?
def qualified_const_defined?(path)
  Object.const_defined?(path, false)
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:126
activesupport-5.2.3/lib/active_support/inflector/methods.rb:272
ActiveSupport::Inflector#constantize
def constantize(camel_cased_word)
  names = camel_cased_word.split("::".freeze)

  # Trigger a built-in NameError exception including the ill-formed constant in the message.
  Object.const_get(camel_cased_word) if names.empty?

  # Remove the first blank element in case of '::ClassName' notation.
  names.shift if names.size > 1 && names.first.empty?

  names.inject(Object) do |constant, name|
    if constant == Object
      constant.const_get(name)
    else
      candidate = constant.const_get(name)
      next candidate if constant.const_defined?(name, false)
      next candidate unless Object.const_defined?(name)

      # Go down the ancestors to check if it is owned directly. The check
      # stops when we reach Object or the end of ancestors tree.
      constant = constant.ancestors.inject(constant) do |const, ancestor|
        break const    if ancestor == Object
        break ancestor if ancestor.const_defined?(name, false)
        const
      end

      # owner is in Object, so raise
      constant.const_get(name, false)
    end
  end
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:126
activesupport-5.2.3/lib/active_support/dependencies.rb:166
ActiveSupport::Dependencies::WatchStack#pop_modules
def pop_modules(modules)
  modules.each { |mod| @stack[mod].pop }
end
# called from activesupport-5.2.3/lib/active_support/dependencies.rb:149
activesupport-5.2.3/lib/active_support/concern.rb:113
ActiveSupport::Concern#append_features
def append_features(base)
  if base.instance_variable_defined?(:@_dependencies)
    base.instance_variable_get(:@_dependencies) << self
    false
  else
    return false if base < self
    @_dependencies.each { |dep| base.include(dep) }
    super
    base.extend const_get(:ClassMethods) if const_defined?(:ClassMethods)
    base.class_eval(&@_included_block) if instance_variable_defined?(:@_included_block)
  end
end
# called from activemodel-5.2.3/lib/active_model/secure_password.rb:69
activesupport-5.2.3/lib/active_support/concern.rb:126
ActiveSupport::Concern#included
def included(base = nil, &block)
  if base.nil?
    if instance_variable_defined?(:@_included_block)
      if @_included_block.source_location != block.source_location
        raise MultipleIncludedBlocks
      end
    else
      @_included_block = block
    end
  else
    super
  end
end
# called from activemodel-5.2.3/lib/active_model/secure_password.rb:69
activemodel-5.2.3/lib/active_model/validations.rb:154
ActiveModel::Validations::ClassMethods#validate
def validate(*args, &block)
  options = args.extract_options!

  if args.all? { |arg| arg.is_a?(Symbol) }
    options.each_key do |k|
      unless VALID_OPTIONS_FOR_VALIDATE.include?(k)
        raise ArgumentError.new("Unknown key: #{k.inspect}. Valid keys are: #{VALID_OPTIONS_FOR_VALIDATE.map(&:inspect).join(', ')}. Perhaps you meant to call `validates` instead of `validate`?")
      end
    end
  end

  if options.key?(:on)
    options = options.dup
    options[:on] = Array(options[:on])
    options[:if] = Array(options[:if])
    options[:if].unshift ->(o) {
      !(options[:on] & Array(o.validation_context)).empty?
    }
  end

  set_callback(:validate, *args, options, &block)
end
# called from activemodel-5.2.3/lib/active_model/secure_password.rb:75
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:24
Array#extract_options!
def extract_options!
  if last.is_a?(Hash) && last.extractable_options?
    pop
  else
    {}
  end
end
# called from activemodel-5.2.3/lib/active_model/validations.rb:155
activesupport-5.2.3/lib/active_support/callbacks.rb:667
ActiveSupport::Callbacks::ClassMethods#set_callback
def set_callback(name, *filter_list, &block)
  type, filters, options = normalize_callback_params(filter_list, block)

  self_chain = get_callbacks name
  mapped = filters.map do |filter|
    Callback.build(self_chain, filter, type, options)
  end

  __update_callbacks(name) do |target, chain|
    options[:prepend] ? chain.prepend(*mapped) : chain.append(*mapped)
    target.set_callbacks name, chain
  end
end
# called from activemodel-5.2.3/lib/active_model/validations.rb:174
activesupport-5.2.3/lib/active_support/callbacks.rb:615
ActiveSupport::Callbacks::ClassMethods#normalize_callback_params
def normalize_callback_params(filters, block) # :nodoc:
  type = CALLBACK_FILTER_TYPES.include?(filters.first) ? filters.shift : :before
  options = filters.extract_options!
  filters.unshift(block) if block
  [type, filters, options.dup]
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:668
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:24
Array#extract_options!
def extract_options!
  if last.is_a?(Hash) && last.extractable_options?
    pop
  else
    {}
  end
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:617
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:9
Hash#extractable_options?
def extractable_options?
  instance_of?(Hash)
end
# called from activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:25
activesupport-5.2.3/lib/active_support/callbacks.rb:836
ActiveSupport::Callbacks::ClassMethods#get_callbacks
def get_callbacks(name) # :nodoc:
  __callbacks[name.to_sym]
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:670
activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:106
ActiveRecord::Base.__callbacks
redefine_method(name) { val }
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:837
activesupport-5.2.3/lib/active_support/callbacks.rb:281
ActiveSupport::Callbacks::Callback.build
def self.build(chain, filter, kind, options)
  if filter.is_a?(String)
    raise ArgumentError, <<-MSG.squish
      Passing string to define a callback is not supported. See the `.set_callback`
      documentation to see supported values.
    MSG
  end

  new chain.name, filter, kind, options, chain.config
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:672
activesupport-5.2.3/lib/active_support/callbacks.rb:295
ActiveSupport::Callbacks::Callback#initialize
def initialize(name, filter, kind, options, chain_config)
  @chain_config = chain_config
  @name    = name
  @kind    = kind
  @filter  = filter
  @key     = compute_identifier filter
  @if      = check_conditionals(Array(options[:if]))
  @unless  = check_conditionals(Array(options[:unless]))
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:289
activesupport-5.2.3/lib/active_support/callbacks.rb:365
ActiveSupport::Callbacks::Callback#compute_identifier
def compute_identifier(filter)
  case filter
  when ::Proc
    filter.object_id
  else
    filter
  end
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:300
activesupport-5.2.3/lib/active_support/callbacks.rb:353
ActiveSupport::Callbacks::Callback#check_conditionals
def check_conditionals(conditionals)
  if conditionals.any? { |c| c.is_a?(String) }
    raise ArgumentError, <<-MSG.squish
      Passing string to be evaluated in :if and :unless conditional
      options is not supported. Pass a symbol for an instance method,
      or a lambda, proc or block, instead.
    MSG
  end

  conditionals
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:301
activesupport-5.2.3/lib/active_support/callbacks.rb:353
ActiveSupport::Callbacks::Callback#check_conditionals
def check_conditionals(conditionals)
  if conditionals.any? { |c| c.is_a?(String) }
    raise ArgumentError, <<-MSG.squish
      Passing string to be evaluated in :if and :unless conditional
      options is not supported. Pass a symbol for an instance method,
      or a lambda, proc or block, instead.
    MSG
  end

  conditionals
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:302
activesupport-5.2.3/lib/active_support/callbacks.rb:624
ActiveSupport::Callbacks::ClassMethods#__update_callbacks
def __update_callbacks(name) #:nodoc:
  ([self] + ActiveSupport::DescendantsTracker.descendants(self)).reverse_each do |target|
    chain = target.get_callbacks name
    yield target, chain.dup
  end
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:675
activesupport-5.2.3/lib/active_support/descendants_tracker.rb:14
ActiveSupport::DescendantsTracker.descendants
def descendants(klass)
  arr = []
  accumulate_descendants(klass, arr)
  arr
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:625
activesupport-5.2.3/lib/active_support/descendants_tracker.rb:41
ActiveSupport::DescendantsTracker.accumulate_descendants
def accumulate_descendants(klass, acc)
  if direct_descendants = @@direct_descendants[klass]
    acc.concat(direct_descendants)
    direct_descendants.each { |direct_descendant| accumulate_descendants(direct_descendant, acc) }
  end
end
# called from activesupport-5.2.3/lib/active_support/descendants_tracker.rb:16
activesupport-5.2.3/lib/active_support/callbacks.rb:836
ActiveSupport::Callbacks::ClassMethods#get_callbacks
def get_callbacks(name) # :nodoc:
  __callbacks[name.to_sym]
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:626
activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:106
ActiveRecord::Base.__callbacks
redefine_method(name) { val }
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:837
activesupport-5.2.3/lib/active_support/callbacks.rb:557
ActiveSupport::Callbacks::CallbackChain#initialize_copy
def initialize_copy(other)
  @callbacks = nil
  @chain     = other.chain.dup
  @mutex     = Mutex.new
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:627
activesupport-5.2.3/lib/active_support/callbacks.rb:581
ActiveSupport::Callbacks::CallbackChain#chain
def chain; @chain; end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:559
activesupport-5.2.3/lib/active_support/callbacks.rb:572
ActiveSupport::Callbacks::CallbackChain#append
def append(*callbacks)
  callbacks.each { |c| append_one(c) }
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:676
activesupport-5.2.3/lib/active_support/callbacks.rb:585
ActiveSupport::Callbacks::CallbackChain#append_one
def append_one(callback)
  @callbacks = nil
  remove_duplicates(callback)
  @chain.push(callback)
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:573
activesupport-5.2.3/lib/active_support/callbacks.rb:597
ActiveSupport::Callbacks::CallbackChain#remove_duplicates
def remove_duplicates(callback)
  @callbacks = nil
  @chain.delete_if { |c| callback.duplicates?(c) }
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:587
activesupport-5.2.3/lib/active_support/callbacks.rb:840
ActiveSupport::Callbacks::ClassMethods#set_callbacks
def set_callbacks(name, callbacks) # :nodoc:
  self.__callbacks = __callbacks.merge(name.to_sym => callbacks)
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:677
activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:106
ActiveRecord::Base.__callbacks
redefine_method(name) { val }
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:841
activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:104
ActiveRecord::Base.__callbacks=
define_singleton_method("#{name}=") do |val|
  singleton_class.class_eval do
    redefine_method(name) { val }
  end

  if singleton_class?
    class_eval do
      redefine_method(name) do
        if instance_variable_defined? ivar
          instance_variable_get ivar
        else
          singleton_class.send name
        end
      end
    end
  end
  val
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:841
activesupport-5.2.3/lib/active_support/core_ext/module/redefine_method.rb:26
Module#redefine_method
def redefine_method(method, &block)
  visibility = method_visibility(method)
  silence_redefinition_of_method(method)
  define_method(method, &block)
  send(visibility, method)
end
# called from activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:106
activesupport-5.2.3/lib/active_support/core_ext/module/redefine_method.rb:39
Module#method_visibility
def method_visibility(method) # :nodoc:
  case
  when private_method_defined?(method)
    :private
  when protected_method_defined?(method)
    :protected
  else
    :public
  end
end
# called from activesupport-5.2.3/lib/active_support/core_ext/module/redefine_method.rb:27
activesupport-5.2.3/lib/active_support/core_ext/module/redefine_method.rb:8
Module#silence_redefinition_of_method
def silence_redefinition_of_method(method)
  if method_defined?(method) || private_method_defined?(method)
    # This suppresses the "method redefined" warning; the self-alias
    # looks odd, but means we don't need to generate a unique name
    alias_method method, method
  end
end
# called from activesupport-5.2.3/lib/active_support/core_ext/module/redefine_method.rb:28
activerecord-5.2.3/lib/active_record/validations/length.rb:19
ActiveRecord::Validations::ClassMethods#validates_length_of
def validates_length_of(*attr_names)
  validates_with LengthValidator, _merge_attributes(attr_names)
end
# called from activemodel-5.2.3/lib/active_model/secure_password.rb:79
activemodel-5.2.3/lib/active_model/validations/helper_methods.rb:7
ActiveModel::Validations::HelperMethods#_merge_attributes
def _merge_attributes(attr_names)
  options = attr_names.extract_options!.symbolize_keys
  attr_names.flatten!
  options[:attributes] = attr_names
  options
end
# called from activerecord-5.2.3/lib/active_record/validations/length.rb:20
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:24
Array#extract_options!
def extract_options!
  if last.is_a?(Hash) && last.extractable_options?
    pop
  else
    {}
  end
end
# called from activemodel-5.2.3/lib/active_model/validations/helper_methods.rb:8
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:9
Hash#extractable_options?
def extractable_options?
  instance_of?(Hash)
end
# called from activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:25
activesupport-5.2.3/lib/active_support/core_ext/hash/keys.rb:56
Hash#symbolize_keys
def symbolize_keys
  transform_keys { |key| key.to_sym rescue key }
end
# called from activemodel-5.2.3/lib/active_model/validations/helper_methods.rb:8
activemodel-5.2.3/lib/active_model/validations/with.rb:81
ActiveModel::Validations::ClassMethods#validates_with
def validates_with(*args, &block)
  options = args.extract_options!
  options[:class] = self

  args.each do |klass|
    validator = klass.new(options, &block)

    if validator.respond_to?(:attributes) && !validator.attributes.empty?
      validator.attributes.each do |attribute|
        _validators[attribute.to_sym] << validator
      end
    else
      _validators[nil] << validator
    end

    validate(validator, options)
  end
end
# called from activerecord-5.2.3/lib/active_record/validations/length.rb:20
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:24
Array#extract_options!
def extract_options!
  if last.is_a?(Hash) && last.extractable_options?
    pop
  else
    {}
  end
end
# called from activemodel-5.2.3/lib/active_model/validations/with.rb:82
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:9
Hash#extractable_options?
def extractable_options?
  instance_of?(Hash)
end
# called from activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:25
activemodel-5.2.3/lib/active_model/validations/length.rb:11
ActiveModel::Validations::LengthValidator#initialize
def initialize(options)
  if range = (options.delete(:in) || options.delete(:within))
    raise ArgumentError, ":in and :within must be a Range" unless range.is_a?(Range)
    options[:minimum], options[:maximum] = range.min, range.max
  end

  if options[:allow_blank] == false && options[:minimum].nil? && options[:is].nil?
    options[:minimum] = 1
  end

  super
end
# called from activemodel-5.2.3/lib/active_model/validations/with.rb:86
activemodel-5.2.3/lib/active_model/validator.rb:138
ActiveModel::EachValidator#initialize
def initialize(options)
  @attributes = Array(options.delete(:attributes))
  raise ArgumentError, ":attributes cannot be blank" if @attributes.empty?
  super
  check_validity!
end
# called from activemodel-5.2.3/lib/active_model/validations/length.rb:21
activemodel-5.2.3/lib/active_model/validator.rb:108
ActiveModel::Validator#initialize
def initialize(options = {})
  @options = options.except(:class).freeze
end
# called from activemodel-5.2.3/lib/active_model/validator.rb:141
activesupport-5.2.3/lib/active_support/core_ext/hash/except.rb:12
Hash#except
def except(*keys)
  dup.except!(*keys)
end
# called from activemodel-5.2.3/lib/active_model/validator.rb:109
activesupport-5.2.3/lib/active_support/core_ext/hash/except.rb:20
Hash#except!
def except!(*keys)
  keys.each { |key| delete(key) }
  self
end
# called from activesupport-5.2.3/lib/active_support/core_ext/hash/except.rb:13
activemodel-5.2.3/lib/active_model/validations/length.rb:24
ActiveModel::Validations::LengthValidator#check_validity!
def check_validity!
  keys = CHECKS.keys & options.keys

  if keys.empty?
    raise ArgumentError, "Range unspecified. Specify the :in, :within, :maximum, :minimum, or :is option."
  end

  keys.each do |key|
    value = options[key]

    unless (value.is_a?(Integer) && value >= 0) || value == Float::INFINITY || value.is_a?(Symbol) || value.is_a?(Proc)
      raise ArgumentError, ":#{key} must be a nonnegative Integer, Infinity, Symbol, or Proc"
    end
  end
end
# called from activemodel-5.2.3/lib/active_model/validator.rb:142
activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:106
User._validators
redefine_method(name) { val }
# called from activemodel-5.2.3/lib/active_model/validations/with.rb:90
activemodel-5.2.3/lib/active_model/validations.rb:154
ActiveModel::Validations::ClassMethods#validate
def validate(*args, &block)
  options = args.extract_options!

  if args.all? { |arg| arg.is_a?(Symbol) }
    options.each_key do |k|
      unless VALID_OPTIONS_FOR_VALIDATE.include?(k)
        raise ArgumentError.new("Unknown key: #{k.inspect}. Valid keys are: #{VALID_OPTIONS_FOR_VALIDATE.map(&:inspect).join(', ')}. Perhaps you meant to call `validates` instead of `validate`?")
      end
    end
  end

  if options.key?(:on)
    options = options.dup
    options[:on] = Array(options[:on])
    options[:if] = Array(options[:if])
    options[:if].unshift ->(o) {
      !(options[:on] & Array(o.validation_context)).empty?
    }
  end

  set_callback(:validate, *args, options, &block)
end
# called from activemodel-5.2.3/lib/active_model/validations/with.rb:96
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:24
Array#extract_options!
def extract_options!
  if last.is_a?(Hash) && last.extractable_options?
    pop
  else
    {}
  end
end
# called from activemodel-5.2.3/lib/active_model/validations.rb:155
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:9
Hash#extractable_options?
def extractable_options?
  instance_of?(Hash)
end
# called from activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:25
activesupport-5.2.3/lib/active_support/callbacks.rb:667
ActiveSupport::Callbacks::ClassMethods#set_callback
def set_callback(name, *filter_list, &block)
  type, filters, options = normalize_callback_params(filter_list, block)

  self_chain = get_callbacks name
  mapped = filters.map do |filter|
    Callback.build(self_chain, filter, type, options)
  end

  __update_callbacks(name) do |target, chain|
    options[:prepend] ? chain.prepend(*mapped) : chain.append(*mapped)
    target.set_callbacks name, chain
  end
end
# called from activemodel-5.2.3/lib/active_model/validations.rb:174
activesupport-5.2.3/lib/active_support/callbacks.rb:615
ActiveSupport::Callbacks::ClassMethods#normalize_callback_params
def normalize_callback_params(filters, block) # :nodoc:
  type = CALLBACK_FILTER_TYPES.include?(filters.first) ? filters.shift : :before
  options = filters.extract_options!
  filters.unshift(block) if block
  [type, filters, options.dup]
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:668
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:24
Array#extract_options!
def extract_options!
  if last.is_a?(Hash) && last.extractable_options?
    pop
  else
    {}
  end
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:617
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:9
Hash#extractable_options?
def extractable_options?
  instance_of?(Hash)
end
# called from activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:25
activesupport-5.2.3/lib/active_support/callbacks.rb:836
ActiveSupport::Callbacks::ClassMethods#get_callbacks
def get_callbacks(name) # :nodoc:
  __callbacks[name.to_sym]
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:670
activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:106
User.__callbacks
redefine_method(name) { val }
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:837
activesupport-5.2.3/lib/active_support/callbacks.rb:281
ActiveSupport::Callbacks::Callback.build
def self.build(chain, filter, kind, options)
  if filter.is_a?(String)
    raise ArgumentError, <<-MSG.squish
      Passing string to define a callback is not supported. See the `.set_callback`
      documentation to see supported values.
    MSG
  end

  new chain.name, filter, kind, options, chain.config
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:672
activesupport-5.2.3/lib/active_support/callbacks.rb:295
ActiveSupport::Callbacks::Callback#initialize
def initialize(name, filter, kind, options, chain_config)
  @chain_config = chain_config
  @name    = name
  @kind    = kind
  @filter  = filter
  @key     = compute_identifier filter
  @if      = check_conditionals(Array(options[:if]))
  @unless  = check_conditionals(Array(options[:unless]))
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:289
activesupport-5.2.3/lib/active_support/callbacks.rb:365
ActiveSupport::Callbacks::Callback#compute_identifier
def compute_identifier(filter)
  case filter
  when ::Proc
    filter.object_id
  else
    filter
  end
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:300
activesupport-5.2.3/lib/active_support/callbacks.rb:353
ActiveSupport::Callbacks::Callback#check_conditionals
def check_conditionals(conditionals)
  if conditionals.any? { |c| c.is_a?(String) }
    raise ArgumentError, <<-MSG.squish
      Passing string to be evaluated in :if and :unless conditional
      options is not supported. Pass a symbol for an instance method,
      or a lambda, proc or block, instead.
    MSG
  end

  conditionals
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:301
activesupport-5.2.3/lib/active_support/callbacks.rb:353
ActiveSupport::Callbacks::Callback#check_conditionals
def check_conditionals(conditionals)
  if conditionals.any? { |c| c.is_a?(String) }
    raise ArgumentError, <<-MSG.squish
      Passing string to be evaluated in :if and :unless conditional
      options is not supported. Pass a symbol for an instance method,
      or a lambda, proc or block, instead.
    MSG
  end

  conditionals
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:302
activesupport-5.2.3/lib/active_support/callbacks.rb:624
ActiveSupport::Callbacks::ClassMethods#__update_callbacks
def __update_callbacks(name) #:nodoc:
  ([self] + ActiveSupport::DescendantsTracker.descendants(self)).reverse_each do |target|
    chain = target.get_callbacks name
    yield target, chain.dup
  end
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:675
activesupport-5.2.3/lib/active_support/descendants_tracker.rb:14
ActiveSupport::DescendantsTracker.descendants
def descendants(klass)
  arr = []
  accumulate_descendants(klass, arr)
  arr
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:625
activesupport-5.2.3/lib/active_support/descendants_tracker.rb:41
ActiveSupport::DescendantsTracker.accumulate_descendants
def accumulate_descendants(klass, acc)
  if direct_descendants = @@direct_descendants[klass]
    acc.concat(direct_descendants)
    direct_descendants.each { |direct_descendant| accumulate_descendants(direct_descendant, acc) }
  end
end
# called from activesupport-5.2.3/lib/active_support/descendants_tracker.rb:16
activesupport-5.2.3/lib/active_support/callbacks.rb:836
ActiveSupport::Callbacks::ClassMethods#get_callbacks
def get_callbacks(name) # :nodoc:
  __callbacks[name.to_sym]
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:626
activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:106
User.__callbacks
redefine_method(name) { val }
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:837
activesupport-5.2.3/lib/active_support/callbacks.rb:557
ActiveSupport::Callbacks::CallbackChain#initialize_copy
def initialize_copy(other)
  @callbacks = nil
  @chain     = other.chain.dup
  @mutex     = Mutex.new
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:627
activesupport-5.2.3/lib/active_support/callbacks.rb:581
ActiveSupport::Callbacks::CallbackChain#chain
def chain; @chain; end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:559
activesupport-5.2.3/lib/active_support/callbacks.rb:572
ActiveSupport::Callbacks::CallbackChain#append
def append(*callbacks)
  callbacks.each { |c| append_one(c) }
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:676
activesupport-5.2.3/lib/active_support/callbacks.rb:585
ActiveSupport::Callbacks::CallbackChain#append_one
def append_one(callback)
  @callbacks = nil
  remove_duplicates(callback)
  @chain.push(callback)
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:573
activesupport-5.2.3/lib/active_support/callbacks.rb:597
ActiveSupport::Callbacks::CallbackChain#remove_duplicates
def remove_duplicates(callback)
  @callbacks = nil
  @chain.delete_if { |c| callback.duplicates?(c) }
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:587
activesupport-5.2.3/lib/active_support/callbacks.rb:324
ActiveSupport::Callbacks::Callback#duplicates?
def duplicates?(other)
  case @filter
  when Symbol
    matches?(other.kind, other.filter)
  else
    false
  end
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:599
activesupport-5.2.3/lib/active_support/callbacks.rb:840
ActiveSupport::Callbacks::ClassMethods#set_callbacks
def set_callbacks(name, callbacks) # :nodoc:
  self.__callbacks = __callbacks.merge(name.to_sym => callbacks)
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:677
activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:106
User.__callbacks
redefine_method(name) { val }
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:841
activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:104
ActiveRecord::Base.__callbacks=
define_singleton_method("#{name}=") do |val|
  singleton_class.class_eval do
    redefine_method(name) { val }
  end

  if singleton_class?
    class_eval do
      redefine_method(name) do
        if instance_variable_defined? ivar
          instance_variable_get ivar
        else
          singleton_class.send name
        end
      end
    end
  end
  val
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:841
activesupport-5.2.3/lib/active_support/core_ext/module/redefine_method.rb:26
Module#redefine_method
def redefine_method(method, &block)
  visibility = method_visibility(method)
  silence_redefinition_of_method(method)
  define_method(method, &block)
  send(visibility, method)
end
# called from activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:106
activesupport-5.2.3/lib/active_support/core_ext/module/redefine_method.rb:39
Module#method_visibility
def method_visibility(method) # :nodoc:
  case
  when private_method_defined?(method)
    :private
  when protected_method_defined?(method)
    :protected
  else
    :public
  end
end
# called from activesupport-5.2.3/lib/active_support/core_ext/module/redefine_method.rb:27
activesupport-5.2.3/lib/active_support/core_ext/module/redefine_method.rb:8
Module#silence_redefinition_of_method
def silence_redefinition_of_method(method)
  if method_defined?(method) || private_method_defined?(method)
    # This suppresses the "method redefined" warning; the self-alias
    # looks odd, but means we don't need to generate a unique name
    alias_method method, method
  end
end
# called from activesupport-5.2.3/lib/active_support/core_ext/module/redefine_method.rb:28
activemodel-5.2.3/lib/active_model/validations/confirmation.rb:75
ActiveModel::Validations::HelperMethods#validates_confirmation_of
def validates_confirmation_of(*attr_names)
  validates_with ConfirmationValidator, _merge_attributes(attr_names)
end
# called from activemodel-5.2.3/lib/active_model/secure_password.rb:80
activemodel-5.2.3/lib/active_model/validations/helper_methods.rb:7
ActiveModel::Validations::HelperMethods#_merge_attributes
def _merge_attributes(attr_names)
  options = attr_names.extract_options!.symbolize_keys
  attr_names.flatten!
  options[:attributes] = attr_names
  options
end
# called from activemodel-5.2.3/lib/active_model/validations/confirmation.rb:76
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:24
Array#extract_options!
def extract_options!
  if last.is_a?(Hash) && last.extractable_options?
    pop
  else
    {}
  end
end
# called from activemodel-5.2.3/lib/active_model/validations/helper_methods.rb:8
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:9
Hash#extractable_options?
def extractable_options?
  instance_of?(Hash)
end
# called from activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:25
activesupport-5.2.3/lib/active_support/core_ext/hash/keys.rb:56
Hash#symbolize_keys
def symbolize_keys
  transform_keys { |key| key.to_sym rescue key }
end
# called from activemodel-5.2.3/lib/active_model/validations/helper_methods.rb:8
activemodel-5.2.3/lib/active_model/validations/with.rb:81
ActiveModel::Validations::ClassMethods#validates_with
def validates_with(*args, &block)
  options = args.extract_options!
  options[:class] = self

  args.each do |klass|
    validator = klass.new(options, &block)

    if validator.respond_to?(:attributes) && !validator.attributes.empty?
      validator.attributes.each do |attribute|
        _validators[attribute.to_sym] << validator
      end
    else
      _validators[nil] << validator
    end

    validate(validator, options)
  end
end
# called from activemodel-5.2.3/lib/active_model/validations/confirmation.rb:76
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:24
Array#extract_options!
def extract_options!
  if last.is_a?(Hash) && last.extractable_options?
    pop
  else
    {}
  end
end
# called from activemodel-5.2.3/lib/active_model/validations/with.rb:82
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:9
Hash#extractable_options?
def extractable_options?
  instance_of?(Hash)
end
# called from activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:25
activemodel-5.2.3/lib/active_model/validations/confirmation.rb:6
ActiveModel::Validations::ConfirmationValidator#initialize
def initialize(options)
  super({ case_sensitive: true }.merge!(options))
  setup!(options[:class])
end
# called from activemodel-5.2.3/lib/active_model/validations/with.rb:86
activemodel-5.2.3/lib/active_model/validator.rb:138
ActiveModel::EachValidator#initialize
def initialize(options)
  @attributes = Array(options.delete(:attributes))
  raise ArgumentError, ":attributes cannot be blank" if @attributes.empty?
  super
  check_validity!
end
# called from activemodel-5.2.3/lib/active_model/validations/confirmation.rb:7
activemodel-5.2.3/lib/active_model/validator.rb:108
ActiveModel::Validator#initialize
def initialize(options = {})
  @options = options.except(:class).freeze
end
# called from activemodel-5.2.3/lib/active_model/validator.rb:141
activesupport-5.2.3/lib/active_support/core_ext/hash/except.rb:12
Hash#except
def except(*keys)
  dup.except!(*keys)
end
# called from activemodel-5.2.3/lib/active_model/validator.rb:109
activesupport-5.2.3/lib/active_support/core_ext/hash/except.rb:20
Hash#except!
def except!(*keys)
  keys.each { |key| delete(key) }
  self
end
# called from activesupport-5.2.3/lib/active_support/core_ext/hash/except.rb:13
activemodel-5.2.3/lib/active_model/validator.rb:165
ActiveModel::EachValidator#check_validity!
def check_validity!
end
# called from activemodel-5.2.3/lib/active_model/validator.rb:142
activemodel-5.2.3/lib/active_model/validations/confirmation.rb:21
ActiveModel::Validations::ConfirmationValidator#setup!
def setup!(klass)
  klass.send(:attr_reader, *attributes.map do |attribute|
    :"#{attribute}_confirmation" unless klass.method_defined?(:"#{attribute}_confirmation")
  end.compact)

  klass.send(:attr_writer, *attributes.map do |attribute|
    :"#{attribute}_confirmation" unless klass.method_defined?(:"#{attribute}_confirmation=")
  end.compact)
end
# called from activemodel-5.2.3/lib/active_model/validations/confirmation.rb:8
activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:106
User._validators
redefine_method(name) { val }
# called from activemodel-5.2.3/lib/active_model/validations/with.rb:90
activemodel-5.2.3/lib/active_model/validations.rb:154
ActiveModel::Validations::ClassMethods#validate
def validate(*args, &block)
  options = args.extract_options!

  if args.all? { |arg| arg.is_a?(Symbol) }
    options.each_key do |k|
      unless VALID_OPTIONS_FOR_VALIDATE.include?(k)
        raise ArgumentError.new("Unknown key: #{k.inspect}. Valid keys are: #{VALID_OPTIONS_FOR_VALIDATE.map(&:inspect).join(', ')}. Perhaps you meant to call `validates` instead of `validate`?")
      end
    end
  end

  if options.key?(:on)
    options = options.dup
    options[:on] = Array(options[:on])
    options[:if] = Array(options[:if])
    options[:if].unshift ->(o) {
      !(options[:on] & Array(o.validation_context)).empty?
    }
  end

  set_callback(:validate, *args, options, &block)
end
# called from activemodel-5.2.3/lib/active_model/validations/with.rb:96
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:24
Array#extract_options!
def extract_options!
  if last.is_a?(Hash) && last.extractable_options?
    pop
  else
    {}
  end
end
# called from activemodel-5.2.3/lib/active_model/validations.rb:155
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:9
Hash#extractable_options?
def extractable_options?
  instance_of?(Hash)
end
# called from activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:25
activesupport-5.2.3/lib/active_support/callbacks.rb:667
ActiveSupport::Callbacks::ClassMethods#set_callback
def set_callback(name, *filter_list, &block)
  type, filters, options = normalize_callback_params(filter_list, block)

  self_chain = get_callbacks name
  mapped = filters.map do |filter|
    Callback.build(self_chain, filter, type, options)
  end

  __update_callbacks(name) do |target, chain|
    options[:prepend] ? chain.prepend(*mapped) : chain.append(*mapped)
    target.set_callbacks name, chain
  end
end
# called from activemodel-5.2.3/lib/active_model/validations.rb:174
activesupport-5.2.3/lib/active_support/callbacks.rb:615
ActiveSupport::Callbacks::ClassMethods#normalize_callback_params
def normalize_callback_params(filters, block) # :nodoc:
  type = CALLBACK_FILTER_TYPES.include?(filters.first) ? filters.shift : :before
  options = filters.extract_options!
  filters.unshift(block) if block
  [type, filters, options.dup]
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:668
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:24
Array#extract_options!
def extract_options!
  if last.is_a?(Hash) && last.extractable_options?
    pop
  else
    {}
  end
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:617
activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:9
Hash#extractable_options?
def extractable_options?
  instance_of?(Hash)
end
# called from activesupport-5.2.3/lib/active_support/core_ext/array/extract_options.rb:25
activesupport-5.2.3/lib/active_support/callbacks.rb:836
ActiveSupport::Callbacks::ClassMethods#get_callbacks
def get_callbacks(name) # :nodoc:
  __callbacks[name.to_sym]
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:670
activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:106
User.__callbacks
redefine_method(name) { val }
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:837
activesupport-5.2.3/lib/active_support/callbacks.rb:281
ActiveSupport::Callbacks::Callback.build
def self.build(chain, filter, kind, options)
  if filter.is_a?(String)
    raise ArgumentError, <<-MSG.squish
      Passing string to define a callback is not supported. See the `.set_callback`
      documentation to see supported values.
    MSG
  end

  new chain.name, filter, kind, options, chain.config
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:672
activesupport-5.2.3/lib/active_support/callbacks.rb:295
ActiveSupport::Callbacks::Callback#initialize
def initialize(name, filter, kind, options, chain_config)
  @chain_config = chain_config
  @name    = name
  @kind    = kind
  @filter  = filter
  @key     = compute_identifier filter
  @if      = check_conditionals(Array(options[:if]))
  @unless  = check_conditionals(Array(options[:unless]))
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:289
activesupport-5.2.3/lib/active_support/callbacks.rb:365
ActiveSupport::Callbacks::Callback#compute_identifier
def compute_identifier(filter)
  case filter
  when ::Proc
    filter.object_id
  else
    filter
  end
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:300
activesupport-5.2.3/lib/active_support/callbacks.rb:353
ActiveSupport::Callbacks::Callback#check_conditionals
def check_conditionals(conditionals)
  if conditionals.any? { |c| c.is_a?(String) }
    raise ArgumentError, <<-MSG.squish
      Passing string to be evaluated in :if and :unless conditional
      options is not supported. Pass a symbol for an instance method,
      or a lambda, proc or block, instead.
    MSG
  end

  conditionals
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:301
activesupport-5.2.3/lib/active_support/callbacks.rb:353
ActiveSupport::Callbacks::Callback#check_conditionals
def check_conditionals(conditionals)
  if conditionals.any? { |c| c.is_a?(String) }
    raise ArgumentError, <<-MSG.squish
      Passing string to be evaluated in :if and :unless conditional
      options is not supported. Pass a symbol for an instance method,
      or a lambda, proc or block, instead.
    MSG
  end

  conditionals
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:302
activesupport-5.2.3/lib/active_support/callbacks.rb:624
ActiveSupport::Callbacks::ClassMethods#__update_callbacks
def __update_callbacks(name) #:nodoc:
  ([self] + ActiveSupport::DescendantsTracker.descendants(self)).reverse_each do |target|
    chain = target.get_callbacks name
    yield target, chain.dup
  end
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:675
activesupport-5.2.3/lib/active_support/descendants_tracker.rb:14
ActiveSupport::DescendantsTracker.descendants
def descendants(klass)
  arr = []
  accumulate_descendants(klass, arr)
  arr
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:625
activesupport-5.2.3/lib/active_support/descendants_tracker.rb:41
ActiveSupport::DescendantsTracker.accumulate_descendants
def accumulate_descendants(klass, acc)
  if direct_descendants = @@direct_descendants[klass]
    acc.concat(direct_descendants)
    direct_descendants.each { |direct_descendant| accumulate_descendants(direct_descendant, acc) }
  end
end
# called from activesupport-5.2.3/lib/active_support/descendants_tracker.rb:16
activesupport-5.2.3/lib/active_support/callbacks.rb:836
ActiveSupport::Callbacks::ClassMethods#get_callbacks
def get_callbacks(name) # :nodoc:
  __callbacks[name.to_sym]
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:626
activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:106
User.__callbacks
redefine_method(name) { val }
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:837
activesupport-5.2.3/lib/active_support/callbacks.rb:557
ActiveSupport::Callbacks::CallbackChain#initialize_copy
def initialize_copy(other)
  @callbacks = nil
  @chain     = other.chain.dup
  @mutex     = Mutex.new
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:627
activesupport-5.2.3/lib/active_support/callbacks.rb:581
ActiveSupport::Callbacks::CallbackChain#chain
def chain; @chain; end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:559
activesupport-5.2.3/lib/active_support/callbacks.rb:572
ActiveSupport::Callbacks::CallbackChain#append
def append(*callbacks)
  callbacks.each { |c| append_one(c) }
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:676
activesupport-5.2.3/lib/active_support/callbacks.rb:585
ActiveSupport::Callbacks::CallbackChain#append_one
def append_one(callback)
  @callbacks = nil
  remove_duplicates(callback)
  @chain.push(callback)
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:573
activesupport-5.2.3/lib/active_support/callbacks.rb:597
ActiveSupport::Callbacks::CallbackChain#remove_duplicates
def remove_duplicates(callback)
  @callbacks = nil
  @chain.delete_if { |c| callback.duplicates?(c) }
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:587
activesupport-5.2.3/lib/active_support/callbacks.rb:324
ActiveSupport::Callbacks::Callback#duplicates?
def duplicates?(other)
  case @filter
  when Symbol
    matches?(other.kind, other.filter)
  else
    false
  end
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:599
activesupport-5.2.3/lib/active_support/callbacks.rb:324
ActiveSupport::Callbacks::Callback#duplicates?
def duplicates?(other)
  case @filter
  when Symbol
    matches?(other.kind, other.filter)
  else
    false
  end
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:599
activesupport-5.2.3/lib/active_support/callbacks.rb:840
ActiveSupport::Callbacks::ClassMethods#set_callbacks
def set_callbacks(name, callbacks) # :nodoc:
  self.__callbacks = __callbacks.merge(name.to_sym => callbacks)
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:677
activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:106
User.__callbacks
redefine_method(name) { val }
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:841
activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:104
ActiveRecord::Base.__callbacks=
define_singleton_method("#{name}=") do |val|
  singleton_class.class_eval do
    redefine_method(name) { val }
  end

  if singleton_class?
    class_eval do
      redefine_method(name) do
        if instance_variable_defined? ivar
          instance_variable_get ivar
        else
          singleton_class.send name
        end
      end
    end
  end
  val
end
# called from activesupport-5.2.3/lib/active_support/callbacks.rb:841
activesupport-5.2.3/lib/active_support/core_ext/module/redefine_method.rb:26
Module#redefine_method
def redefine_method(method, &block)
  visibility = method_visibility(method)
  silence_redefinition_of_method(method)
  define_method(method, &block)
  send(visibility, method)
end
# called from activesupport-5.2.3/lib/active_support/core_ext/class/attribute.rb:106
activesupport-5.2.3/lib/active_support/core_ext/module/redefine_method.rb:39
Module#method_visibility
def method_visibility(method) # :nodoc:
  case
  when private_method_defined?(method)
    :private
  when protected_method_defined?(method)
    :protected
  else
    :public
  end
end
# called from activesupport-5.2.3/lib/active_support/core_ext/module/redefine_method.rb:27
activesupport-5.2.3/lib/active_support/core_ext/module/redefine_method.rb:8
Module#silence_redefinition_of_method
def silence_redefinition_of_method(method)
  if method_defined?(method) || private_method_defined?(method)
    # This suppresses the "method redefined" warning; the self-alias
    # looks odd, but means we don't need to generate a unique name
    alias_method method, method
  end
end
# called from activesupport-5.2.3/lib/active_support/core_ext/module/redefine_method.rb:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment