# typed: true
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `activemodel` gem.
# Please instead update this file by running `bin/tapioca gem activemodel`.
# source://activemodel//lib/active_model/gem_version.rb#3
module ActiveModel
extend ::ActiveSupport::Autoload
class << self
# source://activemodel//lib/active_model.rb#72
def eager_load!; end
# Returns the currently loaded version of \Active \Model as a Gem::Version.
#
# source://activemodel//lib/active_model/gem_version.rb#5
def gem_version; end
# Returns the currently loaded version of \Active \Model as a Gem::Version.
#
# source://activemodel//lib/active_model/version.rb#7
def version; end
end
end
# == Active \Model \API
#
# Includes the required interface for an object to interact with
# Action Pack and Action View, using different Active Model modules.
# It includes model name introspections, conversions, translations, and
# validations. Besides that, it allows you to initialize the object with a
# hash of attributes, pretty much like Active Record does.
#
# A minimal implementation could be:
#
# class Person
# include ActiveModel::API
# attr_accessor :name, :age
# end
#
# person = Person.new(name: 'bob', age: '18')
# person.name # => "bob"
# person.age # => "18"
#
# Note that, by default, ActiveModel::API implements persisted?
# to return +false+, which is the most common case. You may want to override
# it in your class to simulate a different scenario:
#
# class Person
# include ActiveModel::API
# attr_accessor :id, :name
#
# def persisted?
# self.id.present?
# end
# end
#
# person = Person.new(id: 1, name: 'bob')
# person.persisted? # => true
#
# Also, if for some reason you need to run code on initialize, make
# sure you call +super+ if you want the attributes hash initialization to
# happen.
#
# class Person
# include ActiveModel::API
# attr_accessor :id, :name, :omg
#
# def initialize(attributes={})
# super
# @omg ||= true
# end
# end
#
# person = Person.new(id: 1, name: 'bob')
# person.omg # => true
#
# For more detailed information on other functionalities available, please
# refer to the specific modules included in ActiveModel::API
# (see below).
#
# source://activemodel//lib/active_model/api.rb#59
module ActiveModel::API
include ::ActiveModel::ForbiddenAttributesProtection
include ::ActiveModel::AttributeAssignment
extend ::ActiveSupport::Concern
include GeneratedInstanceMethods
include ::ActiveSupport::Callbacks
include ::ActiveModel::Validations::HelperMethods
include ::ActiveModel::Validations
include ::ActiveModel::Conversion
mixes_in_class_methods GeneratedClassMethods
mixes_in_class_methods ::ActiveModel::Validations::ClassMethods
mixes_in_class_methods ::ActiveModel::Callbacks
mixes_in_class_methods ::ActiveSupport::Callbacks::ClassMethods
mixes_in_class_methods ::ActiveSupport::DescendantsTracker
mixes_in_class_methods ::ActiveModel::Translation
mixes_in_class_methods ::ActiveModel::Validations::HelperMethods
mixes_in_class_methods ::ActiveModel::Conversion::ClassMethods
# Initializes a new model with the given +params+.
#
# class Person
# include ActiveModel::API
# attr_accessor :name, :age
# end
#
# person = Person.new(name: 'bob', age: '18')
# person.name # => "bob"
# person.age # => "18"
#
# source://activemodel//lib/active_model/api.rb#80
def initialize(attributes = T.unsafe(nil)); end
# Indicates if the model is persisted. Default is +false+.
#
# class Person
# include ActiveModel::API
# attr_accessor :id, :name
# end
#
# person = Person.new(id: 1, name: 'bob')
# person.persisted? # => false
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/api.rb#95
def persisted?; end
module GeneratedClassMethods
def __callbacks; end
def __callbacks=(value); end
def __callbacks?; end
def _validators; end
def _validators=(value); end
def _validators?; end
end
module GeneratedInstanceMethods
def __callbacks; end
def __callbacks?; end
def _validators; end
def _validators?; end
end
end
# source://activemodel//lib/active_model/attribute.rb#6
class ActiveModel::Attribute
# This method should not be called directly.
# Use #from_database or #from_user
#
# @return [Attribute] a new instance of Attribute
#
# source://activemodel//lib/active_model/attribute.rb#33
def initialize(name, value_before_type_cast, type, original_attribute = T.unsafe(nil), value = T.unsafe(nil)); end
# source://activemodel//lib/active_model/attribute.rb#112
def ==(other); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#104
def came_from_user?; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#63
def changed?; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#67
def changed_in_place?; end
# source://activemodel//lib/active_model/attribute.rb#132
def encode_with(coder); end
# source://activemodel//lib/active_model/attribute.rb#112
def eql?(other); end
# source://activemodel//lib/active_model/attribute.rb#71
def forgetting_assignment; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#108
def has_been_read?; end
# source://activemodel//lib/active_model/attribute.rb#120
def hash; end
# source://activemodel//lib/active_model/attribute.rb#124
def init_with(coder); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#100
def initialized?; end
# Returns the value of attribute name.
#
# source://activemodel//lib/active_model/attribute.rb#29
def name; end
# source://activemodel//lib/active_model/attribute.rb#47
def original_value; end
# source://activemodel//lib/active_model/attribute.rb#140
def original_value_for_database; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#59
def serializable?(&block); end
# Returns the value of attribute type.
#
# source://activemodel//lib/active_model/attribute.rb#29
def type; end
# @raise [NotImplementedError]
#
# source://activemodel//lib/active_model/attribute.rb#96
def type_cast(*_arg0); end
# source://activemodel//lib/active_model/attribute.rb#41
def value; end
# Returns the value of attribute value_before_type_cast.
#
# source://activemodel//lib/active_model/attribute.rb#29
def value_before_type_cast; end
# source://activemodel//lib/active_model/attribute.rb#55
def value_for_database; end
# source://activemodel//lib/active_model/attribute.rb#84
def with_cast_value(value); end
# source://activemodel//lib/active_model/attribute.rb#88
def with_type(type); end
# source://activemodel//lib/active_model/attribute.rb#80
def with_value_from_database(value); end
# source://activemodel//lib/active_model/attribute.rb#75
def with_value_from_user(value); end
private
# source://activemodel//lib/active_model/attribute.rb#162
def _original_value_for_database; end
# Returns the value of attribute original_attribute.
#
# source://activemodel//lib/active_model/attribute.rb#149
def assigned?; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#158
def changed_from_assignment?; end
# source://activemodel//lib/active_model/attribute.rb#152
def initialize_dup(other); end
# Returns the value of attribute original_attribute.
#
# source://activemodel//lib/active_model/attribute.rb#149
def original_attribute; end
class << self
# source://activemodel//lib/active_model/attribute.rb#8
def from_database(name, value_before_type_cast, type, value = T.unsafe(nil)); end
# source://activemodel//lib/active_model/attribute.rb#12
def from_user(name, value_before_type_cast, type, original_attribute = T.unsafe(nil)); end
# source://activemodel//lib/active_model/attribute.rb#20
def null(name); end
# source://activemodel//lib/active_model/attribute.rb#24
def uninitialized(name, type); end
# source://activemodel//lib/active_model/attribute.rb#16
def with_cast_value(name, value_before_type_cast, type); end
end
end
# source://activemodel//lib/active_model/attribute.rb#166
class ActiveModel::Attribute::FromDatabase < ::ActiveModel::Attribute
# source://activemodel//lib/active_model/attribute.rb#167
def type_cast(value); end
private
# source://activemodel//lib/active_model/attribute.rb#172
def _original_value_for_database; end
end
# source://activemodel//lib/active_model/attribute.rb#177
class ActiveModel::Attribute::FromUser < ::ActiveModel::Attribute
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#182
def came_from_user?; end
# source://activemodel//lib/active_model/attribute.rb#178
def type_cast(value); end
end
# source://activemodel//lib/active_model/attribute.rb#197
class ActiveModel::Attribute::Null < ::ActiveModel::Attribute
# @return [Null] a new instance of Null
#
# source://activemodel//lib/active_model/attribute.rb#198
def initialize(name); end
# source://activemodel//lib/active_model/attribute.rb#202
def type_cast(*_arg0); end
# @raise [ActiveModel::MissingAttributeError]
#
# source://activemodel//lib/active_model/attribute.rb#210
def with_cast_value(value); end
# source://activemodel//lib/active_model/attribute.rb#206
def with_type(type); end
# @raise [ActiveModel::MissingAttributeError]
#
# source://activemodel//lib/active_model/attribute.rb#210
def with_value_from_database(value); end
# @raise [ActiveModel::MissingAttributeError]
#
# source://activemodel//lib/active_model/attribute.rb#210
def with_value_from_user(value); end
end
# source://activemodel//lib/active_model/attribute.rb#217
class ActiveModel::Attribute::Uninitialized < ::ActiveModel::Attribute
# @return [Uninitialized] a new instance of Uninitialized
#
# source://activemodel//lib/active_model/attribute.rb#220
def initialize(name, type); end
# source://activemodel//lib/active_model/attribute.rb#241
def forgetting_assignment; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#237
def initialized?; end
# source://activemodel//lib/active_model/attribute.rb#230
def original_value; end
# source://activemodel//lib/active_model/attribute.rb#224
def value; end
# source://activemodel//lib/active_model/attribute.rb#234
def value_for_database; end
# source://activemodel//lib/active_model/attribute.rb#245
def with_type(type); end
end
# source://activemodel//lib/active_model/attribute.rb#218
ActiveModel::Attribute::Uninitialized::UNINITIALIZED_ORIGINAL_VALUE = T.let(T.unsafe(nil), Object)
# source://activemodel//lib/active_model/attribute/user_provided_default.rb#7
class ActiveModel::Attribute::UserProvidedDefault < ::ActiveModel::Attribute::FromUser
# @return [UserProvidedDefault] a new instance of UserProvidedDefault
#
# source://activemodel//lib/active_model/attribute/user_provided_default.rb#8
def initialize(name, value, type, database_default); end
# source://activemodel//lib/active_model/attribute/user_provided_default.rb#25
def marshal_dump; end
# source://activemodel//lib/active_model/attribute/user_provided_default.rb#36
def marshal_load(values); end
# source://activemodel//lib/active_model/attribute/user_provided_default.rb#13
def value_before_type_cast; end
# source://activemodel//lib/active_model/attribute/user_provided_default.rb#21
def with_type(type); end
private
# Returns the value of attribute user_provided_value.
#
# source://activemodel//lib/active_model/attribute/user_provided_default.rb#48
def user_provided_value; end
end
# source://activemodel//lib/active_model/attribute.rb#187
class ActiveModel::Attribute::WithCastValue < ::ActiveModel::Attribute
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#192
def changed_in_place?; end
# source://activemodel//lib/active_model/attribute.rb#188
def type_cast(value); end
end
# source://activemodel//lib/active_model/attribute_assignment.rb#6
module ActiveModel::AttributeAssignment
include ::ActiveModel::ForbiddenAttributesProtection
# Allows you to set all the attributes by passing in a hash of attributes with
# keys matching the attribute names.
#
# If the passed hash responds to permitted? method and the return value
# of this method is +false+ an ActiveModel::ForbiddenAttributesError
# exception is raised.
#
# class Cat
# include ActiveModel::AttributeAssignment
# attr_accessor :name, :status
# end
#
# cat = Cat.new
# cat.assign_attributes(name: "Gorby", status: "yawning")
# cat.name # => 'Gorby'
# cat.status # => 'yawning'
# cat.assign_attributes(status: "sleeping")
# cat.name # => 'Gorby'
# cat.status # => 'sleeping'
#
# source://activemodel//lib/active_model/attribute_assignment.rb#28
def assign_attributes(new_attributes); end
# Allows you to set all the attributes by passing in a hash of attributes with
# keys matching the attribute names.
#
# If the passed hash responds to permitted? method and the return value
# of this method is +false+ an ActiveModel::ForbiddenAttributesError
# exception is raised.
#
# class Cat
# include ActiveModel::AttributeAssignment
# attr_accessor :name, :status
# end
#
# cat = Cat.new
# cat.assign_attributes(name: "Gorby", status: "yawning")
# cat.name # => 'Gorby'
# cat.status # => 'yawning'
# cat.assign_attributes(status: "sleeping")
# cat.name # => 'Gorby'
# cat.status # => 'sleeping'
#
# source://activemodel//lib/active_model/attribute_assignment.rb#28
def attributes=(new_attributes); end
private
# source://activemodel//lib/active_model/attribute_assignment.rb#46
def _assign_attribute(k, v); end
# source://activemodel//lib/active_model/attribute_assignment.rb#40
def _assign_attributes(attributes); end
end
# == Active \Model \Attribute \Methods
#
# Provides a way to add prefixes and suffixes to your methods as
# well as handling the creation of ActiveRecord::Base-like
# class methods such as +table_name+.
#
# The requirements to implement ActiveModel::AttributeMethods are to:
#
# * include ActiveModel::AttributeMethods in your class.
# * Call each of its methods you want to add, such as +attribute_method_suffix+
# or +attribute_method_prefix+.
# * Call +define_attribute_methods+ after the other methods are called.
# * Define the various generic +_attribute+ methods that you have declared.
# * Define an +attributes+ method which returns a hash with each
# attribute name in your model as hash key and the attribute value as hash value.
# Hash keys must be strings.
#
# A minimal implementation could be:
#
# class Person
# include ActiveModel::AttributeMethods
#
# attribute_method_affix prefix: 'reset_', suffix: '_to_default!'
# attribute_method_suffix '_contrived?'
# attribute_method_prefix 'clear_'
# define_attribute_methods :name
#
# attr_accessor :name
#
# def attributes
# { 'name' => @name }
# end
#
# private
# def attribute_contrived?(attr)
# true
# end
#
# def clear_attribute(attr)
# send("#{attr}=", nil)
# end
#
# def reset_attribute_to_default!(attr)
# send("#{attr}=", 'Default Name')
# end
# end
#
# source://activemodel//lib/active_model/attribute_methods.rb#64
module ActiveModel::AttributeMethods
extend ::ActiveSupport::Concern
include GeneratedInstanceMethods
mixes_in_class_methods GeneratedClassMethods
mixes_in_class_methods ::ActiveModel::AttributeMethods::ClassMethods
# +attribute_missing+ is like +method_missing+, but for attributes. When
# +method_missing+ is called we check to see if there is a matching
# attribute method. If so, we tell +attribute_missing+ to dispatch the
# attribute. This method can be overloaded to customize the behavior.
#
# source://activemodel//lib/active_model/attribute_methods.rb#459
def attribute_missing(match, *args, &block); end
# Allows access to the object attributes, which are held in the hash
# returned by attributes, as though they were first-class
# methods. So a +Person+ class with a +name+ attribute can for example use
# Person#name and Person#name= and never directly use
# the attributes hash -- except for multiple assignments with
# ActiveRecord::Base#attributes=.
#
# It's also possible to instantiate related objects, so a Client
# class belonging to the +clients+ table with a +master_id+ foreign key
# can instantiate master through Client#master.
#
# source://activemodel//lib/active_model/attribute_methods.rb#445
def method_missing(method, *args, &block); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_methods.rb#468
def respond_to?(method, include_private_methods = T.unsafe(nil)); end
# A +Person+ instance with a +name+ attribute can ask
# person.respond_to?(:name), person.respond_to?(:name=),
# and person.respond_to?(:name?) which will all return +true+.
def respond_to_without_attributes?(*_arg0); end
private
# source://activemodel//lib/active_model/attribute_methods.rb#496
def _read_attribute(attr); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_methods.rb#481
def attribute_method?(attr_name); end
# Returns a struct representing the matching attribute method.
# The struct's attributes are prefix, base and suffix.
#
# source://activemodel//lib/active_model/attribute_methods.rb#487
def matched_attribute_method(method_name); end
# @raise [ActiveModel::MissingAttributeError]
#
# source://activemodel//lib/active_model/attribute_methods.rb#492
def missing_attribute(attr_name, stack); end
module GeneratedClassMethods
def attribute_aliases; end
def attribute_aliases=(value); end
def attribute_aliases?; end
def attribute_method_matchers; end
def attribute_method_matchers=(value); end
def attribute_method_matchers?; end
end
module GeneratedInstanceMethods
def attribute_aliases; end
def attribute_aliases?; end
def attribute_method_matchers; end
def attribute_method_matchers?; end
end
end
# source://activemodel//lib/active_model/attribute_methods.rb#500
module ActiveModel::AttributeMethods::AttrNames
class << self
# We want to generate the methods via module_eval rather than
# define_method, because define_method is slower on dispatch.
#
# But sometimes the database might return columns with
# characters that are not allowed in normal method names (like
# 'my_column(omg)'. So to work around this we first define with
# the __temp__ identifier, and then use alias method to rename
# it to what we want.
#
# We are also defining a constant to hold the frozen string of
# the attribute name. Using a constant means that we do not have
# to allocate an object on each call to the attribute method.
# Making it frozen means that it doesn't get duped when used to
# key the @attributes in read_attribute.
#
# source://activemodel//lib/active_model/attribute_methods.rb#517
def define_attribute_accessor_method(owner, attr_name, writer: T.unsafe(nil)); end
end
end
# source://activemodel//lib/active_model/attribute_methods.rb#501
ActiveModel::AttributeMethods::AttrNames::DEF_SAFE_NAME = T.let(T.unsafe(nil), Regexp)
# source://activemodel//lib/active_model/attribute_methods.rb#68
ActiveModel::AttributeMethods::CALL_COMPILABLE_REGEXP = T.let(T.unsafe(nil), Regexp)
# source://activemodel//lib/active_model/attribute_methods.rb#76
module ActiveModel::AttributeMethods::ClassMethods
# Allows you to make aliases for attributes.
#
# class Person
# include ActiveModel::AttributeMethods
#
# attr_accessor :name
# attribute_method_suffix '_short?'
# define_attribute_methods :name
#
# alias_attribute :nickname, :name
#
# private
# def attribute_short?(attr)
# send(attr).length < 5
# end
# end
#
# person = Person.new
# person.name = 'Bob'
# person.name # => "Bob"
# person.nickname # => "Bob"
# person.name_short? # => true
# person.nickname_short? # => true
#
# source://activemodel//lib/active_model/attribute_methods.rb#204
def alias_attribute(new_name, old_name); end
# Returns the original name for the alias +name+
#
# source://activemodel//lib/active_model/attribute_methods.rb#243
def attribute_alias(name); end
# Is +new_name+ an alias?
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_methods.rb#238
def attribute_alias?(new_name); end
# Declares a method available for all attributes with the given prefix
# and suffix. Uses +method_missing+ and respond_to? to rewrite
# the method.
#
# #{prefix}#{attr}#{suffix}(*args, &block)
#
# to
#
# #{prefix}attribute#{suffix}(#{attr}, *args, &block)
#
# An #{prefix}attribute#{suffix} instance method must exist and
# accept at least the +attr+ argument.
#
# class Person
# include ActiveModel::AttributeMethods
#
# attr_accessor :name
# attribute_method_affix prefix: 'reset_', suffix: '_to_default!'
# define_attribute_methods :name
#
# private
# def reset_attribute_to_default!(attr)
# send("#{attr}=", 'Default Name')
# end
# end
#
# person = Person.new
# person.name # => 'Gem'
# person.reset_name_to_default!
# person.name # => 'Default Name'
#
# source://activemodel//lib/active_model/attribute_methods.rb#176
def attribute_method_affix(*affixes); end
# Declares a method available for all attributes with the given prefix.
# Uses +method_missing+ and respond_to? to rewrite the method.
#
# #{prefix}#{attr}(*args, &block)
#
# to
#
# #{prefix}attribute(#{attr}, *args, &block)
#
# An instance method #{prefix}attribute must exist and accept
# at least the +attr+ argument.
#
# class Person
# include ActiveModel::AttributeMethods
#
# attr_accessor :name
# attribute_method_prefix 'clear_'
# define_attribute_methods :name
#
# private
# def clear_attribute(attr)
# send("#{attr}=", nil)
# end
# end
#
# person = Person.new
# person.name = 'Bob'
# person.name # => "Bob"
# person.clear_name
# person.name # => nil
#
# source://activemodel//lib/active_model/attribute_methods.rb#107
def attribute_method_prefix(*prefixes, parameters: T.unsafe(nil)); end
# Declares a method available for all attributes with the given suffix.
# Uses +method_missing+ and respond_to? to rewrite the method.
#
# #{attr}#{suffix}(*args, &block)
#
# to
#
# attribute#{suffix}(#{attr}, *args, &block)
#
# An attribute#{suffix} instance method must exist and accept at
# least the +attr+ argument.
#
# class Person
# include ActiveModel::AttributeMethods
#
# attr_accessor :name
# attribute_method_suffix '_short?'
# define_attribute_methods :name
#
# private
# def attribute_short?(attr)
# send(attr).length < 5
# end
# end
#
# person = Person.new
# person.name = 'Bob'
# person.name # => "Bob"
# person.name_short? # => true
#
# source://activemodel//lib/active_model/attribute_methods.rb#141
def attribute_method_suffix(*suffixes, parameters: T.unsafe(nil)); end
# Declares an attribute that should be prefixed and suffixed by
# ActiveModel::AttributeMethods.
#
# To use, pass an attribute name (as string or symbol). Be sure to declare
# +define_attribute_method+ after you define any prefix, suffix or affix
# method, or they will not hook in.
#
# class Person
# include ActiveModel::AttributeMethods
#
# attr_accessor :name
# attribute_method_suffix '_short?'
#
# # Call to define_attribute_method must appear after the
# # attribute_method_prefix, attribute_method_suffix or
# # attribute_method_affix declarations.
# define_attribute_method :name
#
# private
# def attribute_short?(attr)
# send(attr).length < 5
# end
# end
#
# person = Person.new
# person.name = 'Bob'
# person.name # => "Bob"
# person.name_short? # => true
#
# source://activemodel//lib/active_model/attribute_methods.rb#304
def define_attribute_method(attr_name, _owner: T.unsafe(nil)); end
# Declares the attributes that should be prefixed and suffixed by
# ActiveModel::AttributeMethods.
#
# To use, pass attribute names (as strings or symbols). Be sure to declare
# +define_attribute_methods+ after you define any prefix, suffix, or affix
# methods, or they will not hook in.
#
# class Person
# include ActiveModel::AttributeMethods
#
# attr_accessor :name, :age, :address
# attribute_method_prefix 'clear_'
#
# # Call to define_attribute_methods must appear after the
# # attribute_method_prefix, attribute_method_suffix or
# # attribute_method_affix declarations.
# define_attribute_methods :name, :age, :address
#
# private
# def clear_attribute(attr)
# send("#{attr}=", nil)
# end
# end
#
# source://activemodel//lib/active_model/attribute_methods.rb#270
def define_attribute_methods(*attr_names); end
# Removes all the previously dynamically defined methods from the class.
#
# class Person
# include ActiveModel::AttributeMethods
#
# attr_accessor :name
# attribute_method_suffix '_short?'
# define_attribute_method :name
#
# private
# def attribute_short?(attr)
# send(attr).length < 5
# end
# end
#
# person = Person.new
# person.name = 'Bob'
# person.name_short? # => true
#
# Person.undefine_attribute_methods
#
# person.name_short? # => NoMethodError
#
# source://activemodel//lib/active_model/attribute_methods.rb#345
def undefine_attribute_methods; end
private
# The methods +method_missing+ and +respond_to?+ of this module are
# invoked often in a typical rails, both of which invoke the method
# +matched_attribute_method+. The latter method iterates through an
# array doing regular expression matches, which results in a lot of
# object creations. Most of the time it returns a +nil+ match. As the
# match result is always the same given a +method_name+, this cache is
# used to alleviate the GC, which ultimately also speeds up the app
# significantly (in our case our test suite finishes 10% faster with
# this cache).
#
# source://activemodel//lib/active_model/attribute_methods.rb#370
def attribute_method_matchers_cache; end
# source://activemodel//lib/active_model/attribute_methods.rb#374
def attribute_method_matchers_matching(method_name); end
# Define a method `name` in `mod` that dispatches to `send`
# using the given `extra` args. This falls back on `send`
# if the called name cannot be compiled.
#
# source://activemodel//lib/active_model/attribute_methods.rb#383
def define_proxy_call(code_generator, name, target, parameters, *call_args, namespace:); end
# source://activemodel//lib/active_model/attribute_methods.rb#353
def generated_attribute_methods; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_methods.rb#357
def instance_method_already_implemented?(method_name); end
end
# source://activemodel//lib/active_model/attribute_methods.rb#409
class ActiveModel::AttributeMethods::ClassMethods::AttributeMethodMatcher
# @return [AttributeMethodMatcher] a new instance of AttributeMethodMatcher
#
# source://activemodel//lib/active_model/attribute_methods.rb#414
def initialize(prefix: T.unsafe(nil), suffix: T.unsafe(nil), parameters: T.unsafe(nil)); end
# source://activemodel//lib/active_model/attribute_methods.rb#423
def match(method_name); end
# source://activemodel//lib/active_model/attribute_methods.rb#429
def method_name(attr_name); end
# Returns the value of attribute parameters.
#
# source://activemodel//lib/active_model/attribute_methods.rb#410
def parameters; end
# Returns the value of attribute prefix.
#
# source://activemodel//lib/active_model/attribute_methods.rb#410
def prefix; end
# Returns the value of attribute suffix.
#
# source://activemodel//lib/active_model/attribute_methods.rb#410
def suffix; end
# Returns the value of attribute target.
#
# source://activemodel//lib/active_model/attribute_methods.rb#410
def target; end
end
# source://activemodel//lib/active_model/attribute_methods.rb#412
class ActiveModel::AttributeMethods::ClassMethods::AttributeMethodMatcher::AttributeMethodMatch < ::Struct
# Returns the value of attribute attr_name
#
# @return [Object] the current value of attr_name
def attr_name; end
# Sets the attribute attr_name
#
# @param value [Object] the value to set the attribute attr_name to.
# @return [Object] the newly set value
#
# source://activemodel//lib/active_model/attribute_methods.rb#412
def attr_name=(_); end
# Returns the value of attribute target
#
# @return [Object] the current value of target
def target; end
# Sets the attribute target
#
# @param value [Object] the value to set the attribute target to.
# @return [Object] the newly set value
#
# source://activemodel//lib/active_model/attribute_methods.rb#412
def target=(_); end
class << self
def [](*_arg0); end
def inspect; end
def members; end
def new(*_arg0); end
end
end
# source://activemodel//lib/active_model/attribute_methods.rb#69
ActiveModel::AttributeMethods::FORWARD_PARAMETERS = T.let(T.unsafe(nil), String)
# source://activemodel//lib/active_model/attribute_methods.rb#67
ActiveModel::AttributeMethods::NAME_COMPILABLE_REGEXP = T.let(T.unsafe(nil), Regexp)
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#7
class ActiveModel::AttributeMutationTracker
# @return [AttributeMutationTracker] a new instance of AttributeMutationTracker
#
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#10
def initialize(attributes); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#40
def any_changes?; end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#34
def change_to_attribute(attr_name); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#44
def changed?(attr_name, from: T.unsafe(nil), to: T.unsafe(nil)); end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#14
def changed_attribute_names; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#50
def changed_in_place?(attr_name); end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#18
def changed_values; end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#26
def changes; end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#63
def force_change(attr_name); end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#54
def forget_change(attr_name); end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#59
def original_value(attr_name); end
private
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#74
def attr_names; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#78
def attribute_changed?(attr_name); end
# Returns the value of attribute attributes.
#
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#68
def attributes; end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#82
def fetch_value(attr_name); end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#70
def forced_changes; end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#86
def type_cast(attr_name, value); end
end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#8
ActiveModel::AttributeMutationTracker::OPTION_NOT_GIVEN = T.let(T.unsafe(nil), Object)
# source://activemodel//lib/active_model/attribute_set/builder.rb#6
class ActiveModel::AttributeSet
# @return [AttributeSet] a new instance of AttributeSet
#
# source://activemodel//lib/active_model/attribute_set.rb#12
def initialize(attributes); end
# source://activemodel//lib/active_model/attribute_set.rb#97
def ==(other); end
# source://activemodel//lib/active_model/attribute_set.rb#16
def [](name); end
# source://activemodel//lib/active_model/attribute_set.rb#20
def []=(name, value); end
# source://activemodel//lib/active_model/attribute_set.rb#88
def accessed; end
# source://activemodel//lib/active_model/attribute_set.rb#68
def deep_dup; end
# source://activemodel//lib/active_model/attribute_set.rb#10
def each_value(*_arg0, &_arg1); end
# source://activemodel//lib/active_model/attribute_set.rb#10
def except(*_arg0, &_arg1); end
# source://activemodel//lib/active_model/attribute_set.rb#10
def fetch(*_arg0, &_arg1); end
# source://activemodel//lib/active_model/attribute_set.rb#45
def fetch_value(name, &block); end
# source://activemodel//lib/active_model/attribute_set.rb#63
def freeze; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_set.rb#37
def key?(name); end
# source://activemodel//lib/active_model/attribute_set.rb#41
def keys; end
# source://activemodel//lib/active_model/attribute_set.rb#92
def map(&block); end
# source://activemodel//lib/active_model/attribute_set.rb#82
def reset(key); end
# source://activemodel//lib/active_model/attribute_set.rb#32
def to_h; end
# source://activemodel//lib/active_model/attribute_set.rb#32
def to_hash; end
# source://activemodel//lib/active_model/attribute_set.rb#24
def values_before_type_cast; end
# source://activemodel//lib/active_model/attribute_set.rb#28
def values_for_database; end
# source://activemodel//lib/active_model/attribute_set.rb#59
def write_cast_value(name, value); end
# source://activemodel//lib/active_model/attribute_set.rb#49
def write_from_database(name, value); end
# @raise [FrozenError]
#
# source://activemodel//lib/active_model/attribute_set.rb#53
def write_from_user(name, value); end
protected
# Returns the value of attribute attributes.
#
# source://activemodel//lib/active_model/attribute_set.rb#102
def attributes; end
private
# source://activemodel//lib/active_model/attribute_set.rb#105
def default_attribute(name); end
# source://activemodel//lib/active_model/attribute_set.rb#77
def initialize_clone(_); end
# source://activemodel//lib/active_model/attribute_set.rb#72
def initialize_dup(_); end
end
# source://activemodel//lib/active_model/attribute_set/builder.rb#7
class ActiveModel::AttributeSet::Builder
# @return [Builder] a new instance of Builder
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#10
def initialize(types, default_attributes = T.unsafe(nil)); end
# source://activemodel//lib/active_model/attribute_set/builder.rb#15
def build_from_database(values = T.unsafe(nil), additional_types = T.unsafe(nil)); end
# Returns the value of attribute default_attributes.
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#8
def default_attributes; end
# Returns the value of attribute types.
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#8
def types; end
end
# Attempts to do more intelligent YAML dumping of an
# ActiveModel::AttributeSet to reduce the size of the resulting string
#
# source://activemodel//lib/active_model/attribute_set/yaml_encoder.rb#7
class ActiveModel::AttributeSet::YAMLEncoder
# @return [YAMLEncoder] a new instance of YAMLEncoder
#
# source://activemodel//lib/active_model/attribute_set/yaml_encoder.rb#8
def initialize(default_types); end
# source://activemodel//lib/active_model/attribute_set/yaml_encoder.rb#22
def decode(coder); end
# source://activemodel//lib/active_model/attribute_set/yaml_encoder.rb#12
def encode(attribute_set, coder); end
private
# Returns the value of attribute default_types.
#
# source://activemodel//lib/active_model/attribute_set/yaml_encoder.rb#37
def default_types; end
end
# source://activemodel//lib/active_model/attributes.rb#7
module ActiveModel::Attributes
extend ::ActiveSupport::Concern
include GeneratedInstanceMethods
include ::ActiveModel::AttributeMethods
mixes_in_class_methods GeneratedClassMethods
mixes_in_class_methods ::ActiveModel::AttributeMethods::ClassMethods
mixes_in_class_methods ::ActiveModel::Attributes::ClassMethods
# source://activemodel//lib/active_model/attributes.rb#78
def initialize(*_arg0); end
# Returns an array of attribute names as strings
#
# class Person
# include ActiveModel::Attributes
#
# attribute :name, :string
# attribute :age, :integer
# end
#
# person = Person.new
# person.attribute_names
# # => ["name", "age"]
#
# source://activemodel//lib/active_model/attributes.rb#116
def attribute_names; end
# Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
#
# class Person
# include ActiveModel::Attributes
#
# attribute :name, :string
# attribute :age, :integer
# end
#
# person = Person.new(name: 'Francesco', age: 22)
# person.attributes
# # => {"name"=>"Francesco", "age"=>22}
#
# source://activemodel//lib/active_model/attributes.rb#100
def attributes; end
# source://activemodel//lib/active_model/attributes.rb#120
def freeze; end
private
# source://activemodel//lib/active_model/attributes.rb#126
def _write_attribute(attr_name, value); end
# source://activemodel//lib/active_model/attributes.rb#131
def attribute(attr_name); end
# source://activemodel//lib/active_model/attributes.rb#126
def attribute=(attr_name, value); end
# source://activemodel//lib/active_model/attributes.rb#83
def initialize_dup(other); end
module GeneratedClassMethods
def _default_attributes; end
def _default_attributes=(value); end
def _default_attributes?; end
def attribute_aliases; end
def attribute_aliases=(value); end
def attribute_aliases?; end
def attribute_method_matchers; end
def attribute_method_matchers=(value); end
def attribute_method_matchers?; end
def attribute_types; end
def attribute_types=(value); end
def attribute_types?; end
end
module GeneratedInstanceMethods
def attribute_aliases; end
def attribute_aliases?; end
def attribute_method_matchers; end
def attribute_method_matchers?; end
end
end
# source://activemodel//lib/active_model/attributes.rb#18
module ActiveModel::Attributes::ClassMethods
# source://activemodel//lib/active_model/attributes.rb#19
def attribute(name, cast_type = T.unsafe(nil), default: T.unsafe(nil), **options); end
# Returns an array of attribute names as strings
#
# class Person
# include ActiveModel::Attributes
#
# attribute :name, :string
# attribute :age, :integer
# end
#
# Person.attribute_names
# # => ["name", "age"]
#
# source://activemodel//lib/active_model/attributes.rb#41
def attribute_names; end
private
# source://activemodel//lib/active_model/attributes.rb#62
def define_default_attribute(name, value, type); end
# source://activemodel//lib/active_model/attributes.rb#46
def define_method_attribute=(name, owner:); end
end
# source://activemodel//lib/active_model/attributes.rb#59
ActiveModel::Attributes::ClassMethods::NO_DEFAULT_PROVIDED = T.let(T.unsafe(nil), Object)
# +BlockValidator+ is a special +EachValidator+ which receives a block on initialization
# and call this block for each attribute being validated. +validates_each+ uses this validator.
#
# source://activemodel//lib/active_model/validator.rb#177
class ActiveModel::BlockValidator < ::ActiveModel::EachValidator
# @return [BlockValidator] a new instance of BlockValidator
#
# source://activemodel//lib/active_model/validator.rb#178
def initialize(options, &block); end
private
# source://activemodel//lib/active_model/validator.rb#184
def validate_each(record, attribute, value); end
end
# == Active \Model \Callbacks
#
# Provides an interface for any class to have Active Record like callbacks.
#
# Like the Active Record methods, the callback chain is aborted as soon as
# one of the methods throws +:abort+.
#
# First, extend ActiveModel::Callbacks from the class you are creating:
#
# class MyModel
# extend ActiveModel::Callbacks
# end
#
# Then define a list of methods that you want callbacks attached to:
#
# define_model_callbacks :create, :update
#
# This will provide all three standard callbacks (before, around and after)
# for both the :create and :update methods. To implement,
# you need to wrap the methods you want callbacks on in a block so that the
# callbacks get a chance to fire:
#
# def create
# run_callbacks :create do
# # Your create action methods here
# end
# end
#
# Then in your class, you can use the +before_create+, +after_create+, and
# +around_create+ methods, just as you would in an Active Record model.
#
# before_create :action_before_create
#
# def action_before_create
# # Your code here
# end
#
# When defining an around callback remember to yield to the block, otherwise
# it won't be executed:
#
# around_create :log_status
#
# def log_status
# puts 'going to call the block...'
# yield
# puts 'block successfully called.'
# end
#
# You can choose to have only specific callbacks by passing a hash to the
# +define_model_callbacks+ method.
#
# define_model_callbacks :create, only: [:after, :before]
#
# Would only create the +after_create+ and +before_create+ callback methods in
# your class.
#
# NOTE: Calling the same callback multiple times will overwrite previous callback definitions.
#
# source://activemodel//lib/active_model/callbacks.rb#65
module ActiveModel::Callbacks
# define_model_callbacks accepts the same options +define_callbacks+ does,
# in case you want to overwrite a default. Besides that, it also accepts an
# :only option, where you can choose if you want all types (before,
# around or after) or just some.
#
# define_model_callbacks :initialize, only: :after
#
# Note, the only: hash will apply to all callbacks defined
# on that method call. To get around this you can call the define_model_callbacks
# method as many times as you need.
#
# define_model_callbacks :create, only: :after
# define_model_callbacks :update, only: :before
# define_model_callbacks :destroy, only: :around
#
# Would create +after_create+, +before_update+, and +around_destroy+ methods
# only.
#
# You can pass in a class to before_, after_ and around_,
# in which case the callback will call that class's _ method
# passing the object that the callback is being called on.
#
# class MyModel
# extend ActiveModel::Callbacks
# define_model_callbacks :create
#
# before_create AnotherClass
# end
#
# class AnotherClass
# def self.before_create( obj )
# # obj is the MyModel instance that the callback is being called on
# end
# end
#
# NOTE: +method_name+ passed to define_model_callbacks must not end with
# !, ? or =.
#
# source://activemodel//lib/active_model/callbacks.rb#109
def define_model_callbacks(*callbacks); end
private
# source://activemodel//lib/active_model/callbacks.rb#143
def _define_after_model_callback(klass, callback); end
# source://activemodel//lib/active_model/callbacks.rb#136
def _define_around_model_callback(klass, callback); end
# source://activemodel//lib/active_model/callbacks.rb#129
def _define_before_model_callback(klass, callback); end
class << self
# source://activemodel//lib/active_model/callbacks.rb#66
def extended(base); end
end
end
# == Active \Model \Conversion
#
# Handles default conversions: to_model, to_key, to_param, and to_partial_path.
#
# Let's take for example this non-persisted object.
#
# class ContactMessage
# include ActiveModel::Conversion
#
# # ContactMessage are never persisted in the DB
# def persisted?
# false
# end
# end
#
# cm = ContactMessage.new
# cm.to_model == cm # => true
# cm.to_key # => nil
# cm.to_param # => nil
# cm.to_partial_path # => "contact_messages/contact_message"
#
# source://activemodel//lib/active_model/conversion.rb#24
module ActiveModel::Conversion
extend ::ActiveSupport::Concern
mixes_in_class_methods ::ActiveModel::Conversion::ClassMethods
# Returns an Array of all key attributes if any of the attributes is set, whether or not
# the object is persisted. Returns +nil+ if there are no key attributes.
#
# class Person
# include ActiveModel::Conversion
# attr_accessor :id
#
# def initialize(id)
# @id = id
# end
# end
#
# person = Person.new(1)
# person.to_key # => [1]
#
# source://activemodel//lib/active_model/conversion.rb#59
def to_key; end
# If your object is already designed to implement all of the \Active \Model
# you can use the default :to_model implementation, which simply
# returns +self+.
#
# class Person
# include ActiveModel::Conversion
# end
#
# person = Person.new
# person.to_model == person # => true
#
# If your model does not act like an \Active \Model object, then you should
# define :to_model yourself returning a proxy object that wraps
# your object with \Active \Model compliant methods.
#
# source://activemodel//lib/active_model/conversion.rb#41
def to_model; end
# Returns a +string+ representing the object's key suitable for use in URLs,
# or +nil+ if persisted? is +false+.
#
# class Person
# include ActiveModel::Conversion
# attr_accessor :id
#
# def initialize(id)
# @id = id
# end
#
# def persisted?
# true
# end
# end
#
# person = Person.new(1)
# person.to_param # => "1"
#
# source://activemodel//lib/active_model/conversion.rb#82
def to_param; end
# Returns a +string+ identifying the path associated with the object.
# ActionPack uses this to find a suitable partial to represent the object.
#
# class Person
# include ActiveModel::Conversion
# end
#
# person = Person.new
# person.to_partial_path # => "people/person"
#
# source://activemodel//lib/active_model/conversion.rb#95
def to_partial_path; end
end
# source://activemodel//lib/active_model/conversion.rb#99
module ActiveModel::Conversion::ClassMethods
# Provide a class level cache for #to_partial_path. This is an
# internal method and should not be accessed directly.
#
# source://activemodel//lib/active_model/conversion.rb#102
def _to_partial_path; end
end
# == Active \Model \Dirty
#
# Provides a way to track changes in your object in the same way as
# Active Record does.
#
# The requirements for implementing ActiveModel::Dirty are:
#
# * include ActiveModel::Dirty in your object.
# * Call define_attribute_methods passing each method you want to
# track.
# * Call [attr_name]_will_change! before each change to the tracked
# attribute.
# * Call changes_applied after the changes are persisted.
# * Call clear_changes_information when you want to reset the changes
# information.
# * Call restore_attributes when you want to restore previous data.
#
# A minimal implementation could be:
#
# class Person
# include ActiveModel::Dirty
#
# define_attribute_methods :name
#
# def initialize
# @name = nil
# end
#
# def name
# @name
# end
#
# def name=(val)
# name_will_change! unless val == @name
# @name = val
# end
#
# def save
# # do persistence work
#
# changes_applied
# end
#
# def reload!
# # get the values from the persistence layer
#
# clear_changes_information
# end
#
# def rollback!
# restore_attributes
# end
# end
#
# A newly instantiated +Person+ object is unchanged:
#
# person = Person.new
# person.changed? # => false
#
# Change the name:
#
# person.name = 'Bob'
# person.changed? # => true
# person.name_changed? # => true
# person.name_changed?(from: nil, to: "Bob") # => true
# person.name_was # => nil
# person.name_change # => [nil, "Bob"]
# person.name = 'Bill'
# person.name_change # => [nil, "Bill"]
#
# Save the changes:
#
# person.save
# person.changed? # => false
# person.name_changed? # => false
#
# Reset the changes:
#
# person.previous_changes # => {"name" => [nil, "Bill"]}
# person.name_previously_changed? # => true
# person.name_previously_changed?(from: nil, to: "Bill") # => true
# person.name_previous_change # => [nil, "Bill"]
# person.name_previously_was # => nil
# person.reload!
# person.previous_changes # => {}
#
# Rollback the changes:
#
# person.name = "Uncle Bob"
# person.rollback!
# person.name # => "Bill"
# person.name_changed? # => false
#
# Assigning the same value leaves the attribute unchanged:
#
# person.name = 'Bill'
# person.name_changed? # => false
# person.name_change # => nil
#
# Which attributes have changed?
#
# person.name = 'Bob'
# person.changed # => ["name"]
# person.changes # => {"name" => ["Bill", "Bob"]}
#
# If an attribute is modified in-place then make use of
# [attribute_name]_will_change! to mark that the attribute is changing.
# Otherwise \Active \Model can't track changes to in-place attributes. Note
# that Active Record can detect in-place modifications automatically. You do
# not need to call [attribute_name]_will_change! on Active Record models.
#
# person.name_will_change!
# person.name_change # => ["Bill", "Bill"]
# person.name << 'y'
# person.name_change # => ["Bill", "Billy"]
#
# source://activemodel//lib/active_model/dirty.rb#121
module ActiveModel::Dirty
extend ::ActiveSupport::Concern
include GeneratedInstanceMethods
include ::ActiveModel::AttributeMethods
mixes_in_class_methods GeneratedClassMethods
mixes_in_class_methods ::ActiveModel::AttributeMethods::ClassMethods
# source://activemodel//lib/active_model/dirty.rb#143
def as_json(options = T.unsafe(nil)); end
# Dispatch target for *_changed? attribute methods.
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/dirty.rb#178
def attribute_changed?(attr_name, **options); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/dirty.rb#245
def attribute_changed_in_place?(attr_name); end
# Dispatch target for *_previously_changed? attribute methods.
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/dirty.rb#188
def attribute_previously_changed?(attr_name, **options); end
# Dispatch target for *_previously_was attribute methods.
#
# source://activemodel//lib/active_model/dirty.rb#193
def attribute_previously_was(attr_name); end
# Dispatch target for *_was attribute methods.
#
# source://activemodel//lib/active_model/dirty.rb#183
def attribute_was(attr_name); end
# Returns an array with the name of the attributes with unsaved changes.
#
# person.changed # => []
# person.name = 'bob'
# person.changed # => ["name"]
#
# source://activemodel//lib/active_model/dirty.rb#173
def changed; end
# Returns +true+ if any of the attributes has unsaved changes, +false+ otherwise.
#
# person.changed? # => false
# person.name = 'bob'
# person.changed? # => true
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/dirty.rb#164
def changed?; end
# Returns a hash of the attributes with unsaved changes indicating their original
# values like attr => original value.
#
# person.name # => "bob"
# person.name = 'robert'
# person.changed_attributes # => {"name" => "bob"}
#
# source://activemodel//lib/active_model/dirty.rb#221
def changed_attributes; end
# Returns a hash of changed attributes indicating their original
# and new values like attr => [original value, new value].
#
# person.changes # => {}
# person.name = 'bob'
# person.changes # => { "name" => ["bill", "bob"] }
#
# source://activemodel//lib/active_model/dirty.rb#231
def changes; end
# Clears dirty data and moves +changes+ to +previous_changes+ and
# +mutations_from_database+ to +mutations_before_last_save+ respectively.
#
# source://activemodel//lib/active_model/dirty.rb#150
def changes_applied; end
# source://activemodel//lib/active_model/dirty.rb#209
def clear_attribute_changes(attr_names); end
# Clears all dirty data: current changes and previous changes.
#
# source://activemodel//lib/active_model/dirty.rb#203
def clear_changes_information; end
# Returns a hash of attributes that were changed before the model was saved.
#
# person.name # => "bob"
# person.name = 'robert'
# person.save
# person.previous_changes # => {"name" => ["bob", "robert"]}
#
# source://activemodel//lib/active_model/dirty.rb#241
def previous_changes; end
# Restore all previous data of the provided attributes.
#
# source://activemodel//lib/active_model/dirty.rb#198
def restore_attributes(attr_names = T.unsafe(nil)); end
private
# Dispatch target for *_change attribute methods.
#
# source://activemodel//lib/active_model/dirty.rb#271
def attribute_change(attr_name); end
# Dispatch target for *_previous_change attribute methods.
#
# source://activemodel//lib/active_model/dirty.rb#276
def attribute_previous_change(attr_name); end
# Dispatch target for *_will_change! attribute methods.
#
# source://activemodel//lib/active_model/dirty.rb#281
def attribute_will_change!(attr_name); end
# source://activemodel//lib/active_model/dirty.rb#250
def clear_attribute_change(attr_name); end
# source://activemodel//lib/active_model/dirty.rb#262
def forget_attribute_assignments; end
# source://activemodel//lib/active_model/dirty.rb#133
def initialize_dup(other); end
# source://activemodel//lib/active_model/dirty.rb#266
def mutations_before_last_save; end
# source://activemodel//lib/active_model/dirty.rb#254
def mutations_from_database; end
# Dispatch target for restore_*! attribute methods.
#
# source://activemodel//lib/active_model/dirty.rb#286
def restore_attribute!(attr_name); end
module GeneratedClassMethods
def attribute_aliases; end
def attribute_aliases=(value); end
def attribute_aliases?; end
def attribute_method_matchers; end
def attribute_method_matchers=(value); end
def attribute_method_matchers?; end
end
module GeneratedInstanceMethods
def attribute_aliases; end
def attribute_aliases?; end
def attribute_method_matchers; end
def attribute_method_matchers?; end
end
end
# +EachValidator+ is a validator which iterates through the attributes given
# in the options hash invoking the validate_each method passing in the
# record, attribute, and value.
#
# All \Active \Model validations are built on top of this validator.
#
# source://activemodel//lib/active_model/validator.rb#132
class ActiveModel::EachValidator < ::ActiveModel::Validator
# Returns a new validator instance. All options will be available via the
# +options+ reader, however the :attributes option will be removed
# and instead be made available through the +attributes+ reader.
#
# @raise [ArgumentError]
# @return [EachValidator] a new instance of EachValidator
#
# source://activemodel//lib/active_model/validator.rb#138
def initialize(options); end
# Returns the value of attribute attributes.
#
# source://activemodel//lib/active_model/validator.rb#133
def attributes; end
# Hook method that gets called by the initializer allowing verification
# that the arguments supplied are valid. You could for example raise an
# +ArgumentError+ when invalid options are supplied.
#
# source://activemodel//lib/active_model/validator.rb#166
def check_validity!; end
# Performs validation on the supplied record. By default this will call
# +validate_each+ to determine validity therefore subclasses should
# override +validate_each+ with validation logic.
#
# source://activemodel//lib/active_model/validator.rb#148
def validate(record); end
# Override this method in subclasses with the validation logic, adding
# errors to the records +errors+ array where necessary.
#
# @raise [NotImplementedError]
#
# source://activemodel//lib/active_model/validator.rb#159
def validate_each(record, attribute, value); end
private
# source://activemodel//lib/active_model/validator.rb#170
def prepare_value_for_validation(value, record, attr_name); end
end
# == Active \Model \Error
#
# Represents one single error
#
# source://activemodel//lib/active_model/error.rb#9
class ActiveModel::Error
# @return [Error] a new instance of Error
#
# source://activemodel//lib/active_model/error.rb#103
def initialize(base, attribute, type = T.unsafe(nil), **options); end
# source://activemodel//lib/active_model/error.rb#189
def ==(other); end
# The attribute of +base+ which the error belongs to
#
# source://activemodel//lib/active_model/error.rb#121
def attribute; end
# The object which the error belongs to
#
# source://activemodel//lib/active_model/error.rb#119
def base; end
# Returns the error details.
#
# error = ActiveModel::Error.new(person, :name, :too_short, count: 5)
# error.details
# # => { error: :too_short, count: 5 }
#
# source://activemodel//lib/active_model/error.rb#148
def detail; end
# Returns the error details.
#
# error = ActiveModel::Error.new(person, :name, :too_short, count: 5)
# error.details
# # => { error: :too_short, count: 5 }
#
# source://activemodel//lib/active_model/error.rb#148
def details; end
# source://activemodel//lib/active_model/error.rb#189
def eql?(other); end
# Returns the full error message.
#
# error = ActiveModel::Error.new(person, :name, :too_short, count: 5)
# error.full_message
# # => "Name is too short (minimum is 5 characters)"
#
# source://activemodel//lib/active_model/error.rb#158
def full_message; end
# source://activemodel//lib/active_model/error.rb#194
def hash; end
# source://activemodel//lib/active_model/error.rb#13
def i18n_customize_full_message; end
# source://activemodel//lib/active_model/error.rb#13
def i18n_customize_full_message=(_arg0); end
# source://activemodel//lib/active_model/error.rb#13
def i18n_customize_full_message?; end
# source://activemodel//lib/active_model/error.rb#198
def inspect; end
# See if error matches provided +attribute+, +type+, and +options+.
#
# Omitted params are not checked for a match.
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/error.rb#165
def match?(attribute, type = T.unsafe(nil), **options); end
# Returns the error message.
#
# error = ActiveModel::Error.new(person, :name, :too_short, count: 5)
# error.message
# # => "is too short (minimum is 5 characters)"
#
# source://activemodel//lib/active_model/error.rb#134
def message; end
# The options provided when calling +errors#add+
#
# source://activemodel//lib/active_model/error.rb#127
def options; end
# The raw value provided as the second parameter when calling +errors#add+
#
# source://activemodel//lib/active_model/error.rb#125
def raw_type; end
# See if error matches provided +attribute+, +type+, and +options+ exactly.
#
# All params must be equal to Error's own attributes to be considered a
# strict match.
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/error.rb#183
def strict_match?(attribute, type, **options); end
# The type of error, defaults to +:invalid+ unless specified
#
# source://activemodel//lib/active_model/error.rb#123
def type; end
protected
# source://activemodel//lib/active_model/error.rb#203
def attributes_for_hash; end
private
# source://activemodel//lib/active_model/error.rb#111
def initialize_dup(other); end
class << self
# source://activemodel//lib/active_model/error.rb#15
def full_message(attribute, message, base); end
# source://activemodel//lib/active_model/error.rb#64
def generate_message(attribute, type, base, options); end
# source://activemodel//lib/active_model/error.rb#13
def i18n_customize_full_message; end
# source://activemodel//lib/active_model/error.rb#13
def i18n_customize_full_message=(value); end
# source://activemodel//lib/active_model/error.rb#13
def i18n_customize_full_message?; end
end
end
# source://activemodel//lib/active_model/error.rb#10
ActiveModel::Error::CALLBACKS_OPTIONS = T.let(T.unsafe(nil), Array)
# source://activemodel//lib/active_model/error.rb#11
ActiveModel::Error::MESSAGE_OPTIONS = T.let(T.unsafe(nil), Array)
# == Active \Model \Errors
#
# Provides error related functionalities you can include in your object
# for handling error messages and interacting with Action View helpers.
#
# A minimal implementation could be:
#
# class Person
# # Required dependency for ActiveModel::Errors
# extend ActiveModel::Naming
#
# def initialize
# @errors = ActiveModel::Errors.new(self)
# end
#
# attr_accessor :name
# attr_reader :errors
#
# def validate!
# errors.add(:name, :blank, message: "cannot be nil") if name.nil?
# end
#
# # The following methods are needed to be minimally implemented
#
# def read_attribute_for_validation(attr)
# send(attr)
# end
#
# def self.human_attribute_name(attr, options = {})
# attr
# end
#
# def self.lookup_ancestors
# [self]
# end
# end
#
# The last three methods are required in your object for +Errors+ to be
# able to generate error messages correctly and also handle multiple
# languages. Of course, if you extend your object with ActiveModel::Translation
# you will not need to implement the last two. Likewise, using
# ActiveModel::Validations will handle the validation related methods
# for you.
#
# The above allows you to do:
#
# person = Person.new
# person.validate! # => ["cannot be nil"]
# person.errors.full_messages # => ["name cannot be nil"]
# # etc..
#
# source://activemodel//lib/active_model/errors.rb#62
class ActiveModel::Errors
include ::Enumerable
extend ::Forwardable
# Pass in the instance of the object that is using the errors object.
#
# class Person
# def initialize
# @errors = ActiveModel::Errors.new(self)
# end
# end
#
# @return [Errors] a new instance of Errors
#
# source://activemodel//lib/active_model/errors.rb#92
def initialize(base); end
# When passed a symbol or a name of a method, returns an array of errors
# for the method.
#
# person.errors[:name] # => ["cannot be nil"]
# person.errors['name'] # => ["cannot be nil"]
#
# source://activemodel//lib/active_model/errors.rb#204
def [](attribute); end
# Adds a new error of +type+ on +attribute+.
# More than one error can be added to the same +attribute+.
# If no +type+ is supplied, :invalid is assumed.
#
# person.errors.add(:name)
# # Adds <#ActiveModel::Error attribute=name, type=invalid>
# person.errors.add(:name, :not_implemented, message: "must be implemented")
# # Adds <#ActiveModel::Error attribute=name, type=not_implemented,
# options={:message=>"must be implemented"}>
#
# person.errors.messages
# # => {:name=>["is invalid", "must be implemented"]}
#
# If +type+ is a string, it will be used as error message.
#
# If +type+ is a symbol, it will be translated using the appropriate
# scope (see +generate_message+).
#
# person.errors.add(:name, :blank)
# person.errors.messages
# # => {:name=>["can't be blank"]}
#
# person.errors.add(:name, :too_long, { count: 25 })
# person.errors.messages
# # => ["is too long (maximum is 25 characters)"]
#
# If +type+ is a proc, it will be called, allowing for things like
# Time.now to be used within an error.
#
# If the :strict option is set to +true+, it will raise
# ActiveModel::StrictValidationFailed instead of adding the error.
# :strict option can also be set to any other exception.
#
# person.errors.add(:name, :invalid, strict: true)
# # => ActiveModel::StrictValidationFailed: Name is invalid
# person.errors.add(:name, :invalid, strict: NameIsInvalid)
# # => NameIsInvalid: Name is invalid
#
# person.errors.messages # => {}
#
# +attribute+ should be set to :base if the error is not
# directly associated with a single attribute.
#
# person.errors.add(:base, :name_or_email_blank,
# message: "either name or email must be present")
# person.errors.messages
# # => {:base=>["either name or email must be present"]}
# person.errors.details
# # => {:base=>[{error: :name_or_email_blank}]}
#
# source://activemodel//lib/active_model/errors.rb#317
def add(attribute, type = T.unsafe(nil), **options); end
# Returns +true+ if an error matches provided +attribute+ and +type+,
# or +false+ otherwise. +type+ is treated the same as for +add+.
#
# person.errors.add :name, :blank
# person.errors.added? :name, :blank # => true
# person.errors.added? :name, "can't be blank" # => true
#
# If the error requires options, then it returns +true+ with
# the correct options, or +false+ with incorrect or missing options.
#
# person.errors.add :name, :too_long, { count: 25 }
# person.errors.added? :name, :too_long, count: 25 # => true
# person.errors.added? :name, "is too long (maximum is 25 characters)" # => true
# person.errors.added? :name, :too_long, count: 24 # => false
# person.errors.added? :name, :too_long # => false
# person.errors.added? :name, "is too long" # => false
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/errors.rb#347
def added?(attribute, type = T.unsafe(nil), options = T.unsafe(nil)); end
# Returns a Hash that can be used as the JSON representation for this
# object. You can pass the :full_messages option. This determines
# if the json object should contain full messages or not (false by default).
#
# person.errors.as_json # => {:name=>["cannot be nil"]}
# person.errors.as_json(full_messages: true) # => {:name=>["name cannot be nil"]}
#
# source://activemodel//lib/active_model/errors.rb#222
def as_json(options = T.unsafe(nil)); end
# Returns all error attribute names
#
# person.errors.messages # => {:name=>["cannot be nil", "must be specified"]}
# person.errors.attribute_names # => [:name]
#
# source://activemodel//lib/active_model/errors.rb#212
def attribute_names; end
# source://forwardable/1.3.2/forwardable.rb#229
def clear(*args, &block); end
# Copies the errors from other.
# For copying errors but keep @base as is.
#
# ==== Parameters
#
# * +other+ - The ActiveModel::Errors instance.
#
# ==== Examples
#
# person.errors.copy!(other)
#
# source://activemodel//lib/active_model/errors.rb#113
def copy!(other); end
# Delete messages for +key+. Returns the deleted messages.
#
# person.errors[:name] # => ["cannot be nil"]
# person.errors.delete(:name) # => ["cannot be nil"]
# person.errors[:name] # => []
#
# source://activemodel//lib/active_model/errors.rb#190
def delete(attribute, type = T.unsafe(nil), **options); end
# Returns a Hash of attributes with an array of their error details.
#
# source://activemodel//lib/active_model/errors.rb#251
def details; end
# source://forwardable/1.3.2/forwardable.rb#229
def each(*args, &block); end
# source://forwardable/1.3.2/forwardable.rb#229
def empty?(*args, &block); end
# The actual array of +Error+ objects
# This method is aliased to objects.
#
# source://activemodel//lib/active_model/errors.rb#82
def errors; end
# Returns a full message for a given attribute.
#
# person.errors.full_message(:name, 'is invalid') # => "Name is invalid"
#
# source://activemodel//lib/active_model/errors.rb#426
def full_message(attribute, message); end
# Returns all the full error messages in an array.
#
# class Person
# validates_presence_of :name, :address, :email
# validates_length_of :name, in: 5..30
# end
#
# person = Person.create(address: '123 First St.')
# person.errors.full_messages
# # => ["Name is too short (minimum is 5 characters)", "Name can't be blank", "Email can't be blank"]
#
# source://activemodel//lib/active_model/errors.rb#390
def full_messages; end
# Returns all the full error messages for a given attribute in an array.
#
# class Person
# validates_presence_of :name, :email
# validates_length_of :name, in: 5..30
# end
#
# person = Person.create()
# person.errors.full_messages_for(:name)
# # => ["Name is too short (minimum is 5 characters)", "Name can't be blank"]
#
# source://activemodel//lib/active_model/errors.rb#405
def full_messages_for(attribute); end
# Translates an error message in its default scope
# (activemodel.errors.messages).
#
# Error messages are first looked up in activemodel.errors.models.MODEL.attributes.ATTRIBUTE.MESSAGE,
# if it's not there, it's looked up in activemodel.errors.models.MODEL.MESSAGE and if
# that is not there also, it returns the translation of the default message
# (e.g. activemodel.errors.messages.MESSAGE). The translated model
# name, translated attribute name, and the value are available for
# interpolation.
#
# When using inheritance in your models, it will check all the inherited
# models too, but only if the model itself hasn't been found. Say you have
# class Admin < User; end and you wanted the translation for
# the :blank error message for the title attribute,
# it looks for these translations:
#
# * activemodel.errors.models.admin.attributes.title.blank
# * activemodel.errors.models.admin.blank
# * activemodel.errors.models.user.attributes.title.blank
# * activemodel.errors.models.user.blank
# * any default you provided through the +options+ hash (in the activemodel.errors scope)
# * activemodel.errors.messages.blank
# * errors.attributes.title.blank
# * errors.messages.blank
#
# source://activemodel//lib/active_model/errors.rb#454
def generate_message(attribute, type = T.unsafe(nil), options = T.unsafe(nil)); end
# Returns a Hash of attributes with an array of their Error objects.
#
# person.errors.group_by_attribute
# # => {:name=>[<#ActiveModel::Error>, <#ActiveModel::Error>]}
#
# source://activemodel//lib/active_model/errors.rb#264
def group_by_attribute; end
# Returns +true+ if the error messages include an error for the given key
# +attribute+, +false+ otherwise.
#
# person.errors.messages # => {:name=>["cannot be nil"]}
# person.errors.include?(:name) # => true
# person.errors.include?(:age) # => false
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/errors.rb#177
def has_key?(attribute); end
# Imports one error.
# Imported errors are wrapped as a NestedError,
# providing access to original error object.
# If attribute or type needs to be overridden, use +override_options+.
#
# ==== Options
#
# * +:attribute+ - Override the attribute the error belongs to.
# * +:type+ - Override type of the error.
#
# source://activemodel//lib/active_model/errors.rb#129
def import(error, override_options = T.unsafe(nil)); end
# Returns +true+ if the error messages include an error for the given key
# +attribute+, +false+ otherwise.
#
# person.errors.messages # => {:name=>["cannot be nil"]}
# person.errors.include?(:name) # => true
# person.errors.include?(:age) # => false
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/errors.rb#177
def include?(attribute); end
# source://activemodel//lib/active_model/errors.rb#458
def inspect; end
# Returns +true+ if the error messages include an error for the given key
# +attribute+, +false+ otherwise.
#
# person.errors.messages # => {:name=>["cannot be nil"]}
# person.errors.include?(:name) # => true
# person.errors.include?(:age) # => false
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/errors.rb#177
def key?(attribute); end
# Merges the errors from other,
# each Error wrapped as NestedError.
#
# ==== Parameters
#
# * +other+ - The ActiveModel::Errors instance.
#
# ==== Examples
#
# person.errors.merge!(other)
#
# source://activemodel//lib/active_model/errors.rb#149
def merge!(other); end
# Returns a Hash of attributes with an array of their error messages.
#
# source://activemodel//lib/active_model/errors.rb#243
def messages; end
# Returns all the error messages for a given attribute in an array.
#
# class Person
# validates_presence_of :name, :email
# validates_length_of :name, in: 5..30
# end
#
# person = Person.create()
# person.errors.messages_for(:name)
# # => ["is too short (minimum is 5 characters)", "can't be blank"]
#
# source://activemodel//lib/active_model/errors.rb#419
def messages_for(attribute); end
# The actual array of +Error+ objects
# This method is aliased to objects.
#
# source://activemodel//lib/active_model/errors.rb#82
def objects; end
# Returns +true+ if an error on the attribute with the given type is
# present, or +false+ otherwise. +type+ is treated the same as for +add+.
#
# person.errors.add :age
# person.errors.add :name, :too_long, { count: 25 }
# person.errors.of_kind? :age # => true
# person.errors.of_kind? :name # => false
# person.errors.of_kind? :name, :too_long # => true
# person.errors.of_kind? :name, "is too long (maximum is 25 characters)" # => true
# person.errors.of_kind? :name, :not_too_long # => false
# person.errors.of_kind? :name, "is too long" # => false
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/errors.rb#370
def of_kind?(attribute, type = T.unsafe(nil)); end
# source://forwardable/1.3.2/forwardable.rb#229
def size(*args, &block); end
# Returns all the full error messages in an array.
#
# class Person
# validates_presence_of :name, :address, :email
# validates_length_of :name, in: 5..30
# end
#
# person = Person.create(address: '123 First St.')
# person.errors.full_messages
# # => ["Name is too short (minimum is 5 characters)", "Name can't be blank", "Email can't be blank"]
#
# source://activemodel//lib/active_model/errors.rb#390
def to_a; end
# Returns a Hash of attributes with their error messages. If +full_messages+
# is +true+, it will contain full messages (see +full_message+).
#
# person.errors.to_hash # => {:name=>["cannot be nil"]}
# person.errors.to_hash(true) # => {:name=>["name cannot be nil"]}
#
# source://activemodel//lib/active_model/errors.rb#231
def to_hash(full_messages = T.unsafe(nil)); end
# source://forwardable/1.3.2/forwardable.rb#229
def uniq!(*args, &block); end
# Search for errors matching +attribute+, +type+, or +options+.
#
# Only supplied params will be matched.
#
# person.errors.where(:name) # => all name errors.
# person.errors.where(:name, :too_short) # => all name errors being too short
# person.errors.where(:name, :too_short, minimum: 2) # => all name errors being too short and minimum is 2
#
# source://activemodel//lib/active_model/errors.rb#164
def where(attribute, type = T.unsafe(nil), **options); end
private
# source://activemodel//lib/active_model/errors.rb#97
def initialize_dup(other); end
# source://activemodel//lib/active_model/errors.rb#465
def normalize_arguments(attribute, type, **options); end
end
# source://activemodel//lib/active_model/errors.rb#240
ActiveModel::Errors::EMPTY_ARRAY = T.let(T.unsafe(nil), Array)
# Raised when forbidden attributes are used for mass assignment.
#
# class Person < ActiveRecord::Base
# end
#
# params = ActionController::Parameters.new(name: 'Bob')
# Person.new(params)
# # => ActiveModel::ForbiddenAttributesError
#
# params.permit!
# Person.new(params)
# # => #
#
# source://activemodel//lib/active_model/forbidden_attributes_protection.rb#16
class ActiveModel::ForbiddenAttributesError < ::StandardError; end
# source://activemodel//lib/active_model/forbidden_attributes_protection.rb#19
module ActiveModel::ForbiddenAttributesProtection
private
# source://activemodel//lib/active_model/forbidden_attributes_protection.rb#21
def sanitize_for_mass_assignment(attributes); end
# source://activemodel//lib/active_model/forbidden_attributes_protection.rb#21
def sanitize_forbidden_attributes(attributes); end
end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#91
class ActiveModel::ForcedMutationTracker < ::ActiveModel::AttributeMutationTracker
# @return [ForcedMutationTracker] a new instance of ForcedMutationTracker
#
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#92
def initialize(attributes); end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#101
def change_to_attribute(attr_name); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#97
def changed_in_place?(attr_name); end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#125
def finalize_changes; end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#121
def force_change(attr_name); end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#109
def forget_change(attr_name); end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#113
def original_value(attr_name); end
private
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#132
def attr_names; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#136
def attribute_changed?(attr_name); end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#144
def clone_value(attr_name); end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#140
def fetch_value(attr_name); end
# Returns the value of attribute finalized_changes.
#
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#130
def finalized_changes; end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#151
def type_cast(attr_name, value); end
end
# source://activemodel//lib/active_model/attribute_set/builder.rb#94
class ActiveModel::LazyAttributeHash
# @return [LazyAttributeHash] a new instance of LazyAttributeHash
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#97
def initialize(types, values, additional_types, default_attributes, delegate_hash = T.unsafe(nil)); end
# source://activemodel//lib/active_model/attribute_set/builder.rb#134
def ==(other); end
# source://activemodel//lib/active_model/attribute_set/builder.rb#110
def [](key); end
# source://activemodel//lib/active_model/attribute_set/builder.rb#114
def []=(key, value); end
# source://activemodel//lib/active_model/attribute_set/builder.rb#118
def deep_dup; end
# source://activemodel//lib/active_model/attribute_set/builder.rb#129
def each_key(&block); end
# source://activemodel//lib/active_model/attribute_set/builder.rb#95
def each_value(*_arg0, &_arg1); end
# source://activemodel//lib/active_model/attribute_set/builder.rb#95
def except(*_arg0, &_arg1); end
# source://activemodel//lib/active_model/attribute_set/builder.rb#95
def fetch(*_arg0, &_arg1); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#106
def key?(key); end
# source://activemodel//lib/active_model/attribute_set/builder.rb#142
def marshal_dump; end
# source://activemodel//lib/active_model/attribute_set/builder.rb#146
def marshal_load(values); end
# source://activemodel//lib/active_model/attribute_set/builder.rb#95
def transform_values(*_arg0, &_arg1); end
protected
# source://activemodel//lib/active_model/attribute_set/builder.rb#151
def materialize; end
private
# Returns the value of attribute additional_types.
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#163
def additional_types; end
# source://activemodel//lib/active_model/attribute_set/builder.rb#165
def assign_default_value(name); end
# Returns the value of attribute default_attributes.
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#163
def default_attributes; end
# Returns the value of attribute delegate_hash.
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#163
def delegate_hash; end
# source://activemodel//lib/active_model/attribute_set/builder.rb#124
def initialize_dup(_); end
# Returns the value of attribute types.
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#163
def types; end
# Returns the value of attribute values.
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#163
def values; end
end
# source://activemodel//lib/active_model/attribute_set/builder.rb#21
class ActiveModel::LazyAttributeSet < ::ActiveModel::AttributeSet
# @return [LazyAttributeSet] a new instance of LazyAttributeSet
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#22
def initialize(values, types, additional_types, default_attributes, attributes = T.unsafe(nil)); end
# source://activemodel//lib/active_model/attribute_set/builder.rb#41
def fetch_value(name, &block); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#32
def key?(name); end
# source://activemodel//lib/active_model/attribute_set/builder.rb#36
def keys; end
protected
# source://activemodel//lib/active_model/attribute_set/builder.rb#61
def attributes; end
private
# Returns the value of attribute additional_types.
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#71
def additional_types; end
# source://activemodel//lib/active_model/attribute_set/builder.rb#73
def default_attribute(name, value_present = T.unsafe(nil), value = T.unsafe(nil)); end
# Returns the value of attribute default_attributes.
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#71
def default_attributes; end
# Returns the value of attribute types.
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#71
def types; end
# Returns the value of attribute values.
#
# source://activemodel//lib/active_model/attribute_set/builder.rb#71
def values; end
end
# source://activemodel//lib/active_model/lint.rb#4
module ActiveModel::Lint; end
# == Active \Model \Lint \Tests
#
# You can test whether an object is compliant with the Active \Model API by
# including ActiveModel::Lint::Tests in your TestCase. It will
# include tests that tell you whether your object is fully compliant,
# or if not, which aspects of the API are not implemented.
#
# Note an object is not required to implement all APIs in order to work
# with Action Pack. This module only intends to provide guidance in case
# you want all features out of the box.
#
# These tests do not attempt to determine the semantic correctness of the
# returned values. For instance, you could implement valid? to
# always return +true+, and the tests would pass. It is up to you to ensure
# that the values are semantically meaningful.
#
# Objects you pass in are expected to return a compliant object from a call
# to to_model. It is perfectly fine for to_model to return
# +self+.
#
# source://activemodel//lib/active_model/lint.rb#24
module ActiveModel::Lint::Tests
# Passes if the object's model responds to errors and if calling
# [](attribute) on the result of this method returns an array.
# Fails otherwise.
#
# errors[attribute] is used to retrieve the errors of a model
# for a given attribute. If errors are present, the method should return
# an array of strings that are the errors for the attribute in question.
# If localization is used, the strings should be localized for the current
# locale. If no error is present, the method should return an empty array.
#
# source://activemodel//lib/active_model/lint.rb#102
def test_errors_aref; end
# Passes if the object's model responds to model_name both as
# an instance method and as a class method, and if calling this method
# returns a string with some convenience methods: :human,
# :singular and :plural.
#
# Check ActiveModel::Naming for more information.
#
# source://activemodel//lib/active_model/lint.rb#81
def test_model_naming; end
# Passes if the object's model responds to persisted? and if
# calling this method returns either +true+ or +false+. Fails otherwise.
#
# persisted? is used when calculating the URL for an object.
# If the object is not persisted, a form for that object, for instance,
# will route to the create action. If it is persisted, a form for the
# object will route to the update action.
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/lint.rb#70
def test_persisted?; end
# Passes if the object's model responds to to_key and if calling
# this method returns +nil+ when the object is not persisted.
# Fails otherwise.
#
# to_key returns an Enumerable of all (primary) key attributes
# of the model, and is used to a generate unique DOM id for the object.
#
# source://activemodel//lib/active_model/lint.rb#31
def test_to_key; end
# Passes if the object's model responds to to_param and if
# calling this method returns +nil+ when the object is not persisted.
# Fails otherwise.
#
# to_param is used to represent the object's key in URLs.
# Implementers can decide to either raise an exception or provide a
# default in case the record uses a composite primary key. There are no
# tests for this behavior in lint because it doesn't make sense to force
# any of the possible implementation strategies on the implementer.
#
# source://activemodel//lib/active_model/lint.rb#46
def test_to_param; end
# Passes if the object's model responds to to_partial_path and if
# calling this method returns a string. Fails otherwise.
#
# to_partial_path is used for looking up partials. For example,
# a BlogPost model might return "blog_posts/blog_post".
#
# source://activemodel//lib/active_model/lint.rb#58
def test_to_partial_path; end
private
# source://activemodel//lib/active_model/lint.rb#113
def assert_boolean(result, name); end
# source://activemodel//lib/active_model/lint.rb#108
def model; end
end
# Raised when an attribute is not defined.
#
# class User < ActiveRecord::Base
# has_many :pets
# end
#
# user = User.first
# user.pets.select(:id).first.user_id
# # => ActiveModel::MissingAttributeError: missing attribute: user_id
#
# source://activemodel//lib/active_model/attribute_methods.rb#15
class ActiveModel::MissingAttributeError < ::NoMethodError; end
# == Active \Model \Basic \Model
#
# Allows implementing models similar to ActiveRecord::Base.
# Includes ActiveModel::API for the required interface for an
# object to interact with Action Pack and Action View, but can be
# extended with other functionalities.
#
# A minimal implementation could be:
#
# class Person
# include ActiveModel::Model
# attr_accessor :name, :age
# end
#
# person = Person.new(name: 'bob', age: '18')
# person.name # => "bob"
# person.age # => "18"
#
# If for some reason you need to run code on initialize, make
# sure you call +super+ if you want the attributes hash initialization to
# happen.
#
# class Person
# include ActiveModel::Model
# attr_accessor :id, :name, :omg
#
# def initialize(attributes={})
# super
# @omg ||= true
# end
# end
#
# person = Person.new(id: 1, name: 'bob')
# person.omg # => true
#
# For more detailed information on other functionalities available, please
# refer to the specific modules included in ActiveModel::Model
# (see below).
#
# source://activemodel//lib/active_model/model.rb#42
module ActiveModel::Model
extend ::ActiveSupport::Concern
include GeneratedInstanceMethods
include ::ActiveSupport::Callbacks
include ::ActiveModel::Validations::HelperMethods
include ::ActiveModel::Validations
include ::ActiveModel::Conversion
include ::ActiveModel::API
mixes_in_class_methods GeneratedClassMethods
mixes_in_class_methods ::ActiveModel::Validations::ClassMethods
mixes_in_class_methods ::ActiveModel::Callbacks
mixes_in_class_methods ::ActiveSupport::Callbacks::ClassMethods
mixes_in_class_methods ::ActiveSupport::DescendantsTracker
mixes_in_class_methods ::ActiveModel::Translation
mixes_in_class_methods ::ActiveModel::Validations::HelperMethods
mixes_in_class_methods ::ActiveModel::Conversion::ClassMethods
module GeneratedClassMethods
def __callbacks; end
def __callbacks=(value); end
def __callbacks?; end
def _validators; end
def _validators=(value); end
def _validators?; end
end
module GeneratedInstanceMethods
def __callbacks; end
def __callbacks?; end
def _validators; end
def _validators?; end
end
end
# source://activemodel//lib/active_model/naming.rb#9
class ActiveModel::Name
include ::Comparable
# Returns a new ActiveModel::Name instance. By default, the +namespace+
# and +name+ option will take the namespace and name of the given class
# respectively.
# Use +locale+ argument for singularize and pluralize model name.
#
# module Foo
# class Bar
# end
# end
#
# ActiveModel::Name.new(Foo::Bar).to_s
# # => "Foo::Bar"
#
# @raise [ArgumentError]
# @return [Name] a new instance of Name
#
# source://activemodel//lib/active_model/naming.rb#166
def initialize(klass, namespace = T.unsafe(nil), name = T.unsafe(nil), locale = T.unsafe(nil)); end
# source://activemodel//lib/active_model/naming.rb#151
def !~(*_arg0, &_arg1); end
# source://activemodel//lib/active_model/naming.rb#151
def <=>(*_arg0, &_arg1); end
# source://activemodel//lib/active_model/naming.rb#151
def ==(arg); end
# source://activemodel//lib/active_model/naming.rb#151
def ===(arg); end
# source://activemodel//lib/active_model/naming.rb#151
def =~(*_arg0, &_arg1); end
# source://activemodel//lib/active_model/naming.rb#151
def as_json(*_arg0, &_arg1); end
# Returns the value of attribute collection.
#
# source://activemodel//lib/active_model/naming.rb#12
def cache_key; end
# Returns the value of attribute collection.
#
# source://activemodel//lib/active_model/naming.rb#12
def collection; end
# Sets the attribute collection
#
# @param value the value to set the attribute collection to.
#
# source://activemodel//lib/active_model/naming.rb#12
def collection=(_arg0); end
# Returns the value of attribute element.
#
# source://activemodel//lib/active_model/naming.rb#12
def element; end
# Sets the attribute element
#
# @param value the value to set the attribute element to.
#
# source://activemodel//lib/active_model/naming.rb#12
def element=(_arg0); end
# source://activemodel//lib/active_model/naming.rb#151
def eql?(*_arg0, &_arg1); end
# Transform the model name into a more human format, using I18n. By default,
# it will underscore then humanize the class name.
#
# class BlogPost
# extend ActiveModel::Naming
# end
#
# BlogPost.model_name.human # => "Blog post"
#
# Specify +options+ with additional translating options.
#
# source://activemodel//lib/active_model/naming.rb#197
def human(options = T.unsafe(nil)); end
# Returns the value of attribute i18n_key.
#
# source://activemodel//lib/active_model/naming.rb#12
def i18n_key; end
# Sets the attribute i18n_key
#
# @param value the value to set the attribute i18n_key to.
#
# source://activemodel//lib/active_model/naming.rb#12
def i18n_key=(_arg0); end
# source://activemodel//lib/active_model/naming.rb#151
def match?(*_arg0, &_arg1); end
# Returns the value of attribute name.
#
# source://activemodel//lib/active_model/naming.rb#12
def name; end
# Sets the attribute name
#
# @param value the value to set the attribute name to.
#
# source://activemodel//lib/active_model/naming.rb#12
def name=(_arg0); end
# Returns the value of attribute param_key.
#
# source://activemodel//lib/active_model/naming.rb#12
def param_key; end
# Sets the attribute param_key
#
# @param value the value to set the attribute param_key to.
#
# source://activemodel//lib/active_model/naming.rb#12
def param_key=(_arg0); end
# Returns the value of attribute plural.
#
# source://activemodel//lib/active_model/naming.rb#12
def plural; end
# Sets the attribute plural
#
# @param value the value to set the attribute plural to.
#
# source://activemodel//lib/active_model/naming.rb#12
def plural=(_arg0); end
# Returns the value of attribute route_key.
#
# source://activemodel//lib/active_model/naming.rb#12
def route_key; end
# Sets the attribute route_key
#
# @param value the value to set the attribute route_key to.
#
# source://activemodel//lib/active_model/naming.rb#12
def route_key=(_arg0); end
# Returns the value of attribute singular.
#
# source://activemodel//lib/active_model/naming.rb#12
def singular; end
# Sets the attribute singular
#
# @param value the value to set the attribute singular to.
#
# source://activemodel//lib/active_model/naming.rb#12
def singular=(_arg0); end
# Returns the value of attribute singular_route_key.
#
# source://activemodel//lib/active_model/naming.rb#12
def singular_route_key; end
# Sets the attribute singular_route_key
#
# @param value the value to set the attribute singular_route_key to.
#
# source://activemodel//lib/active_model/naming.rb#12
def singular_route_key=(_arg0); end
# source://activemodel//lib/active_model/naming.rb#151
def to_s(*_arg0, &_arg1); end
# source://activemodel//lib/active_model/naming.rb#151
def to_str(*_arg0, &_arg1); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/naming.rb#212
def uncountable?; end
private
# source://activemodel//lib/active_model/naming.rb#217
def _singularize(string); end
end
# == Active \Model \Naming
#
# Creates a +model_name+ method on your object.
#
# To implement, just extend ActiveModel::Naming in your object:
#
# class BookCover
# extend ActiveModel::Naming
# end
#
# BookCover.model_name.name # => "BookCover"
# BookCover.model_name.human # => "Book cover"
#
# BookCover.model_name.i18n_key # => :book_cover
# BookModule::BookCover.model_name.i18n_key # => :"book_module/book_cover"
#
# Providing the functionality that ActiveModel::Naming provides in your object
# is required to pass the \Active \Model Lint test. So either extending the
# provided method below, or rolling your own is required.
#
# source://activemodel//lib/active_model/naming.rb#241
module ActiveModel::Naming
# Returns an ActiveModel::Name object for module. It can be
# used to retrieve all kinds of naming-related information
# (See ActiveModel::Name for more information).
#
# class Person
# extend ActiveModel::Naming
# end
#
# Person.model_name.name # => "Person"
# Person.model_name.class # => ActiveModel::Name
# Person.model_name.singular # => "person"
# Person.model_name.plural # => "people"
#
# source://activemodel//lib/active_model/naming.rb#259
def model_name; end
class << self
# source://activemodel//lib/active_model/naming.rb#242
def extended(base); end
# Returns string to use for params names. It differs for
# namespaced models regarding whether it's inside isolated engine.
#
# # For isolated engine:
# ActiveModel::Naming.param_key(Blog::Post) # => "post"
#
# # For shared engine:
# ActiveModel::Naming.param_key(Blog::Post) # => "blog_post"
#
# source://activemodel//lib/active_model/naming.rb#327
def param_key(record_or_class); end
# Returns the plural class name of a record or class.
#
# ActiveModel::Naming.plural(post) # => "posts"
# ActiveModel::Naming.plural(Highrise::Person) # => "highrise_people"
#
# source://activemodel//lib/active_model/naming.rb#272
def plural(record_or_class); end
# Returns string to use while generating route names. It differs for
# namespaced models regarding whether it's inside isolated engine.
#
# # For isolated engine:
# ActiveModel::Naming.route_key(Blog::Post) # => "posts"
#
# # For shared engine:
# ActiveModel::Naming.route_key(Blog::Post) # => "blog_posts"
#
# The route key also considers if the noun is uncountable and, in
# such cases, automatically appends _index.
#
# source://activemodel//lib/active_model/naming.rb#315
def route_key(record_or_class); end
# Returns the singular class name of a record or class.
#
# ActiveModel::Naming.singular(post) # => "post"
# ActiveModel::Naming.singular(Highrise::Person) # => "highrise_person"
#
# source://activemodel//lib/active_model/naming.rb#280
def singular(record_or_class); end
# Returns string to use while generating route names. It differs for
# namespaced models regarding whether it's inside isolated engine.
#
# # For isolated engine:
# ActiveModel::Naming.singular_route_key(Blog::Post) # => "post"
#
# # For shared engine:
# ActiveModel::Naming.singular_route_key(Blog::Post) # => "blog_post"
#
# source://activemodel//lib/active_model/naming.rb#300
def singular_route_key(record_or_class); end
# Identifies whether the class name of a record or class is uncountable.
#
# ActiveModel::Naming.uncountable?(Sheep) # => true
# ActiveModel::Naming.uncountable?(Post) # => false
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/naming.rb#288
def uncountable?(record_or_class); end
private
# source://activemodel//lib/active_model/naming.rb#331
def model_name_from_record_or_class(record_or_class); end
end
end
# source://activemodel//lib/active_model/nested_error.rb#7
class ActiveModel::NestedError < ::ActiveModel::Error
extend ::Forwardable
# @return [NestedError] a new instance of NestedError
#
# source://activemodel//lib/active_model/nested_error.rb#8
def initialize(base, inner_error, override_options = T.unsafe(nil)); end
# Returns the value of attribute inner_error.
#
# source://activemodel//lib/active_model/nested_error.rb#17
def inner_error; end
# source://forwardable/1.3.2/forwardable.rb#229
def message(*args, &block); end
end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#156
class ActiveModel::NullMutationTracker
include ::Singleton
extend ::Singleton::SingletonClassMethods
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#174
def any_changes?; end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#171
def change_to_attribute(attr_name); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#178
def changed?(attr_name, **_arg1); end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#159
def changed_attribute_names; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#182
def changed_in_place?(attr_name); end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#163
def changed_values; end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#167
def changes; end
# source://activemodel//lib/active_model/attribute_mutation_tracker.rb#186
def original_value(attr_name); end
end
# Raised when attribute values are out of range.
#
# source://activemodel//lib/active_model/errors.rb#494
class ActiveModel::RangeError < ::RangeError; end
# source://activemodel//lib/active_model/secure_password.rb#4
module ActiveModel::SecurePassword
extend ::ActiveSupport::Concern
mixes_in_class_methods ::ActiveModel::SecurePassword::ClassMethods
class << self
# source://activemodel//lib/active_model/secure_password.rb#13
def min_cost; end
# source://activemodel//lib/active_model/secure_password.rb#13
def min_cost=(_arg0); end
end
end
# source://activemodel//lib/active_model/secure_password.rb#17
module ActiveModel::SecurePassword::ClassMethods
# Adds methods to set and authenticate against a BCrypt password.
# This mechanism requires you to have a +XXX_digest+ attribute.
# Where +XXX+ is the attribute name of your desired password.
#
# The following validations are added automatically:
# * Password must be present on creation
# * Password length should be less than or equal to 72 bytes
# * Confirmation of password (using a +XXX_confirmation+ attribute)
#
# If confirmation validation is not needed, simply leave out the
# value for +XXX_confirmation+ (i.e. don't provide a form field for
# it). When this attribute has a +nil+ value, the validation will not be
# triggered.
#
# For further customizability, it is possible to suppress the default
# validations by passing validations: false as an argument.
#
# Add bcrypt (~> 3.1.7) to Gemfile to use #has_secure_password:
#
# gem 'bcrypt', '~> 3.1.7'
#
# ==== Examples
#
# ===== Using Active Record (which automatically includes ActiveModel::SecurePassword)
#
# # Schema: User(name:string, password_digest:string, recovery_password_digest:string)
# class User < ActiveRecord::Base
# has_secure_password
# has_secure_password :recovery_password, validations: false
# end
#
# user = User.new(name: 'david', password: '', password_confirmation: 'nomatch')
# user.save # => false, password required
# user.password = 'mUc3m00RsqyRe'
# user.save # => false, confirmation doesn't match
# user.password_confirmation = 'mUc3m00RsqyRe'
# user.save # => true
# user.recovery_password = "42password"
# user.recovery_password_digest # => "$2a$04$iOfhwahFymCs5weB3BNH/uXkTG65HR.qpW.bNhEjFP3ftli3o5DQC"
# user.save # => true
# user.authenticate('notright') # => false
# user.authenticate('mUc3m00RsqyRe') # => user
# user.authenticate_recovery_password('42password') # => user
# User.find_by(name: 'david')&.authenticate('notright') # => false
# User.find_by(name: 'david')&.authenticate('mUc3m00RsqyRe') # => user
#
# ===== Conditionally requiring a password
#
# class Account
# include ActiveModel::SecurePassword
#
# attr_accessor :is_guest, :password_digest
#
# has_secure_password
#
# def errors
# super.tap { |errors| errors.delete(:password, :blank) if is_guest }
# end
# end
#
# account = Account.new
# account.valid? # => false, password required
#
# account.is_guest = true
# account.valid? # => true
#
# source://activemodel//lib/active_model/secure_password.rb#84
def has_secure_password(attribute = T.unsafe(nil), validations: T.unsafe(nil)); end
end
# source://activemodel//lib/active_model/secure_password.rb#114
class ActiveModel::SecurePassword::InstanceMethodsOnActivation < ::Module
# @return [InstanceMethodsOnActivation] a new instance of InstanceMethodsOnActivation
#
# source://activemodel//lib/active_model/secure_password.rb#115
def initialize(attribute); end
end
# BCrypt hash function can handle maximum 72 bytes, and if we pass
# password of length more than 72 bytes it ignores extra characters.
# Hence need to put a restriction on password length.
#
# source://activemodel//lib/active_model/secure_password.rb#10
ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED = T.let(T.unsafe(nil), Integer)
# == Active \Model \Serialization
#
# Provides a basic serialization to a serializable_hash for your objects.
#
# A minimal implementation could be:
#
# class Person
# include ActiveModel::Serialization
#
# attr_accessor :name
#
# def attributes
# {'name' => nil}
# end
# end
#
# Which would provide you with:
#
# person = Person.new
# person.serializable_hash # => {"name"=>nil}
# person.name = "Bob"
# person.serializable_hash # => {"name"=>"Bob"}
#
# An +attributes+ hash must be defined and should contain any attributes you
# need to be serialized. Attributes must be strings, not symbols.
# When called, serializable hash will use instance methods that match the name
# of the attributes hash's keys. In order to override this behavior, take a look
# at the private method +read_attribute_for_serialization+.
#
# ActiveModel::Serializers::JSON module automatically includes
# the ActiveModel::Serialization module, so there is no need to
# explicitly include ActiveModel::Serialization.
#
# A minimal implementation including JSON would be:
#
# class Person
# include ActiveModel::Serializers::JSON
#
# attr_accessor :name
#
# def attributes
# {'name' => nil}
# end
# end
#
# Which would provide you with:
#
# person = Person.new
# person.serializable_hash # => {"name"=>nil}
# person.as_json # => {"name"=>nil}
# person.to_json # => "{\"name\":null}"
#
# person.name = "Bob"
# person.serializable_hash # => {"name"=>"Bob"}
# person.as_json # => {"name"=>"Bob"}
# person.to_json # => "{\"name\":\"Bob\"}"
#
# Valid options are :only, :except, :methods and
# :include. The following are all valid examples:
#
# person.serializable_hash(only: 'name')
# person.serializable_hash(include: :address)
# person.serializable_hash(include: { address: { only: 'city' }})
#
# source://activemodel//lib/active_model/serialization.rb#69
module ActiveModel::Serialization
# Hook method defining how an attribute value should be retrieved for
# serialization. By default this is assumed to be an instance named after
# the attribute. Override this method in subclasses should you need to
# retrieve the value for a given attribute differently:
#
# class MyClass
# include ActiveModel::Serialization
#
# def initialize(data = {})
# @data = data
# end
#
# def read_attribute_for_serialization(key)
# @data[key]
# end
# end
def read_attribute_for_serialization(*_arg0); end
# Returns a serialized hash of your object.
#
# class Person
# include ActiveModel::Serialization
#
# attr_accessor :name, :age
#
# def attributes
# {'name' => nil, 'age' => nil}
# end
#
# def capitalized_name
# name.capitalize
# end
# end
#
# person = Person.new
# person.name = 'bob'
# person.age = 22
# person.serializable_hash # => {"name"=>"bob", "age"=>22}
# person.serializable_hash(only: :name) # => {"name"=>"bob"}
# person.serializable_hash(except: :name) # => {"age"=>22}
# person.serializable_hash(methods: :capitalized_name)
# # => {"name"=>"bob", "age"=>22, "capitalized_name"=>"Bob"}
#
# Example with :include option
#
# class User
# include ActiveModel::Serializers::JSON
# attr_accessor :name, :notes # Emulate has_many :notes
# def attributes
# {'name' => nil}
# end
# end
#
# class Note
# include ActiveModel::Serializers::JSON
# attr_accessor :title, :text
# def attributes
# {'title' => nil, 'text' => nil}
# end
# end
#
# note = Note.new
# note.title = 'Battle of Austerlitz'
# note.text = 'Some text here'
#
# user = User.new
# user.name = 'Napoleon'
# user.notes = [note]
#
# user.serializable_hash
# # => {"name" => "Napoleon"}
# user.serializable_hash(include: { notes: { only: 'title' }})
# # => {"name" => "Napoleon", "notes" => [{"title"=>"Battle of Austerlitz"}]}
#
# source://activemodel//lib/active_model/serialization.rb#125
def serializable_hash(options = T.unsafe(nil)); end
private
# source://activemodel//lib/active_model/serialization.rb#152
def attribute_names_for_serialization; end
# Add associations specified via the :include option.
#
# Expects a block that takes as arguments:
# +association+ - name of the association
# +records+ - the association record(s) to be serialized
# +opts+ - options for the association records
#
# source://activemodel//lib/active_model/serialization.rb#184
def serializable_add_includes(options = T.unsafe(nil)); end
# source://activemodel//lib/active_model/serialization.rb#174
def serializable_attributes(attribute_names); end
end
# source://activemodel//lib/active_model.rb#64
module ActiveModel::Serializers
extend ::ActiveSupport::Autoload
end
# == Active \Model \JSON \Serializer
#
# source://activemodel//lib/active_model/serializers/json.rb#8
module ActiveModel::Serializers::JSON
include ::ActiveModel::Serialization
extend ::ActiveSupport::Concern
include GeneratedInstanceMethods
mixes_in_class_methods GeneratedClassMethods
mixes_in_class_methods ::ActiveModel::Naming
# Returns a hash representing the model. Some configuration can be
# passed through +options+.
#
# The option include_root_in_json controls the top-level behavior
# of +as_json+. If +true+, +as_json+ will emit a single root node named
# after the object's type. The default value for include_root_in_json
# option is +false+.
#
# user = User.find(1)
# user.as_json
# # => { "id" => 1, "name" => "Konata Izumi", "age" => 16,
# # "created_at" => "2006-08-01T17:27:133.000Z", "awesome" => true}
#
# ActiveRecord::Base.include_root_in_json = true
#
# user.as_json
# # => { "user" => { "id" => 1, "name" => "Konata Izumi", "age" => 16,
# # "created_at" => "2006-08-01T17:27:13.000Z", "awesome" => true } }
#
# This behavior can also be achieved by setting the :root option
# to +true+ as in:
#
# user = User.find(1)
# user.as_json(root: true)
# # => { "user" => { "id" => 1, "name" => "Konata Izumi", "age" => 16,
# # "created_at" => "2006-08-01T17:27:13.000Z", "awesome" => true } }
#
# If you prefer, :root may also be set to a custom string key instead as in:
#
# user = User.find(1)
# user.as_json(root: "author")
# # => { "author" => { "id" => 1, "name" => "Konata Izumi", "age" => 16,
# # "created_at" => "2006-08-01T17:27:13.000Z", "awesome" => true } }
#
# Without any +options+, the returned Hash will include all the model's
# attributes.
#
# user = User.find(1)
# user.as_json
# # => { "id" => 1, "name" => "Konata Izumi", "age" => 16,
# # "created_at" => "2006-08-01T17:27:13.000Z", "awesome" => true}
#
# The :only and :except options can be used to limit
# the attributes included, and work similar to the +attributes+ method.
#
# user.as_json(only: [:id, :name])
# # => { "id" => 1, "name" => "Konata Izumi" }
#
# user.as_json(except: [:id, :created_at, :age])
# # => { "name" => "Konata Izumi", "awesome" => true }
#
# To include the result of some method calls on the model use :methods:
#
# user.as_json(methods: :permalink)
# # => { "id" => 1, "name" => "Konata Izumi", "age" => 16,
# # "created_at" => "2006-08-01T17:27:13.000Z", "awesome" => true,
# # "permalink" => "1-konata-izumi" }
#
# To include associations use :include:
#
# user.as_json(include: :posts)
# # => { "id" => 1, "name" => "Konata Izumi", "age" => 16,
# # "created_at" => "2006-08-01T17:27:13.000Z", "awesome" => true,
# # "posts" => [ { "id" => 1, "author_id" => 1, "title" => "Welcome to the weblog" },
# # { "id" => 2, "author_id" => 1, "title" => "So I was thinking" } ] }
#
# Second level and higher order associations work as well:
#
# user.as_json(include: { posts: {
# include: { comments: {
# only: :body } },
# only: :title } })
# # => { "id" => 1, "name" => "Konata Izumi", "age" => 16,
# # "created_at" => "2006-08-01T17:27:13.000Z", "awesome" => true,
# # "posts" => [ { "comments" => [ { "body" => "1st post!" }, { "body" => "Second!" } ],
# # "title" => "Welcome to the weblog" },
# # { "comments" => [ { "body" => "Don't think too hard" } ],
# # "title" => "So I was thinking" } ] }
#
# source://activemodel//lib/active_model/serializers/json.rb#96
def as_json(options = T.unsafe(nil)); end
# Sets the model +attributes+ from a JSON string. Returns +self+.
#
# class Person
# include ActiveModel::Serializers::JSON
#
# attr_accessor :name, :age, :awesome
#
# def attributes=(hash)
# hash.each do |key, value|
# send("#{key}=", value)
# end
# end
#
# def attributes
# instance_values
# end
# end
#
# json = { name: 'bob', age: 22, awesome:true }.to_json
# person = Person.new
# person.from_json(json) # => #
# person.name # => "bob"
# person.age # => 22
# person.awesome # => true
#
# The default value for +include_root+ is +false+. You can change it to
# +true+ if the given JSON string includes a single root node.
#
# json = { person: { name: 'bob', age: 22, awesome:true } }.to_json
# person = Person.new
# person.from_json(json, true) # => #
# person.name # => "bob"
# person.age # => 22
# person.awesome # => true
#
# source://activemodel//lib/active_model/serializers/json.rb#146
def from_json(json, include_root = T.unsafe(nil)); end
module GeneratedClassMethods
def include_root_in_json; end
def include_root_in_json=(value); end
def include_root_in_json?; end
end
module GeneratedInstanceMethods
def include_root_in_json; end
def include_root_in_json?; end
end
end
# Raised when a validation cannot be corrected by end users and are considered
# exceptional.
#
# class Person
# include ActiveModel::Validations
#
# attr_accessor :name
#
# validates_presence_of :name, strict: true
# end
#
# person = Person.new
# person.name = nil
# person.valid?
# # => ActiveModel::StrictValidationFailed: Name can't be blank
#
# source://activemodel//lib/active_model/errors.rb#490
class ActiveModel::StrictValidationFailed < ::StandardError; end
# == Active \Model \Translation
#
# Provides integration between your object and the Rails internationalization
# (i18n) framework.
#
# A minimal implementation could be:
#
# class TranslatedPerson
# extend ActiveModel::Translation
# end
#
# TranslatedPerson.human_attribute_name('my_attribute')
# # => "My attribute"
#
# This also provides the required class methods for hooking into the
# Rails internationalization API, including being able to define a
# class-based +i18n_scope+ and +lookup_ancestors+ to find translations in
# parent classes.
#
# source://activemodel//lib/active_model/translation.rb#22
module ActiveModel::Translation
include ::ActiveModel::Naming
# Transforms attribute names into a more human format, such as "First name"
# instead of "first_name".
#
# Person.human_attribute_name("first_name") # => "First name"
#
# Specify +options+ with additional translating options.
#
# source://activemodel//lib/active_model/translation.rb#44
def human_attribute_name(attribute, options = T.unsafe(nil)); end
# Returns the +i18n_scope+ for the class. Override if you want custom lookup.
#
# source://activemodel//lib/active_model/translation.rb#26
def i18n_scope; end
# When localizing a string, it goes through the lookup returned by this
# method, which is used in ActiveModel::Name#human,
# ActiveModel::Errors#full_messages and
# ActiveModel::Translation#human_attribute_name.
#
# source://activemodel//lib/active_model/translation.rb#34
def lookup_ancestors; end
end
# source://activemodel//lib/active_model/type/helpers/accepts_multiparameter_time.rb#4
module ActiveModel::Type
class << self
# source://activemodel//lib/active_model/type.rb#37
def default_value; end
# source://activemodel//lib/active_model/type.rb#33
def lookup(*_arg0, &_arg1); end
# Add a new type to the registry, allowing it to be referenced as a
# symbol by {attribute}[rdoc-ref:Attributes::ClassMethods#attribute].
#
# source://activemodel//lib/active_model/type.rb#29
def register(type_name, klass = T.unsafe(nil), &block); end
# source://activemodel//lib/active_model/type.rb#25
def registry; end
# source://activemodel//lib/active_model/type.rb#25
def registry=(_arg0); end
end
end
# source://activemodel//lib/active_model/type/big_integer.rb#7
class ActiveModel::Type::BigInteger < ::ActiveModel::Type::Integer
private
# source://activemodel//lib/active_model/type/big_integer.rb#9
def max_value; end
end
# source://activemodel//lib/active_model/type/binary.rb#5
class ActiveModel::Type::Binary < ::ActiveModel::Type::Value
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/binary.rb#10
def binary?; end
# source://activemodel//lib/active_model/type/binary.rb#14
def cast(value); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/binary.rb#29
def changed_in_place?(raw_old_value, value); end
# source://activemodel//lib/active_model/type/binary.rb#24
def serialize(value); end
# source://activemodel//lib/active_model/type/binary.rb#6
def type; end
end
# source://activemodel//lib/active_model/type/binary.rb#34
class ActiveModel::Type::Binary::Data
# @return [Data] a new instance of Data
#
# source://activemodel//lib/active_model/type/binary.rb#35
def initialize(value); end
# source://activemodel//lib/active_model/type/binary.rb#50
def ==(other); end
# source://activemodel//lib/active_model/type/binary.rb#46
def hex; end
# source://activemodel//lib/active_model/type/binary.rb#41
def to_s; end
# source://activemodel//lib/active_model/type/binary.rb#41
def to_str; end
end
# == Active \Model \Type \Boolean
#
# A class that behaves like a boolean type, including rules for coercion of user input.
#
# === Coercion
# Values set from user input will first be coerced into the appropriate ruby type.
# Coercion behavior is roughly mapped to Ruby's boolean semantics.
#
# - "false", "f" , "0", +0+ or any other value in +FALSE_VALUES+ will be coerced to +false+
# - Empty strings are coerced to +nil+
# - All other values will be coerced to +true+
#
# source://activemodel//lib/active_model/type/boolean.rb#16
class ActiveModel::Type::Boolean < ::ActiveModel::Type::Value
# source://activemodel//lib/active_model/type/boolean.rb#32
def serialize(value); end
# source://activemodel//lib/active_model/type/boolean.rb#28
def type; end
private
# source://activemodel//lib/active_model/type/boolean.rb#37
def cast_value(value); end
end
# source://activemodel//lib/active_model/type/boolean.rb#17
ActiveModel::Type::Boolean::FALSE_VALUES = T.let(T.unsafe(nil), Set)
# source://activemodel//lib/active_model/type/date.rb#5
class ActiveModel::Type::Date < ::ActiveModel::Type::Value
include ::ActiveModel::Type::Helpers::Timezone
include ::ActiveModel::Type::Helpers::AcceptsMultiparameterTime::InstanceMethods
# source://activemodel//lib/active_model/type/date.rb#9
def type; end
# source://activemodel//lib/active_model/type/date.rb#13
def type_cast_for_schema(value); end
private
# source://activemodel//lib/active_model/type/date.rb#18
def cast_value(value); end
# source://activemodel//lib/active_model/type/date.rb#36
def fallback_string_to_date(string); end
# source://activemodel//lib/active_model/type/date.rb#30
def fast_string_to_date(string); end
# source://activemodel//lib/active_model/type/date.rb#40
def new_date(year, mon, mday); end
# source://activemodel//lib/active_model/type/date.rb#46
def value_from_multiparameter_assignment(*_arg0); end
end
# source://activemodel//lib/active_model/type/date.rb#29
ActiveModel::Type::Date::ISO_DATE = T.let(T.unsafe(nil), Regexp)
# source://activemodel//lib/active_model/type/date_time.rb#5
class ActiveModel::Type::DateTime < ::ActiveModel::Type::Value
include ::ActiveModel::Type::Helpers::Timezone
include ::ActiveModel::Type::Helpers::TimeValue
include ::ActiveModel::Type::Helpers::AcceptsMultiparameterTime::InstanceMethods
# source://activemodel//lib/active_model/type/date_time.rb#12
def type; end
private
# source://activemodel//lib/active_model/type/date_time.rb#17
def cast_value(value); end
# source://activemodel//lib/active_model/type/date_time.rb#30
def fallback_string_to_time(string); end
# '0.123456' -> 123456
# '1.123456' -> 123456
#
# source://activemodel//lib/active_model/type/date_time.rb#26
def microseconds(time); end
# source://activemodel//lib/active_model/type/date_time.rb#37
def value_from_multiparameter_assignment(values_hash); end
end
# source://activemodel//lib/active_model/type/decimal.rb#7
class ActiveModel::Type::Decimal < ::ActiveModel::Type::Value
include ::ActiveModel::Type::Helpers::Numeric
# source://activemodel//lib/active_model/type/decimal.rb#11
def type; end
# source://activemodel//lib/active_model/type/decimal.rb#15
def type_cast_for_schema(value); end
private
# source://activemodel//lib/active_model/type/decimal.rb#60
def apply_scale(value); end
# source://activemodel//lib/active_model/type/decimal.rb#20
def cast_value(value); end
# source://activemodel//lib/active_model/type/decimal.rb#44
def convert_float_to_big_decimal(value); end
# source://activemodel//lib/active_model/type/decimal.rb#52
def float_precision; end
end
# source://activemodel//lib/active_model/type/decimal.rb#9
ActiveModel::Type::Decimal::BIGDECIMAL_PRECISION = T.let(T.unsafe(nil), Integer)
# source://activemodel//lib/active_model/type/float.rb#7
class ActiveModel::Type::Float < ::ActiveModel::Type::Value
include ::ActiveModel::Type::Helpers::Numeric
# source://activemodel//lib/active_model/type/float.rb#10
def type; end
# source://activemodel//lib/active_model/type/float.rb#14
def type_cast_for_schema(value); end
private
# source://activemodel//lib/active_model/type/float.rb#24
def cast_value(value); end
end
# source://activemodel//lib/active_model/type/helpers/accepts_multiparameter_time.rb#5
module ActiveModel::Type::Helpers; end
# source://activemodel//lib/active_model/type/helpers/accepts_multiparameter_time.rb#6
class ActiveModel::Type::Helpers::AcceptsMultiparameterTime < ::Module
# @return [AcceptsMultiparameterTime] a new instance of AcceptsMultiparameterTime
#
# source://activemodel//lib/active_model/type/helpers/accepts_multiparameter_time.rb#33
def initialize(defaults: T.unsafe(nil)); end
end
# source://activemodel//lib/active_model/type/helpers/accepts_multiparameter_time.rb#7
module ActiveModel::Type::Helpers::AcceptsMultiparameterTime::InstanceMethods
# source://activemodel//lib/active_model/type/helpers/accepts_multiparameter_time.rb#20
def assert_valid_value(value); end
# source://activemodel//lib/active_model/type/helpers/accepts_multiparameter_time.rb#12
def cast(value); end
# source://activemodel//lib/active_model/type/helpers/accepts_multiparameter_time.rb#8
def serialize(value); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/helpers/accepts_multiparameter_time.rb#28
def value_constructed_by_mass_assignment?(value); end
end
# source://activemodel//lib/active_model/type/helpers/mutable.rb#6
module ActiveModel::Type::Helpers::Mutable
# source://activemodel//lib/active_model/type/helpers/mutable.rb#7
def cast(value); end
# +raw_old_value+ will be the `_before_type_cast` version of the
# value (likely a string). +new_value+ will be the current, type
# cast value.
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/helpers/mutable.rb#14
def changed_in_place?(raw_old_value, new_value); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/helpers/mutable.rb#18
def mutable?; end
end
# source://activemodel//lib/active_model/type/helpers/numeric.rb#6
module ActiveModel::Type::Helpers::Numeric
# source://activemodel//lib/active_model/type/helpers/numeric.rb#11
def cast(value); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/helpers/numeric.rb#27
def changed?(old_value, _new_value, new_value_before_type_cast); end
# source://activemodel//lib/active_model/type/helpers/numeric.rb#7
def serialize(value); end
private
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/helpers/numeric.rb#33
def equal_nan?(old_value, new_value); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/helpers/numeric.rb#44
def non_numeric_string?(value); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/helpers/numeric.rb#40
def number_to_non_number?(old_value, new_value_before_type_cast); end
end
# source://activemodel//lib/active_model/type/helpers/numeric.rb#51
ActiveModel::Type::Helpers::Numeric::NUMERIC_REGEX = T.let(T.unsafe(nil), Regexp)
# source://activemodel//lib/active_model/type/helpers/time_value.rb#9
module ActiveModel::Type::Helpers::TimeValue
# source://activemodel//lib/active_model/type/helpers/time_value.rb#24
def apply_seconds_precision(value); end
# source://activemodel//lib/active_model/type/helpers/time_value.rb#10
def serialize(value); end
# source://activemodel//lib/active_model/type/helpers/time_value.rb#38
def type_cast_for_schema(value); end
# source://activemodel//lib/active_model/type/helpers/time_value.rb#42
def user_input_in_time_zone(value); end
private
# source://activemodel//lib/active_model/type/helpers/time_value.rb#72
def fast_string_to_time(string); end
# source://activemodel//lib/active_model/type/helpers/time_value.rb#47
def new_time(year, mon, mday, hour, min, sec, microsec, offset = T.unsafe(nil)); end
end
# source://activemodel//lib/active_model/type/helpers/time_value.rb#64
ActiveModel::Type::Helpers::TimeValue::ISO_DATETIME = T.let(T.unsafe(nil), Regexp)
# source://activemodel//lib/active_model/type/helpers/timezone.rb#8
module ActiveModel::Type::Helpers::Timezone
# source://activemodel//lib/active_model/type/helpers/timezone.rb#13
def default_timezone; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/helpers/timezone.rb#9
def is_utc?; end
end
# source://activemodel//lib/active_model/type/immutable_string.rb#5
class ActiveModel::Type::ImmutableString < ::ActiveModel::Type::Value
# @return [ImmutableString] a new instance of ImmutableString
#
# source://activemodel//lib/active_model/type/immutable_string.rb#6
def initialize(**args); end
# source://activemodel//lib/active_model/type/immutable_string.rb#16
def serialize(value); end
# source://activemodel//lib/active_model/type/immutable_string.rb#12
def type; end
private
# source://activemodel//lib/active_model/type/immutable_string.rb#26
def cast_value(value); end
end
# source://activemodel//lib/active_model/type/integer.rb#5
class ActiveModel::Type::Integer < ::ActiveModel::Type::Value
include ::ActiveModel::Type::Helpers::Numeric
# @return [Integer] a new instance of Integer
#
# source://activemodel//lib/active_model/type/integer.rb#12
def initialize(**_arg0); end
# source://activemodel//lib/active_model/type/integer.rb#21
def deserialize(value); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/integer.rb#31
def serializable?(value); end
# source://activemodel//lib/active_model/type/integer.rb#26
def serialize(value); end
# source://activemodel//lib/active_model/type/integer.rb#17
def type; end
private
# source://activemodel//lib/active_model/type/integer.rb#65
def _limit; end
# source://activemodel//lib/active_model/type/integer.rb#46
def cast_value(value); end
# source://activemodel//lib/active_model/type/integer.rb#50
def ensure_in_range(value); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/integer.rb#42
def in_range?(value); end
# source://activemodel//lib/active_model/type/integer.rb#57
def max_value; end
# source://activemodel//lib/active_model/type/integer.rb#61
def min_value; end
# Returns the value of attribute range.
#
# source://activemodel//lib/active_model/type/integer.rb#40
def range; end
end
# Column storage size in bytes.
# 4 bytes means an integer as opposed to smallint etc.
#
# source://activemodel//lib/active_model/type/integer.rb#10
ActiveModel::Type::Integer::DEFAULT_LIMIT = T.let(T.unsafe(nil), Integer)
# source://activemodel//lib/active_model/type/registry.rb#5
class ActiveModel::Type::Registry
# @return [Registry] a new instance of Registry
#
# source://activemodel//lib/active_model/type/registry.rb#6
def initialize; end
# source://activemodel//lib/active_model/type/registry.rb#23
def lookup(symbol, *args); end
# source://activemodel//lib/active_model/type/registry.rb#15
def register(type_name, klass = T.unsafe(nil), &block); end
private
# source://activemodel//lib/active_model/type/registry.rb#10
def initialize_copy(other); end
# Returns the value of attribute registrations.
#
# source://activemodel//lib/active_model/type/registry.rb#35
def registrations; end
end
# source://activemodel//lib/active_model/type/string.rb#7
class ActiveModel::Type::String < ::ActiveModel::Type::ImmutableString
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/string.rb#8
def changed_in_place?(raw_old_value, new_value); end
# source://activemodel//lib/active_model/type/string.rb#14
def to_immutable_string; end
private
# source://activemodel//lib/active_model/type/string.rb#25
def cast_value(value); end
end
# source://activemodel//lib/active_model/type/time.rb#5
class ActiveModel::Type::Time < ::ActiveModel::Type::Value
include ::ActiveModel::Type::Helpers::Timezone
include ::ActiveModel::Type::Helpers::TimeValue
include ::ActiveModel::Type::Helpers::AcceptsMultiparameterTime::InstanceMethods
# source://activemodel//lib/active_model/type/time.rb#12
def type; end
# source://activemodel//lib/active_model/type/time.rb#16
def user_input_in_time_zone(value); end
private
# source://activemodel//lib/active_model/type/time.rb#32
def cast_value(value); end
end
# source://activemodel//lib/active_model/type/value.rb#5
class ActiveModel::Type::Value
# @return [Value] a new instance of Value
#
# source://activemodel//lib/active_model/type/value.rb#8
def initialize(precision: T.unsafe(nil), limit: T.unsafe(nil), scale: T.unsafe(nil)); end
# source://activemodel//lib/active_model/type/value.rb#109
def ==(other); end
# source://activemodel//lib/active_model/type/value.rb#121
def assert_valid_value(_); end
# These predicates are not documented, as I need to look further into
# their use, and see if they can be removed entirely.
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/value.rb#65
def binary?; end
# Type casts a value from user input (e.g. from a setter). This value may
# be a string from the form builder, or a ruby object passed to a setter.
# There is currently no way to differentiate between which source it came
# from.
#
# The return value of this method will be returned from
# ActiveRecord::AttributeMethods::Read#read_attribute. See also:
# Value#cast_value.
#
# +value+ The raw input, as provided to the attribute setter.
#
# source://activemodel//lib/active_model/type/value.rb#45
def cast(value); end
# Determines whether a value has changed for dirty checking. +old_value+
# and +new_value+ will always be type-cast. Types should not need to
# override this method.
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/value.rb#72
def changed?(old_value, new_value, _new_value_before_type_cast); end
# Determines whether the mutable value has been modified since it was
# read. Returns +false+ by default. If your type returns an object
# which could be mutated, you should override this method. You will need
# to either:
#
# - pass +new_value+ to Value#serialize and compare it to
# +raw_old_value+
#
# or
#
# - pass +raw_old_value+ to Value#deserialize and compare it to
# +new_value+
#
# +raw_old_value+ The original value, before being passed to
# +deserialize+.
#
# +new_value+ The current value, after type casting.
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/value.rb#93
def changed_in_place?(raw_old_value, new_value); end
# Converts a value from database input to the appropriate ruby type. The
# return value of this method will be returned from
# ActiveRecord::AttributeMethods::Read#read_attribute. The default
# implementation just calls Value#cast.
#
# +value+ The raw input, as provided from the database.
#
# source://activemodel//lib/active_model/type/value.rb#31
def deserialize(value); end
# source://activemodel//lib/active_model/type/value.rb#109
def eql?(other); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/value.rb#101
def force_equality?(_value); end
# source://activemodel//lib/active_model/type/value.rb#117
def hash; end
# Returns the value of attribute limit.
#
# source://activemodel//lib/active_model/type/value.rb#6
def limit; end
# @yield [value]
#
# source://activemodel//lib/active_model/type/value.rb#105
def map(value); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/value.rb#128
def mutable?; end
# Returns the value of attribute precision.
#
# source://activemodel//lib/active_model/type/value.rb#6
def precision; end
# Returns the value of attribute scale.
#
# source://activemodel//lib/active_model/type/value.rb#6
def scale; end
# Returns true if this type can convert +value+ to a type that is usable
# by the database. For example a boolean type can return +true+ if the
# value parameter is a Ruby boolean, but may return +false+ if the value
# parameter is some other object.
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/value.rb#18
def serializable?(value); end
# Casts a value from the ruby type to a type that the database knows how
# to understand. The returned value from this method should be a
# +String+, +Numeric+, +Date+, +Time+, +Symbol+, +true+, +false+, or
# +nil+.
#
# source://activemodel//lib/active_model/type/value.rb#53
def serialize(value); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/value.rb#124
def serialized?; end
# source://activemodel//lib/active_model/type/value.rb#22
def type; end
# Type casts a value for schema dumping. This method is private, as we are
# hoping to remove it entirely.
#
# source://activemodel//lib/active_model/type/value.rb#59
def type_cast_for_schema(value); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/type/value.rb#97
def value_constructed_by_mass_assignment?(_value); end
private
# Convenience method for types which do not need separate type casting
# behavior for user and database inputs. Called by Value#cast for
# values except +nil+.
#
# source://activemodel//lib/active_model/type/value.rb#136
def cast_value(value); end
end
# Raised when unknown attributes are supplied via mass assignment.
#
# class Person
# include ActiveModel::AttributeAssignment
# include ActiveModel::Validations
# end
#
# person = Person.new
# person.assign_attributes(name: 'Gorby')
# # => ActiveModel::UnknownAttributeError: unknown attribute 'name' for Person.
#
# source://activemodel//lib/active_model/errors.rb#507
class ActiveModel::UnknownAttributeError < ::NoMethodError
# @return [UnknownAttributeError] a new instance of UnknownAttributeError
#
# source://activemodel//lib/active_model/errors.rb#510
def initialize(record, attribute); end
# Returns the value of attribute attribute.
#
# source://activemodel//lib/active_model/errors.rb#508
def attribute; end
# Returns the value of attribute record.
#
# source://activemodel//lib/active_model/errors.rb#508
def record; end
end
# source://activemodel//lib/active_model/gem_version.rb#9
module ActiveModel::VERSION; end
# source://activemodel//lib/active_model/gem_version.rb#10
ActiveModel::VERSION::MAJOR = T.let(T.unsafe(nil), Integer)
# source://activemodel//lib/active_model/gem_version.rb#11
ActiveModel::VERSION::MINOR = T.let(T.unsafe(nil), Integer)
# source://activemodel//lib/active_model/gem_version.rb#13
ActiveModel::VERSION::PRE = T.let(T.unsafe(nil), String)
# source://activemodel//lib/active_model/gem_version.rb#15
ActiveModel::VERSION::STRING = T.let(T.unsafe(nil), String)
# source://activemodel//lib/active_model/gem_version.rb#12
ActiveModel::VERSION::TINY = T.let(T.unsafe(nil), Integer)
# = Active Model ValidationError
#
# Raised by validate! when the model is invalid. Use the
# +model+ method to retrieve the record which did not validate.
#
# begin
# complex_operation_that_internally_calls_validate!
# rescue ActiveModel::ValidationError => invalid
# puts invalid.model.errors
# end
#
# source://activemodel//lib/active_model/validations.rb#425
class ActiveModel::ValidationError < ::StandardError
# @return [ValidationError] a new instance of ValidationError
#
# source://activemodel//lib/active_model/validations.rb#428
def initialize(model); end
# Returns the value of attribute model.
#
# source://activemodel//lib/active_model/validations.rb#426
def model; end
end
# == Active \Model \Validations
#
# Provides a full validation framework to your objects.
#
# A minimal implementation could be:
#
# class Person
# include ActiveModel::Validations
#
# attr_accessor :first_name, :last_name
#
# validates_each :first_name, :last_name do |record, attr, value|
# record.errors.add attr, "starts with z." if value.start_with?("z")
# end
# end
#
# Which provides you with the full standard validation stack that you
# know from Active Record:
#
# person = Person.new
# person.valid? # => true
# person.invalid? # => false
#
# person.first_name = 'zoolander'
# person.valid? # => false
# person.invalid? # => true
# person.errors.messages # => {first_name:["starts with z."]}
#
# Note that ActiveModel::Validations automatically adds an +errors+
# method to your instances initialized with a new ActiveModel::Errors
# object, so there is no need for you to do this manually.
#
# source://activemodel//lib/active_model/validations.rb#37
module ActiveModel::Validations
extend ::ActiveSupport::Concern
include GeneratedInstanceMethods
include ::ActiveSupport::Callbacks
include ::ActiveModel::Validations::HelperMethods
mixes_in_class_methods GeneratedClassMethods
mixes_in_class_methods ::ActiveModel::Validations::ClassMethods
mixes_in_class_methods ::ActiveModel::Callbacks
mixes_in_class_methods ::ActiveSupport::Callbacks::ClassMethods
mixes_in_class_methods ::ActiveSupport::DescendantsTracker
mixes_in_class_methods ::ActiveModel::Translation
mixes_in_class_methods ::ActiveModel::Validations::HelperMethods
# Returns the +Errors+ object that holds all information about attribute
# error messages.
#
# class Person
# include ActiveModel::Validations
#
# attr_accessor :name
# validates_presence_of :name
# end
#
# person = Person.new
# person.valid? # => false
# person.errors # => #
#
# source://activemodel//lib/active_model/validations.rb#301
def errors; end
# Performs the opposite of valid?. Returns +true+ if errors were
# added, +false+ otherwise.
#
# class Person
# include ActiveModel::Validations
#
# attr_accessor :name
# validates_presence_of :name
# end
#
# person = Person.new
# person.name = ''
# person.invalid? # => true
# person.name = 'david'
# person.invalid? # => false
#
# Context can optionally be supplied to define which callbacks to test
# against (the context is defined on the validations using :on).
#
# class Person
# include ActiveModel::Validations
#
# attr_accessor :name
# validates_presence_of :name, on: :new
# end
#
# person = Person.new
# person.invalid? # => false
# person.invalid?(:new) # => true
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/validations.rb#373
def invalid?(context = T.unsafe(nil)); end
# Hook method defining how an attribute value should be retrieved. By default
# this is assumed to be an instance named after the attribute. Override this
# method in subclasses should you need to retrieve the value for a given
# attribute differently:
#
# class MyClass
# include ActiveModel::Validations
#
# def initialize(data = {})
# @data = data
# end
#
# def read_attribute_for_validation(key)
# @data[key]
# end
# end
def read_attribute_for_validation(*_arg0); end
# Runs all the specified validations and returns +true+ if no errors were
# added otherwise +false+.
#
# class Person
# include ActiveModel::Validations
#
# attr_accessor :name
# validates_presence_of :name
# end
#
# person = Person.new
# person.name = ''
# person.valid? # => false
# person.name = 'david'
# person.valid? # => true
#
# Context can optionally be supplied to define which callbacks to test
# against (the context is defined on the validations using :on).
#
# class Person
# include ActiveModel::Validations
#
# attr_accessor :name
# validates_presence_of :name, on: :new
# end
#
# person = Person.new
# person.valid? # => true
# person.valid?(:new) # => false
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/validations.rb#334
def valid?(context = T.unsafe(nil)); end
# Runs all the specified validations and returns +true+ if no errors were
# added otherwise +false+.
#
# class Person
# include ActiveModel::Validations
#
# attr_accessor :name
# validates_presence_of :name
# end
#
# person = Person.new
# person.name = ''
# person.valid? # => false
# person.name = 'david'
# person.valid? # => true
#
# Context can optionally be supplied to define which callbacks to test
# against (the context is defined on the validations using :on).
#
# class Person
# include ActiveModel::Validations
#
# attr_accessor :name
# validates_presence_of :name, on: :new
# end
#
# person = Person.new
# person.valid? # => true
# person.valid?(:new) # => false
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/validations.rb#334
def validate(context = T.unsafe(nil)); end
# Runs all the validations within the specified context. Returns +true+ if
# no errors are found, raises +ValidationError+ otherwise.
#
# Validations with no :on option will run no matter the context. Validations with
# some :on option will only run in the specified context.
#
# source://activemodel//lib/active_model/validations.rb#382
def validate!(context = T.unsafe(nil)); end
# Passes the record off to the class or classes specified and allows them
# to add errors based on more complex conditions.
#
# class Person
# include ActiveModel::Validations
#
# validate :instance_validations
#
# def instance_validations
# validates_with MyValidator
# end
# end
#
# Please consult the class method documentation for more information on
# creating your own validator.
#
# You may also pass it multiple classes, like so:
#
# class Person
# include ActiveModel::Validations
#
# validate :instance_validations, on: :create
#
# def instance_validations
# validates_with MyValidator, MyOtherValidator
# end
# end
#
# Standard configuration options (:on, :if and
# :unless), which are available on the class version of
# +validates_with+, should instead be placed on the +validates+ method
# as these are applied and tested in the callback.
#
# If you pass any additional configuration options, they will be passed
# to the class and available as +options+, please refer to the
# class version of this method for more information.
#
# source://activemodel//lib/active_model/validations/with.rb#137
def validates_with(*args, &block); end
private
# Clean the +Errors+ object if instance is duped.
#
# source://activemodel//lib/active_model/validations.rb#283
def initialize_dup(other); end
# @raise [ValidationError]
#
# source://activemodel//lib/active_model/validations.rb#410
def raise_validation_error; end
# source://activemodel//lib/active_model/validations.rb#405
def run_validations!; end
module GeneratedClassMethods
def __callbacks; end
def __callbacks=(value); end
def __callbacks?; end
def _validators; end
def _validators=(value); end
def _validators?; end
end
module GeneratedInstanceMethods
def __callbacks; end
def __callbacks?; end
def _validators; end
def _validators?; end
end
end
# == \Active \Model Absence Validator
#
# source://activemodel//lib/active_model/validations/absence.rb#6
class ActiveModel::Validations::AbsenceValidator < ::ActiveModel::EachValidator
# source://activemodel//lib/active_model/validations/absence.rb#7
def validate_each(record, attr_name, value); end
end
# source://activemodel//lib/active_model/validations/acceptance.rb#5
class ActiveModel::Validations::AcceptanceValidator < ::ActiveModel::EachValidator
# @return [AcceptanceValidator] a new instance of AcceptanceValidator
#
# source://activemodel//lib/active_model/validations/acceptance.rb#6
def initialize(options); end
# source://activemodel//lib/active_model/validations/acceptance.rb#11
def validate_each(record, attribute, value); end
private
# @return [Boolean]
#
# source://activemodel//lib/active_model/validations/acceptance.rb#23
def acceptable_option?(value); end
# source://activemodel//lib/active_model/validations/acceptance.rb#18
def setup!(klass); end
end
# source://activemodel//lib/active_model/validations/acceptance.rb#27
class ActiveModel::Validations::AcceptanceValidator::LazilyDefineAttributes < ::Module
# @return [LazilyDefineAttributes] a new instance of LazilyDefineAttributes
#
# source://activemodel//lib/active_model/validations/acceptance.rb#28
def initialize(attributes); end
# source://activemodel//lib/active_model/validations/acceptance.rb#73
def ==(other); end
# source://activemodel//lib/active_model/validations/acceptance.rb#56
def define_on(klass); end
# source://activemodel//lib/active_model/validations/acceptance.rb#32
def included(klass); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/validations/acceptance.rb#51
def matches?(method_name); end
protected
# Returns the value of attribute attributes.
#
# source://activemodel//lib/active_model/validations/acceptance.rb#78
def attributes; end
end
# == Active \Model \Validation \Callbacks
#
# Provides an interface for any class to have +before_validation+ and
# +after_validation+ callbacks.
#
# First, include ActiveModel::Validations::Callbacks from the class you are
# creating:
#
# class MyModel
# include ActiveModel::Validations::Callbacks
#
# before_validation :do_stuff_before_validation
# after_validation :do_stuff_after_validation
# end
#
# Like other before_* callbacks if +before_validation+ throws
# +:abort+ then valid? will not be called.
#
# source://activemodel//lib/active_model/validations/callbacks.rb#22
module ActiveModel::Validations::Callbacks
extend ::ActiveSupport::Concern
include GeneratedInstanceMethods
include ::ActiveSupport::Callbacks
mixes_in_class_methods GeneratedClassMethods
mixes_in_class_methods ::ActiveModel::Validations::Callbacks::ClassMethods
mixes_in_class_methods ::ActiveSupport::Callbacks::ClassMethods
mixes_in_class_methods ::ActiveSupport::DescendantsTracker
private
# Override run_validations! to include callbacks.
#
# source://activemodel//lib/active_model/validations/callbacks.rb#114
def run_validations!; end
module GeneratedClassMethods
def __callbacks; end
def __callbacks=(value); end
def __callbacks?; end
end
module GeneratedInstanceMethods
def __callbacks; end
def __callbacks?; end
end
end
# source://activemodel//lib/active_model/validations/callbacks.rb#32
module ActiveModel::Validations::Callbacks::ClassMethods
# Defines a callback that will get called right after validation.
#
# class Person
# include ActiveModel::Validations
# include ActiveModel::Validations::Callbacks
#
# attr_accessor :name, :status
#
# validates_presence_of :name
#
# after_validation :set_status
#
# private
# def set_status
# self.status = errors.empty?
# end
# end
#
# person = Person.new
# person.name = ''
# person.valid? # => false
# person.status # => false
# person.name = 'bob'
# person.valid? # => true
# person.status # => true
#
# source://activemodel//lib/active_model/validations/callbacks.rb#88
def after_validation(*args, &block); end
# Defines a callback that will get called right before validation.
#
# class Person
# include ActiveModel::Validations
# include ActiveModel::Validations::Callbacks
#
# attr_accessor :name
#
# validates_length_of :name, maximum: 6
#
# before_validation :remove_whitespaces
#
# private
# def remove_whitespaces
# name.strip!
# end
# end
#
# person = Person.new
# person.name = ' bob '
# person.valid? # => true
# person.name # => "bob"
#
# source://activemodel//lib/active_model/validations/callbacks.rb#55
def before_validation(*args, &block); end
private
# source://activemodel//lib/active_model/validations/callbacks.rb#99
def set_options_for_callback(options); end
end
# source://activemodel//lib/active_model/validations.rb#55
module ActiveModel::Validations::ClassMethods
# Returns +true+ if +attribute+ is an attribute method, +false+ otherwise.
#
# class Person
# include ActiveModel::Validations
#
# attr_accessor :name
# end
#
# User.attribute_method?(:name) # => true
# User.attribute_method?(:age) # => false
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/validations.rb#270
def attribute_method?(attribute); end
# Clears all of the validators and validations.
#
# Note that this will clear anything that is being used to validate
# the model for both the +validates_with+ and +validate+ methods.
# It clears the validators that are created with an invocation of
# +validates_with+ and the callbacks that are set by an invocation
# of +validate+.
#
# class Person
# include ActiveModel::Validations
#
# validates_with MyValidator
# validates_with OtherValidator, on: :create
# validates_with StrictValidator, strict: true
# validate :cannot_be_robot
#
# def cannot_be_robot
# errors.add(:base, 'A person cannot be a robot') if person_is_robot
# end
# end
#
# Person.validators
# # => [
# # #,
# # #,
# # #
# # ]
#
# If one runs Person.clear_validators! and then checks to see what
# validators this class has, you would obtain:
#
# Person.validators # => []
#
# Also, the callback set by validate :cannot_be_robot will be erased
# so that:
#
# Person._validate_callbacks.empty? # => true
#
# source://activemodel//lib/active_model/validations.rb#234
def clear_validators!; end
# Copy validators on inheritance.
#
# source://activemodel//lib/active_model/validations.rb#275
def inherited(base); end
# Adds a validation method or block to the class. This is useful when
# overriding the +validate+ instance method becomes too unwieldy and
# you're looking for more descriptive declaration of your validations.
#
# This can be done with a symbol pointing to a method:
#
# class Comment
# include ActiveModel::Validations
#
# validate :must_be_friends
#
# def must_be_friends
# errors.add(:base, 'Must be friends to leave a comment') unless commenter.friend_of?(commentee)
# end
# end
#
# With a block which is passed with the current record to be validated:
#
# class Comment
# include ActiveModel::Validations
#
# validate do |comment|
# comment.must_be_friends
# end
#
# def must_be_friends
# errors.add(:base, 'Must be friends to leave a comment') unless commenter.friend_of?(commentee)
# end
# end
#
# Or with a block where +self+ points to the current record to be validated:
#
# class Comment
# include ActiveModel::Validations
#
# validate do
# errors.add(:base, 'Must be friends to leave a comment') unless commenter.friend_of?(commentee)
# end
# end
#
# Note that the return value of validation methods is not relevant.
# It's not possible to halt the validate callback chain.
#
# Options:
# * :on - Specifies the contexts where this validation is active.
# Runs in all validation contexts by default +nil+. You can pass a symbol
# or an array of symbols. (e.g. on: :create or
# on: :custom_validation_context or
# on: [:create, :custom_validation_context])
# * :if - Specifies a method, proc, or string to call to determine
# if the validation should occur (e.g. if: :allow_validation,
# or if: Proc.new { |user| user.signup_step > 2 }). The method,
# proc or string should return or evaluate to a +true+ or +false+ value.
# * :unless - Specifies a method, proc, or string to call to
# determine if the validation should not occur (e.g. unless: :skip_validation,
# or unless: Proc.new { |user| user.signup_step <= 2 }). The
# method, proc, or string should return or evaluate to a +true+ or +false+
# value.
#
# NOTE: Calling +validate+ multiple times on the same method will overwrite previous definitions.
#
# source://activemodel//lib/active_model/validations.rb#152
def validate(*args, &block); end
# This method is a shortcut to all default validators and any custom
# validator classes ending in 'Validator'. Note that Rails default
# validators can be overridden inside specific classes by creating
# custom validator classes in their place such as PresenceValidator.
#
# Examples of using the default rails validators:
#
# validates :username, absence: true
# validates :terms, acceptance: true
# validates :password, confirmation: true
# validates :username, exclusion: { in: %w(admin superuser) }
# validates :email, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create }
# validates :age, inclusion: { in: 0..9 }
# validates :first_name, length: { maximum: 30 }
# validates :age, numericality: true
# validates :username, presence: true
#
# The power of the +validates+ method comes when using custom validators
# and default validators in one call for a given attribute.
#
# class EmailValidator < ActiveModel::EachValidator
# def validate_each(record, attribute, value)
# record.errors.add attribute, (options[:message] || "is not an email") unless
# /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i.match?(value)
# end
# end
#
# class Person
# include ActiveModel::Validations
# attr_accessor :name, :email
#
# validates :name, presence: true, length: { maximum: 100 }
# validates :email, presence: true, email: true
# end
#
# Validator classes may also exist within the class being validated
# allowing custom modules of validators to be included as needed.
#
# class Film
# include ActiveModel::Validations
#
# class TitleValidator < ActiveModel::EachValidator
# def validate_each(record, attribute, value)
# record.errors.add attribute, "must start with 'the'" unless /\Athe/i.match?(value)
# end
# end
#
# validates :name, title: true
# end
#
# Additionally validator classes may be in another namespace and still
# used within any class.
#
# validates :name, :'film/title' => true
#
# The validators hash can also handle regular expressions, ranges, arrays
# and strings in shortcut form.
#
# validates :email, format: /@/
# validates :role, inclusion: %w(admin contributor)
# validates :password, length: 6..20
#
# When using shortcut form, ranges and arrays are passed to your
# validator's initializer as options[:in] while other types
# including regular expressions and strings are passed as options[:with].
#
# There is also a list of options that could be used along with validators:
#
# * :on - Specifies the contexts where this validation is active.
# Runs in all validation contexts by default +nil+. You can pass a symbol
# or an array of symbols. (e.g. on: :create or
# on: :custom_validation_context or
# on: [:create, :custom_validation_context])
# * :if - Specifies a method, proc, or string to call to determine
# if the validation should occur (e.g. if: :allow_validation,
# or if: Proc.new { |user| user.signup_step > 2 }). The method,
# proc or string should return or evaluate to a +true+ or +false+ value.
# * :unless - Specifies a method, proc, or string to call to determine
# if the validation should not occur (e.g. unless: :skip_validation,
# or unless: Proc.new { |user| user.signup_step <= 2 }). The
# method, proc, or string should return or evaluate to a +true+ or
# +false+ value.
# * :allow_nil - Skip validation if the attribute is +nil+.
# * :allow_blank - Skip validation if the attribute is blank.
# * :strict - If the :strict option is set to true
# will raise ActiveModel::StrictValidationFailed instead of adding the error.
# :strict option can also be set to any other exception.
#
# Example:
#
# validates :password, presence: true, confirmation: true, if: :password_required?
# validates :token, length: { is: 24 }, strict: TokenLengthException
#
#
# Finally, the options +:if+, +:unless+, +:on+, +:allow_blank+, +:allow_nil+, +:strict+
# and +:message+ can be given to one specific validator, as a hash:
#
# validates :password, presence: { if: :password_required?, message: 'is forgotten.' }, confirmation: true
#
# @raise [ArgumentError]
#
# source://activemodel//lib/active_model/validations/validates.rb#106
def validates(*attributes); end
# This method is used to define validations that cannot be corrected by end
# users and are considered exceptional. So each validator defined with bang
# or :strict option set to true will always raise
# ActiveModel::StrictValidationFailed instead of adding error
# when validation fails. See validates for more information about
# the validation itself.
#
# class Person
# include ActiveModel::Validations
#
# attr_accessor :name
# validates! :name, presence: true
# end
#
# person = Person.new
# person.name = ''
# person.valid?
# # => ActiveModel::StrictValidationFailed: Name can't be blank
#
# source://activemodel//lib/active_model/validations/validates.rb#148
def validates!(*attributes); end
# Validates each attribute against a block.
#
# class Person
# include ActiveModel::Validations
#
# attr_accessor :first_name, :last_name
#
# validates_each :first_name, :last_name, allow_blank: true do |record, attr, value|
# record.errors.add attr, "starts with z." if value.start_with?("z")
# end
# end
#
# Options:
# * :on - Specifies the contexts where this validation is active.
# Runs in all validation contexts by default +nil+. You can pass a symbol
# or an array of symbols. (e.g. on: :create or
# on: :custom_validation_context or
# on: [:create, :custom_validation_context])
# * :allow_nil - Skip validation if attribute is +nil+.
# * :allow_blank - Skip validation if attribute is blank.
# * :if - Specifies a method, proc, or string to call to determine
# if the validation should occur (e.g. if: :allow_validation,
# or if: Proc.new { |user| user.signup_step > 2 }). The method,
# proc or string should return or evaluate to a +true+ or +false+ value.
# * :unless - Specifies a method, proc, or string to call to
# determine if the validation should not occur (e.g. unless: :skip_validation,
# or unless: Proc.new { |user| user.signup_step <= 2 }). The
# method, proc, or string should return or evaluate to a +true+ or +false+
# value.
#
# source://activemodel//lib/active_model/validations.rb#85
def validates_each(*attr_names, &block); end
# Passes the record off to the class or classes specified and allows them
# to add errors based on more complex conditions.
#
# class Person
# include ActiveModel::Validations
# validates_with MyValidator
# end
#
# class MyValidator < ActiveModel::Validator
# def validate(record)
# if some_complex_logic
# record.errors.add :base, 'This record is invalid'
# end
# end
#
# private
# def some_complex_logic
# # ...
# end
# end
#
# You may also pass it multiple classes, like so:
#
# class Person
# include ActiveModel::Validations
# validates_with MyValidator, MyOtherValidator, on: :create
# end
#
# Configuration options:
# * :on - Specifies the contexts where this validation is active.
# Runs in all validation contexts by default +nil+. You can pass a symbol
# or an array of symbols. (e.g. on: :create or
# on: :custom_validation_context or
# on: [:create, :custom_validation_context])
# * :if - Specifies a method, proc, or string to call to determine
# if the validation should occur (e.g. if: :allow_validation,
# or if: Proc.new { |user| user.signup_step > 2 }).
# The method, proc, or string should return or evaluate to a +true+ or
# +false+ value.
# * :unless - Specifies a method, proc, or string to call to
# determine if the validation should not occur
# (e.g. unless: :skip_validation, or
# unless: Proc.new { |user| user.signup_step <= 2 }).
# The method, proc, or string should return or evaluate to a +true+ or
# +false+ value.
# * :strict - Specifies whether validation should be strict.
# See ActiveModel::Validations#validates! for more information.
#
# If you pass any additional configuration options, they will be passed
# to the class and available as +options+:
#
# class Person
# include ActiveModel::Validations
# validates_with MyValidator, my_custom_key: 'my custom value'
# end
#
# class MyValidator < ActiveModel::Validator
# def validate(record)
# options[:my_custom_key] # => "my custom value"
# end
# end
#
# source://activemodel//lib/active_model/validations/with.rb#81
def validates_with(*args, &block); end
# List all validators that are being used to validate the model using
# +validates_with+ method.
#
# class Person
# include ActiveModel::Validations
#
# validates_with MyValidator
# validates_with OtherValidator, on: :create
# validates_with StrictValidator, strict: true
# end
#
# Person.validators
# # => [
# # #,
# # #,
# # #
# # ]
#
# source://activemodel//lib/active_model/validations.rb#192
def validators; end
# List all validators that are being used to validate a specific attribute.
#
# class Person
# include ActiveModel::Validations
#
# attr_accessor :name, :age
#
# validates_presence_of :name
# validates_inclusion_of :age, in: 0..99
# end
#
# Person.validators_on(:name)
# # => [
# # #,
# # ]
#
# source://activemodel//lib/active_model/validations.rb#254
def validators_on(*attributes); end
private
# source://activemodel//lib/active_model/validations/validates.rb#161
def _parse_validates_options(options); end
# When creating custom validators, it might be useful to be able to specify
# additional default keys. This can be done by overwriting this method.
#
# source://activemodel//lib/active_model/validations/validates.rb#157
def _validates_default_keys; end
end
# source://activemodel//lib/active_model/validations.rb#89
ActiveModel::Validations::ClassMethods::VALID_OPTIONS_FOR_VALIDATE = T.let(T.unsafe(nil), Array)
# source://activemodel//lib/active_model/validations/clusivity.rb#7
module ActiveModel::Validations::Clusivity
# source://activemodel//lib/active_model/validations/clusivity.rb#11
def check_validity!; end
private
# source://activemodel//lib/active_model/validations/clusivity.rb#34
def delimiter; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/validations/clusivity.rb#18
def include?(record, value); end
# After Ruby 2.2, Range#include? on non-number-or-time-ish ranges checks all
# possible values in the range for equality, which is slower but more accurate.
# Range#cover? uses the previous logic of comparing a value with the range
# endpoints, which is fast but is only accurate on Numeric, Time, Date,
# or DateTime ranges.
#
# source://activemodel//lib/active_model/validations/clusivity.rb#43
def inclusion_method(enumerable); end
end
# source://activemodel//lib/active_model/validations/clusivity.rb#8
ActiveModel::Validations::Clusivity::ERROR_MESSAGE = T.let(T.unsafe(nil), String)
# source://activemodel//lib/active_model/validations/comparability.rb#5
module ActiveModel::Validations::Comparability
# source://activemodel//lib/active_model/validations/comparability.rb#21
def error_options(value, option_value); end
# source://activemodel//lib/active_model/validations/comparability.rb#10
def option_value(record, option_value); end
end
# source://activemodel//lib/active_model/validations/comparability.rb#6
ActiveModel::Validations::Comparability::COMPARE_CHECKS = T.let(T.unsafe(nil), Hash)
# source://activemodel//lib/active_model/validations/comparison.rb#7
class ActiveModel::Validations::ComparisonValidator < ::ActiveModel::EachValidator
include ::ActiveModel::Validations::Comparability
# source://activemodel//lib/active_model/validations/comparison.rb#10
def check_validity!; end
# source://activemodel//lib/active_model/validations/comparison.rb#17
def validate_each(record, attr_name, value); end
end
# source://activemodel//lib/active_model/validations/confirmation.rb#5
class ActiveModel::Validations::ConfirmationValidator < ::ActiveModel::EachValidator
# @return [ConfirmationValidator] a new instance of ConfirmationValidator
#
# source://activemodel//lib/active_model/validations/confirmation.rb#6
def initialize(options); end
# source://activemodel//lib/active_model/validations/confirmation.rb#11
def validate_each(record, attribute, value); end
private
# @return [Boolean]
#
# source://activemodel//lib/active_model/validations/confirmation.rb#31
def confirmation_value_equal?(record, attribute, value, confirmed); end
# source://activemodel//lib/active_model/validations/confirmation.rb#21
def setup!(klass); end
end
# source://activemodel//lib/active_model/validations/exclusion.rb#7
class ActiveModel::Validations::ExclusionValidator < ::ActiveModel::EachValidator
include ::ActiveModel::Validations::Clusivity
# source://activemodel//lib/active_model/validations/exclusion.rb#10
def validate_each(record, attribute, value); end
end
# source://activemodel//lib/active_model/validations/format.rb#5
class ActiveModel::Validations::FormatValidator < ::ActiveModel::EachValidator
# source://activemodel//lib/active_model/validations/format.rb#16
def check_validity!; end
# source://activemodel//lib/active_model/validations/format.rb#6
def validate_each(record, attribute, value); end
private
# source://activemodel//lib/active_model/validations/format.rb#35
def check_options_validity(name); end
# source://activemodel//lib/active_model/validations/format.rb#26
def option_call(record, name); end
# source://activemodel//lib/active_model/validations/format.rb#31
def record_error(record, attribute, name, value); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/validations/format.rb#49
def regexp_using_multiline_anchors?(regexp); end
end
# source://activemodel//lib/active_model/validations/absence.rb#12
module ActiveModel::Validations::HelperMethods
# Validates that the specified attributes are blank (as defined by
# Object#present?). Happens by default on save.
#
# class Person < ActiveRecord::Base
# validates_absence_of :first_name
# end
#
# The first_name attribute must be in the object and it must be blank.
#
# Configuration options:
# * :message - A custom error message (default is: "must be blank").
#
# There is also a list of default options supported by every validator:
# +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+.
# See ActiveModel::Validations::ClassMethods#validates for more information.
#
# source://activemodel//lib/active_model/validations/absence.rb#28
def validates_absence_of(*attr_names); end
# Encapsulates the pattern of wanting to validate the acceptance of a
# terms of service check box (or similar agreement).
#
# class Person < ActiveRecord::Base
# validates_acceptance_of :terms_of_service
# validates_acceptance_of :eula, message: 'must be abided'
# end
#
# If the database column does not exist, the +terms_of_service+ attribute
# is entirely virtual. This check is performed only if +terms_of_service+
# is not +nil+ and by default on save.
#
# Configuration options:
# * :message - A custom error message (default is: "must be
# accepted").
# * :accept - Specifies a value that is considered accepted.
# Also accepts an array of possible values. The default value is
# an array ["1", true], which makes it easy to relate to an HTML
# checkbox. This should be set to, or include, +true+ if you are validating
# a database column, since the attribute is typecast from "1" to +true+
# before validation.
#
# There is also a list of default options supported by every validator:
# +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+.
# See ActiveModel::Validations::ClassMethods#validates for more information.
#
# source://activemodel//lib/active_model/validations/acceptance.rb#108
def validates_acceptance_of(*attr_names); end
# Validates the value of a specified attribute fulfills all
# defined comparisons with another value, proc, or attribute.
#
# class Person < ActiveRecord::Base
# validates_comparison_of :value, greater_than: 'the sum of its parts'
# end
#
# Configuration options:
# * :message - A custom error message (default is: "failed comparison").
# * :greater_than - Specifies the value must be greater than the
# supplied value.
# * :greater_than_or_equal_to - Specifies the value must be
# greater than or equal to the supplied value.
# * :equal_to - Specifies the value must be equal to the supplied
# value.
# * :less_than - Specifies the value must be less than the
# supplied value.
# * :less_than_or_equal_to - Specifies the value must be less
# than or equal to the supplied value.
# * :other_than - Specifies the value must not be equal to the
# supplied value.
#
# There is also a list of default options supported by every validator:
# +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+ .
# See ActiveModel::Validations::ClassMethods#validates for more information.
#
# The validator requires at least one of the following checks to be supplied.
# Each will accept a proc, value, or a symbol which corresponds to a method:
#
# * :greater_than
# * :greater_than_or_equal_to
# * :equal_to
# * :less_than
# * :less_than_or_equal_to
# * :other_than
#
# For example:
#
# class Person < ActiveRecord::Base
# validates_comparison_of :birth_date, less_than_or_equal_to: -> { Date.today }
# validates_comparison_of :preferred_name, other_than: :given_name, allow_nil: true
# end
#
# source://activemodel//lib/active_model/validations/comparison.rb#77
def validates_comparison_of(*attr_names); end
# Encapsulates the pattern of wanting to validate a password or email
# address field with a confirmation.
#
# Model:
# class Person < ActiveRecord::Base
# validates_confirmation_of :user_name, :password
# validates_confirmation_of :email_address,
# message: 'should match confirmation'
# end
#
# View:
# <%= password_field "person", "password" %>
# <%= password_field "person", "password_confirmation" %>
#
# The added +password_confirmation+ attribute is virtual; it exists only
# as an in-memory attribute for validating the password. To achieve this,
# the validation adds accessors to the model for the confirmation
# attribute.
#
# NOTE: This check is performed only if +password_confirmation+ is not
# +nil+. To require confirmation, make sure to add a presence check for
# the confirmation attribute:
#
# validates_presence_of :password_confirmation, if: :password_changed?
#
# Configuration options:
# * :message - A custom error message (default is: "doesn't match
# %{translated_attribute_name}").
# * :case_sensitive - Looks for an exact match. Ignored by
# non-text columns (+true+ by default).
#
# There is also a list of default options supported by every validator:
# +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+.
# See ActiveModel::Validations::ClassMethods#validates for more information.
#
# source://activemodel//lib/active_model/validations/confirmation.rb#75
def validates_confirmation_of(*attr_names); end
# Validates that the value of the specified attribute is not in a
# particular enumerable object.
#
# class Person < ActiveRecord::Base
# validates_exclusion_of :username, in: %w( admin superuser ), message: "You don't belong here"
# validates_exclusion_of :age, in: 30..60, message: 'This site is only for under 30 and over 60'
# validates_exclusion_of :format, in: %w( mov avi ), message: "extension %{value} is not allowed"
# validates_exclusion_of :password, in: ->(person) { [person.username, person.first_name] },
# message: 'should not be the same as your username or first name'
# validates_exclusion_of :karma, in: :reserved_karmas
# end
#
# Configuration options:
# * :in - An enumerable object of items that the value shouldn't
# be part of. This can be supplied as a proc, lambda, or symbol which returns an
# enumerable. If the enumerable is a numerical, time, or datetime range the test
# is performed with Range#cover?, otherwise with include?. When
# using a proc or lambda the instance under validation is passed as an argument.
# * :within - A synonym(or alias) for :in
# Range#cover?, otherwise with include?.
# * :message - Specifies a custom error message (default is: "is
# reserved").
#
# There is also a list of default options supported by every validator:
# +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+.
# See ActiveModel::Validations::ClassMethods#validates for more information.
#
# source://activemodel//lib/active_model/validations/exclusion.rb#44
def validates_exclusion_of(*attr_names); end
# Validates whether the value of the specified attribute is of the correct
# form, going by the regular expression provided. You can require that the
# attribute matches the regular expression:
#
# class Person < ActiveRecord::Base
# validates_format_of :email, with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create
# end
#
# Alternatively, you can require that the specified attribute does _not_
# match the regular expression:
#
# class Person < ActiveRecord::Base
# validates_format_of :email, without: /NOSPAM/
# end
#
# You can also provide a proc or lambda which will determine the regular
# expression that will be used to validate the attribute.
#
# class Person < ActiveRecord::Base
# # Admin can have number as a first letter in their screen name
# validates_format_of :screen_name,
# with: ->(person) { person.admin? ? /\A[a-z0-9][a-z0-9_\-]*\z/i : /\A[a-z][a-z0-9_\-]*\z/i }
# end
#
# Note: use \A and \z to match the start and end of the
# string, ^ and $ match the start/end of a line.
#
# Due to frequent misuse of ^ and $, you need to pass
# the multiline: true option in case you use any of these two
# anchors in the provided regular expression. In most cases, you should be
# using \A and \z.
#
# You must pass either :with or :without as an option.
# In addition, both must be a regular expression or a proc or lambda, or
# else an exception will be raised.
#
# Configuration options:
# * :message - A custom error message (default is: "is invalid").
# * :with - Regular expression that if the attribute matches will
# result in a successful validation. This can be provided as a proc or
# lambda returning regular expression which will be called at runtime.
# * :without - Regular expression that if the attribute does not
# match will result in a successful validation. This can be provided as
# a proc or lambda returning regular expression which will be called at
# runtime.
# * :multiline - Set to true if your regular expression contains
# anchors that match the beginning or end of lines as opposed to the
# beginning or end of the string. These anchors are ^ and $.
#
# There is also a list of default options supported by every validator:
# +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+.
# See ActiveModel::Validations::ClassMethods#validates for more information.
#
# source://activemodel//lib/active_model/validations/format.rb#108
def validates_format_of(*attr_names); end
# Validates whether the value of the specified attribute is available in a
# particular enumerable object.
#
# class Person < ActiveRecord::Base
# validates_inclusion_of :role, in: %w( admin contributor )
# validates_inclusion_of :age, in: 0..99
# validates_inclusion_of :format, in: %w( jpg gif png ), message: "extension %{value} is not included in the list"
# validates_inclusion_of :states, in: ->(person) { STATES[person.country] }
# validates_inclusion_of :karma, in: :available_karmas
# end
#
# Configuration options:
# * :in - An enumerable object of available items. This can be
# supplied as a proc, lambda, or symbol which returns an enumerable. If the
# enumerable is a numerical, time, or datetime range the test is performed
# with Range#cover?, otherwise with include?. When using
# a proc or lambda the instance under validation is passed as an argument.
# * :within - A synonym(or alias) for :in
# * :message - Specifies a custom error message (default is: "is
# not included in the list").
#
# There is also a list of default options supported by every validator:
# +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+.
# See ActiveModel::Validations::ClassMethods#validates for more information.
#
# source://activemodel//lib/active_model/validations/inclusion.rb#42
def validates_inclusion_of(*attr_names); end
# Validates that the specified attributes match the length restrictions
# supplied. Only one constraint option can be used at a time apart from
# +:minimum+ and +:maximum+ that can be combined together:
#
# class Person < ActiveRecord::Base
# validates_length_of :first_name, maximum: 30
# validates_length_of :last_name, maximum: 30, message: "less than 30 if you don't mind"
# validates_length_of :fax, in: 7..32, allow_nil: true
# validates_length_of :phone, in: 7..32, allow_blank: true
# validates_length_of :user_name, within: 6..20, too_long: 'pick a shorter name', too_short: 'pick a longer name'
# validates_length_of :zip_code, minimum: 5, too_short: 'please enter at least 5 characters'
# validates_length_of :smurf_leader, is: 4, message: "papa is spelled with 4 characters... don't play me."
# validates_length_of :words_in_essay, minimum: 100, too_short: 'Your essay must be at least 100 words.'
#
# private
# def words_in_essay
# essay.scan(/\w+/)
# end
# end
#
# Constraint options:
#
# * :minimum - The minimum size of the attribute.
# * :maximum - The maximum size of the attribute. Allows +nil+ by
# default if not used with +:minimum+.
# * :is - The exact size of the attribute.
# * :within - A range specifying the minimum and maximum size of
# the attribute.
# * :in - A synonym (or alias) for :within.
#
# Other options:
#
# * :allow_nil - Attribute may be +nil+; skip validation.
# * :allow_blank - Attribute may be blank; skip validation.
# * :too_long - The error message if the attribute goes over the
# maximum (default is: "is too long (maximum is %{count} characters)").
# * :too_short - The error message if the attribute goes under the
# minimum (default is: "is too short (minimum is %{count} characters)").
# * :wrong_length - The error message if using the :is
# method and the attribute is the wrong size (default is: "is the wrong
# length (should be %{count} characters)").
# * :message - The error message to use for a :minimum,
# :maximum, or :is violation. An alias of the appropriate
# too_long/too_short/wrong_length message.
#
# There is also a list of default options supported by every validator:
# +:if+, +:unless+, +:on+, and +:strict+.
# See ActiveModel::Validations::ClassMethods#validates for more information.
#
# source://activemodel//lib/active_model/validations/length.rb#121
def validates_length_of(*attr_names); end
# Validates whether the value of the specified attribute is numeric by
# trying to convert it to a float with Kernel.Float (if only_integer
# is +false+) or applying it to the regular expression /\A[\+\-]?\d+\z/
# (if only_integer is set to +true+). Precision of Kernel.Float values
# are guaranteed up to 15 digits.
#
# class Person < ActiveRecord::Base
# validates_numericality_of :value, on: :create
# end
#
# Configuration options:
# * :message - A custom error message (default is: "is not a number").
# * :only_integer - Specifies whether the value has to be an
# integer (default is +false+).
# * :allow_nil - Skip validation if attribute is +nil+ (default is
# +false+). Notice that for Integer and Float columns empty strings are
# converted to +nil+.
# * :greater_than - Specifies the value must be greater than the
# supplied value.
# * :greater_than_or_equal_to - Specifies the value must be
# greater than or equal the supplied value.
# * :equal_to - Specifies the value must be equal to the supplied
# value.
# * :less_than - Specifies the value must be less than the
# supplied value.
# * :less_than_or_equal_to - Specifies the value must be less
# than or equal the supplied value.
# * :other_than - Specifies the value must be other than the
# supplied value.
# * :odd - Specifies the value must be an odd number.
# * :even - Specifies the value must be an even number.
# * :in - Check that the value is within a range.
#
# There is also a list of default options supported by every validator:
# +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+ .
# See ActiveModel::Validations::ClassMethods#validates for more information.
#
# The following checks can also be supplied with a proc or a symbol which
# corresponds to a method:
#
# * :greater_than
# * :greater_than_or_equal_to
# * :equal_to
# * :less_than
# * :less_than_or_equal_to
# * :only_integer
# * :other_than
#
# For example:
#
# class Person < ActiveRecord::Base
# validates_numericality_of :width, less_than: ->(person) { person.height }
# validates_numericality_of :width, greater_than: :minimum_weight
# end
#
# source://activemodel//lib/active_model/validations/numericality.rb#205
def validates_numericality_of(*attr_names); end
# Validates that the specified attributes are not blank (as defined by
# Object#blank?). Happens by default on save.
#
# class Person < ActiveRecord::Base
# validates_presence_of :first_name
# end
#
# The first_name attribute must be in the object and it cannot be blank.
#
# If you want to validate the presence of a boolean field (where the real
# values are +true+ and +false+), you will want to use
# validates_inclusion_of :field_name, in: [true, false].
#
# This is due to the way Object#blank? handles boolean values:
# false.blank? # => true.
#
# Configuration options:
# * :message - A custom error message (default is: "can't be blank").
#
# There is also a list of default options supported by every validator:
# +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+.
# See ActiveModel::Validations::ClassMethods#validates for more information.
#
# source://activemodel//lib/active_model/validations/presence.rb#34
def validates_presence_of(*attr_names); end
# Validates that the specified attributes match the length restrictions
# supplied. Only one constraint option can be used at a time apart from
# +:minimum+ and +:maximum+ that can be combined together:
#
# class Person < ActiveRecord::Base
# validates_length_of :first_name, maximum: 30
# validates_length_of :last_name, maximum: 30, message: "less than 30 if you don't mind"
# validates_length_of :fax, in: 7..32, allow_nil: true
# validates_length_of :phone, in: 7..32, allow_blank: true
# validates_length_of :user_name, within: 6..20, too_long: 'pick a shorter name', too_short: 'pick a longer name'
# validates_length_of :zip_code, minimum: 5, too_short: 'please enter at least 5 characters'
# validates_length_of :smurf_leader, is: 4, message: "papa is spelled with 4 characters... don't play me."
# validates_length_of :words_in_essay, minimum: 100, too_short: 'Your essay must be at least 100 words.'
#
# private
# def words_in_essay
# essay.scan(/\w+/)
# end
# end
#
# Constraint options:
#
# * :minimum - The minimum size of the attribute.
# * :maximum - The maximum size of the attribute. Allows +nil+ by
# default if not used with +:minimum+.
# * :is - The exact size of the attribute.
# * :within - A range specifying the minimum and maximum size of
# the attribute.
# * :in - A synonym (or alias) for :within.
#
# Other options:
#
# * :allow_nil - Attribute may be +nil+; skip validation.
# * :allow_blank - Attribute may be blank; skip validation.
# * :too_long - The error message if the attribute goes over the
# maximum (default is: "is too long (maximum is %{count} characters)").
# * :too_short - The error message if the attribute goes under the
# minimum (default is: "is too short (minimum is %{count} characters)").
# * :wrong_length - The error message if using the :is
# method and the attribute is the wrong size (default is: "is the wrong
# length (should be %{count} characters)").
# * :message - The error message to use for a :minimum,
# :maximum, or :is violation. An alias of the appropriate
# too_long/too_short/wrong_length message.
#
# There is also a list of default options supported by every validator:
# +:if+, +:unless+, +:on+, and +:strict+.
# See ActiveModel::Validations::ClassMethods#validates for more information.
#
# source://activemodel//lib/active_model/validations/length.rb#121
def validates_size_of(*attr_names); end
private
# source://activemodel//lib/active_model/validations/helper_methods.rb#7
def _merge_attributes(attr_names); end
end
# source://activemodel//lib/active_model/validations/inclusion.rb#7
class ActiveModel::Validations::InclusionValidator < ::ActiveModel::EachValidator
include ::ActiveModel::Validations::Clusivity
# source://activemodel//lib/active_model/validations/inclusion.rb#10
def validate_each(record, attribute, value); end
end
# source://activemodel//lib/active_model/validations/length.rb#5
class ActiveModel::Validations::LengthValidator < ::ActiveModel::EachValidator
# @return [LengthValidator] a new instance of LengthValidator
#
# source://activemodel//lib/active_model/validations/length.rb#11
def initialize(options); end
# source://activemodel//lib/active_model/validations/length.rb#24
def check_validity!; end
# source://activemodel//lib/active_model/validations/length.rb#40
def validate_each(record, attribute, value); end
private
# @return [Boolean]
#
# source://activemodel//lib/active_model/validations/length.rb#67
def skip_nil_check?(key); end
end
# source://activemodel//lib/active_model/validations/length.rb#7
ActiveModel::Validations::LengthValidator::CHECKS = T.let(T.unsafe(nil), Hash)
# source://activemodel//lib/active_model/validations/length.rb#6
ActiveModel::Validations::LengthValidator::MESSAGES = T.let(T.unsafe(nil), Hash)
# source://activemodel//lib/active_model/validations/length.rb#9
ActiveModel::Validations::LengthValidator::RESERVED_OPTIONS = T.let(T.unsafe(nil), Array)
# source://activemodel//lib/active_model/validations/numericality.rb#8
class ActiveModel::Validations::NumericalityValidator < ::ActiveModel::EachValidator
include ::ActiveModel::Validations::Comparability
# source://activemodel//lib/active_model/validations/numericality.rb#20
def check_validity!; end
# source://activemodel//lib/active_model/validations/numericality.rb#34
def validate_each(record, attr_name, value, precision: T.unsafe(nil), scale: T.unsafe(nil)); end
private
# @return [Boolean]
#
# source://activemodel//lib/active_model/validations/numericality.rb#112
def allow_only_integer?(record); end
# source://activemodel//lib/active_model/validations/numericality.rb#106
def filtered_options(value); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/validations/numericality.rb#102
def is_hexadecimal_literal?(raw_value); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/validations/numericality.rb#98
def is_integer?(raw_value); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/validations/numericality.rb#92
def is_number?(raw_value, precision, scale); end
# source://activemodel//lib/active_model/validations/numericality.rb#66
def option_as_number(record, option_value, precision, scale); end
# source://activemodel//lib/active_model/validations/numericality.rb#70
def parse_as_number(raw_value, precision, scale); end
# source://activemodel//lib/active_model/validations/numericality.rb#84
def parse_float(raw_value, precision, scale); end
# source://activemodel//lib/active_model/validations/numericality.rb#123
def prepare_value_for_validation(value, record, attr_name); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/validations/numericality.rb#144
def record_attribute_changed_in_place?(record, attr_name); end
# source://activemodel//lib/active_model/validations/numericality.rb#88
def round(raw_value, scale); end
end
# source://activemodel//lib/active_model/validations/numericality.rb#18
ActiveModel::Validations::NumericalityValidator::HEXADECIMAL_REGEX = T.let(T.unsafe(nil), Regexp)
# source://activemodel//lib/active_model/validations/numericality.rb#16
ActiveModel::Validations::NumericalityValidator::INTEGER_REGEX = T.let(T.unsafe(nil), Regexp)
# source://activemodel//lib/active_model/validations/numericality.rb#12
ActiveModel::Validations::NumericalityValidator::NUMBER_CHECKS = T.let(T.unsafe(nil), Hash)
# source://activemodel//lib/active_model/validations/numericality.rb#11
ActiveModel::Validations::NumericalityValidator::RANGE_CHECKS = T.let(T.unsafe(nil), Hash)
# source://activemodel//lib/active_model/validations/numericality.rb#14
ActiveModel::Validations::NumericalityValidator::RESERVED_OPTIONS = T.let(T.unsafe(nil), Array)
# source://activemodel//lib/active_model/validations/presence.rb#5
class ActiveModel::Validations::PresenceValidator < ::ActiveModel::EachValidator
# source://activemodel//lib/active_model/validations/presence.rb#6
def validate_each(record, attr_name, value); end
end
# source://activemodel//lib/active_model/validations/with.rb#7
class ActiveModel::Validations::WithValidator < ::ActiveModel::EachValidator
# source://activemodel//lib/active_model/validations/with.rb#8
def validate_each(record, attr, val); end
end
# == Active \Model \Validator
#
# A simple base class that can be used along with
# ActiveModel::Validations::ClassMethods.validates_with
#
# class Person
# include ActiveModel::Validations
# validates_with MyValidator
# end
#
# class MyValidator < ActiveModel::Validator
# def validate(record)
# if some_complex_logic
# record.errors.add(:base, "This record is invalid")
# end
# end
#
# private
# def some_complex_logic
# # ...
# end
# end
#
# Any class that inherits from ActiveModel::Validator must implement a method
# called +validate+ which accepts a +record+.
#
# class Person
# include ActiveModel::Validations
# validates_with MyValidator
# end
#
# class MyValidator < ActiveModel::Validator
# def validate(record)
# record # => The person instance being validated
# options # => Any non-standard options passed to validates_with
# end
# end
#
# To cause a validation error, you must add to the +record+'s errors directly
# from within the validators message.
#
# class MyValidator < ActiveModel::Validator
# def validate(record)
# record.errors.add :base, "This is some custom error message"
# record.errors.add :first_name, "This is some complex validation"
# # etc...
# end
# end
#
# To add behavior to the initialize method, use the following signature:
#
# class MyValidator < ActiveModel::Validator
# def initialize(options)
# super
# @my_custom_field = options[:field_name] || :first_name
# end
# end
#
# Note that the validator is initialized only once for the whole application
# life cycle, and not on each validation run.
#
# The easiest way to add custom validators for validating individual attributes
# is with the convenient ActiveModel::EachValidator.
#
# class TitleValidator < ActiveModel::EachValidator
# def validate_each(record, attribute, value)
# record.errors.add attribute, 'must be Mr., Mrs., or Dr.' unless %w(Mr. Mrs. Dr.).include?(value)
# end
# end
#
# This can now be used in combination with the +validates+ method
# (see ActiveModel::Validations::ClassMethods#validates for more on this).
#
# class Person
# include ActiveModel::Validations
# attr_accessor :title
#
# validates :title, presence: true, title: true
# end
#
# It can be useful to access the class that is using that validator when there are prerequisites such
# as an +attr_accessor+ being present. This class is accessible via options[:class] in the constructor.
# To set up your validator override the constructor.
#
# class MyValidator < ActiveModel::Validator
# def initialize(options={})
# super
# options[:class].attr_accessor :custom_attribute
# end
# end
#
# source://activemodel//lib/active_model/validator.rb#96
class ActiveModel::Validator
# Accepts options that will be made available through the +options+ reader.
#
# @return [Validator] a new instance of Validator
#
# source://activemodel//lib/active_model/validator.rb#108
def initialize(options = T.unsafe(nil)); end
# Returns the kind for this validator.
#
# PresenceValidator.new(attributes: [:username]).kind # => :presence
# AcceptanceValidator.new(attributes: [:terms]).kind # => :acceptance
#
# source://activemodel//lib/active_model/validator.rb#116
def kind; end
# Returns the value of attribute options.
#
# source://activemodel//lib/active_model/validator.rb#97
def options; end
# Override this method in subclasses with validation logic, adding errors
# to the records +errors+ array where necessary.
#
# @raise [NotImplementedError]
#
# source://activemodel//lib/active_model/validator.rb#122
def validate(record); end
class << self
# Returns the kind of the validator.
#
# PresenceValidator.kind # => :presence
# AcceptanceValidator.kind # => :acceptance
#
# source://activemodel//lib/active_model/validator.rb#103
def kind; end
end
end