repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/sheep.rb | activemodel/test/models/sheep.rb | # frozen_string_literal: true
class Sheep
extend ActiveModel::Naming
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/topic.rb | activemodel/test/models/topic.rb | # frozen_string_literal: true
class Topic
include ActiveModel::Validations
include ActiveModel::Validations::Callbacks
include ActiveModel::AttributeMethods
include ActiveSupport::NumberHelper
attribute_method_suffix "_before_type_cast", parameters: false
define_attribute_method :price
def self._valida... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/account.rb | activemodel/test/models/account.rb | # frozen_string_literal: true
class Account
include ActiveModel::ForbiddenAttributesProtection
public :sanitize_for_mass_assignment
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/argonaut.rb | activemodel/test/models/argonaut.rb | # frozen_string_literal: true
class Argonaut
include ActiveModel::SecurePassword
include ActiveModel::Attributes
attribute :password_digest
has_secure_password algorithm: :argon2
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/helicopter.rb | activemodel/test/models/helicopter.rb | # frozen_string_literal: true
class Helicopter
include ActiveModel::Conversion
end
class Helicopter::Comanche
include ActiveModel::Conversion
end
class Helicopter::Apache
include ActiveModel::Conversion
class << self
def model_name
@model_name ||= ActiveModel::Name.new(self).tap do |model_name|
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/person_with_validator.rb | activemodel/test/models/person_with_validator.rb | # frozen_string_literal: true
class PersonWithValidator
include ActiveModel::Validations
class PresenceValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, message: "Local validator#{options[:custom]}") if value.blank?
end
end
class Lik... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/custom_reader.rb | activemodel/test/models/custom_reader.rb | # frozen_string_literal: true
class CustomReader
include ActiveModel::Validations
def initialize(data = {})
@data = data
end
def []=(key, value)
@data[key] = value
end
def read_attribute_for_validation(key)
@data[key]
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/address.rb | activemodel/test/models/address.rb | # frozen_string_literal: true
class Address
include ActiveModel::Serializers::JSON
attr_accessor :address_line, :city, :state, :country
def initialize(options = {})
options.each { |name, value| public_send("#{name}=", value) }
end
def attributes
instance_values
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/track_back.rb | activemodel/test/models/track_back.rb | # frozen_string_literal: true
class Post
class TrackBack
def to_model
NamedTrackBack.new
end
end
class NamedTrackBack
extend ActiveModel::Naming
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/slow_pilot.rb | activemodel/test/models/slow_pilot.rb | # frozen_string_literal: true
class SlowPilot
include ActiveModel::SecurePassword
def self.generates_token_for(purpose, expires_in: nil, &)
@@expires_in = expires_in
end
def generate_token_for(purpose)
"#{purpose}-token-#{@@expires_in}"
end
has_secure_password reset_token: { expires_in: 1.hour }... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/pilot.rb | activemodel/test/models/pilot.rb | # frozen_string_literal: true
class Pilot
include ActiveModel::Attributes
include ActiveModel::SecurePassword
def self.generates_token_for(purpose, expires_in: nil, &)
@@expires_in = expires_in
end
def self.find_by_token_for(purpose, token)
"finding-for-#{purpose}-by-#{token}"
end
def self.fin... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/visitor.rb | activemodel/test/models/visitor.rb | # frozen_string_literal: true
class Visitor
extend ActiveModel::Callbacks
include ActiveModel::SecurePassword
define_model_callbacks :create
has_secure_password(validations: false)
attr_accessor :password_digest
attr_reader :password_confirmation
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/contact.rb | activemodel/test/models/contact.rb | # frozen_string_literal: true
class Contact
extend ActiveModel::Naming
include ActiveModel::Conversion
include ActiveModel::Validations
include ActiveModel::Serializers::JSON
attr_accessor :id, :name, :age, :created_at, :awesome, :preferences
attr_accessor :address, :friends, :contact
def social
%... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/person.rb | activemodel/test/models/person.rb | # frozen_string_literal: true
class Person
include ActiveModel::Validations
extend ActiveModel::Translation
attr_accessor :title, :karma, :salary, :gender
def condition_is_true
true
end
def condition_is_false
false
end
end
class Person::Gender
extend ActiveModel::Translation
end
class Chi... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/reply.rb | activemodel/test/models/reply.rb | # frozen_string_literal: true
require "models/topic"
class Reply < Topic
validate :errors_on_empty_content
validate :title_is_wrong_create, on: :create
validate :check_empty_title
validate :check_content_mismatch, on: :create
validate :check_wrong_update, on: :update
def check_empty_title
error... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/blog_post.rb | activemodel/test/models/blog_post.rb | # frozen_string_literal: true
module Blog
def self.use_relative_model_naming?
true
end
class Post
extend ActiveModel::Naming
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/test/models/user.rb | activemodel/test/models/user.rb | # frozen_string_literal: true
class User
extend ActiveModel::Callbacks
include ActiveModel::Attributes
include ActiveModel::Dirty
include ActiveModel::SecurePassword
define_model_callbacks :create
attribute :password_digest
has_secure_password
attribute :recovery_password_digest
has_secure_passwor... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model.rb | activemodel/lib/active_model.rb | # frozen_string_literal: true
#--
# Copyright (c) David Heinemeier Hansson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/attributes.rb | activemodel/lib/active_model/attributes.rb | # frozen_string_literal: true
module ActiveModel
# = Active \Model \Attributes
#
# The Attributes module allows models to define attributes beyond simple Ruby
# readers and writers. Similar to Active Record attributes, which are
# typically inferred from the database schema, Active Model Attributes are
# a... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/nested_error.rb | activemodel/lib/active_model/nested_error.rb | # frozen_string_literal: true
require "active_model/error"
module ActiveModel
class NestedError < Error
def initialize(base, inner_error, override_options = {})
@base = base
@inner_error = inner_error
@attribute = override_options.fetch(:attribute) { inner_error.attribute }
@type = overr... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/attribute_set.rb | activemodel/lib/active_model/attribute_set.rb | # frozen_string_literal: true
require "active_support/core_ext/enumerable"
require "active_support/core_ext/object/deep_dup"
require "active_model/attribute_set/builder"
require "active_model/attribute_set/yaml_encoder"
module ActiveModel
class AttributeSet # :nodoc:
delegate :each_value, :fetch, :except, to: :... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/version.rb | activemodel/lib/active_model/version.rb | # frozen_string_literal: true
require_relative "gem_version"
module ActiveModel
# Returns the currently loaded version of \Active \Model as a +Gem::Version+.
def self.version
gem_version
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/serialization.rb | activemodel/lib/active_model/serialization.rb | # frozen_string_literal: true
require "active_support/core_ext/enumerable"
module ActiveModel
# = Active \Model \Serialization
#
# Provides a basic serialization to a serializable_hash for your objects.
#
# A minimal implementation could be:
#
# class Person
# include ActiveModel::Serialization
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/errors.rb | activemodel/lib/active_model/errors.rb | # frozen_string_literal: true
require "active_support/core_ext/array/conversions"
require "active_support/core_ext/string/inflections"
require "active_support/core_ext/object/deep_dup"
require "active_model/error"
require "active_model/nested_error"
module ActiveModel
# = Active \Model \Errors
#
# Provides erro... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type.rb | activemodel/lib/active_model/type.rb | # frozen_string_literal: true
require "active_model/type/helpers"
require "active_model/type/serialize_cast_value"
require "active_model/type/value"
require "active_model/type/big_integer"
require "active_model/type/binary"
require "active_model/type/boolean"
require "active_model/type/date"
require "active_model/typ... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/translation.rb | activemodel/lib/active_model/translation.rb | # frozen_string_literal: true
module ActiveModel
# = 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
#
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/attribute.rb | activemodel/lib/active_model/attribute.rb | # frozen_string_literal: true
require "active_support/core_ext/object/duplicable"
module ActiveModel
class Attribute # :nodoc:
class << self
def from_database(name, value_before_type_cast, type, value = nil)
FromDatabase.new(name, value_before_type_cast, type, nil, value)
end
def from... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/secure_password.rb | activemodel/lib/active_model/secure_password.rb | # frozen_string_literal: true
require "active_model/secure_password/bcrypt_password"
require "active_model/secure_password/argon2_password"
require "active_support/core_ext/numeric/time"
module ActiveModel
module SecurePassword
extend ActiveSupport::Concern
DEFAULT_RESET_TOKEN_EXPIRES_IN = 15.minutes
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/attribute_methods.rb | activemodel/lib/active_model/attribute_methods.rb | # frozen_string_literal: true
require "concurrent/map"
module ActiveModel
# 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... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/callbacks.rb | activemodel/lib/active_model/callbacks.rb | # frozen_string_literal: true
require "active_support/core_ext/array/extract_options"
require "active_support/core_ext/hash/keys"
module ActiveModel
# = Active \Model \Callbacks
#
# Provides an interface for any class to have Active Record like callbacks.
#
# Like the Active Record methods, the callback cha... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations.rb | activemodel/lib/active_model/validations.rb | # frozen_string_literal: true
require "active_support/core_ext/array/extract_options"
module ActiveModel
# = Active \Model \Validations
#
# Provides a full validation framework to your objects.
#
# A minimal implementation could be:
#
# class Person
# include ActiveModel::Validations
#
# ... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/railtie.rb | activemodel/lib/active_model/railtie.rb | # frozen_string_literal: true
require "rails"
require "active_model"
module ActiveModel
class Railtie < Rails::Railtie # :nodoc:
config.eager_load_namespaces << ActiveModel
config.active_model = ActiveSupport::OrderedOptions.new
initializer "active_model.deprecator", before: :load_environment_config d... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/api.rb | activemodel/lib/active_model/api.rb | # frozen_string_literal: true
module ActiveModel
# = 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 tha... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/access.rb | activemodel/lib/active_model/access.rb | # frozen_string_literal: true
require "active_support/core_ext/enumerable"
require "active_support/core_ext/hash/indifferent_access"
module ActiveModel
module Access # :nodoc:
def slice(*methods)
methods.flatten.index_with { |method| public_send(method) }.with_indifferent_access
end
def values_at... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/lint.rb | activemodel/lib/active_model/lint.rb | # frozen_string_literal: true
module ActiveModel
module Lint
# == 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 co... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/attribute_mutation_tracker.rb | activemodel/lib/active_model/attribute_mutation_tracker.rb | # frozen_string_literal: true
require "active_support/core_ext/hash/indifferent_access"
require "active_support/core_ext/object/duplicable"
module ActiveModel
class AttributeMutationTracker # :nodoc:
OPTION_NOT_GIVEN = Object.new.freeze
def initialize(attributes)
@attributes = attributes
end
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validator.rb | activemodel/lib/active_model/validator.rb | # frozen_string_literal: true
require "active_support/core_ext/module/anonymous"
module ActiveModel
# = Active \Model \Validator
#
# A simple base class that can be used along with
# ActiveModel::Validations::ClassMethods.validates_with
#
# class Person
# include ActiveModel::Validations
# v... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/schematized_json.rb | activemodel/lib/active_model/schematized_json.rb | # frozen_string_literal: true
require "active_support/core_ext/hash/reverse_merge"
require "active_support/core_ext/symbol/starts_ends_with"
module ActiveModel
module SchematizedJson
extend ActiveSupport::Concern
module ClassMethods
# Provides a schema-enforced access object for a JSON attribute. Thi... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/forbidden_attributes_protection.rb | activemodel/lib/active_model/forbidden_attributes_protection.rb | # frozen_string_literal: true
module ActiveModel
# = Active \Model \ForbiddenAttributesError
#
# Raised when forbidden attributes are used for mass assignment.
#
# class Person < ActiveRecord::Base
# end
#
# params = ActionController::Parameters.new(name: 'Bob')
# Person.new(params)
# # =... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/deprecator.rb | activemodel/lib/active_model/deprecator.rb | # frozen_string_literal: true
module ActiveModel
def self.deprecator # :nodoc:
@deprecator ||= ActiveSupport::Deprecation.new
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/conversion.rb | activemodel/lib/active_model/conversion.rb | # frozen_string_literal: true
module ActiveModel
# = 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
#
# # Conta... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/attribute_assignment.rb | activemodel/lib/active_model/attribute_assignment.rb | # frozen_string_literal: true
require "active_support/core_ext/hash/keys"
module ActiveModel
module 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 t... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/gem_version.rb | activemodel/lib/active_model/gem_version.rb | # frozen_string_literal: true
module ActiveModel
# Returns the currently loaded version of \Active \Model as a +Gem::Version+.
def self.gem_version
Gem::Version.new VERSION::STRING
end
module VERSION
MAJOR = 8
MINOR = 2
TINY = 0
PRE = "alpha"
STRING = [MAJOR, MINOR, TINY, PRE].comp... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/model.rb | activemodel/lib/active_model/model.rb | # frozen_string_literal: true
module ActiveModel
# = 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 functionalitie... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/error.rb | activemodel/lib/active_model/error.rb | # frozen_string_literal: true
module ActiveModel
# = Active \Model \Error
#
# Represents one single error
class Error
CALLBACKS_OPTIONS = [:if, :unless, :on, :allow_nil, :allow_blank, :strict]
MESSAGE_OPTIONS = [:message]
class_attribute :i18n_customize_full_message, default: false
def self.... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/attribute_registration.rb | activemodel/lib/active_model/attribute_registration.rb | # frozen_string_literal: true
require "active_support/core_ext/class/subclasses"
require "active_model/attribute_set"
require "active_model/attribute/user_provided_default"
module ActiveModel
module AttributeRegistration # :nodoc:
extend ActiveSupport::Concern
module ClassMethods # :nodoc:
def attrib... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/naming.rb | activemodel/lib/active_model/naming.rb | # frozen_string_literal: true
require "active_support/core_ext/hash/except"
require "active_support/core_ext/module/introspection"
require "active_support/core_ext/module/redefine_method"
module ActiveModel
class Name
include Comparable
attr_accessor :singular, :plural, :element, :collection,
:singul... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/dirty.rb | activemodel/lib/active_model/dirty.rb | # frozen_string_literal: true
require "active_model/attribute_mutation_tracker"
module ActiveModel
# = 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:
#
# * <tt>include Active... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/serializers/json.rb | activemodel/lib/active_model/serializers/json.rb | # frozen_string_literal: true
require "active_support/json"
module ActiveModel
module Serializers
# = Active \Model \JSON \Serializer
module JSON
extend ActiveSupport::Concern
include ActiveModel::Serialization
included do
extend ActiveModel::Naming
class_attribute :inclu... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/value.rb | activemodel/lib/active_model/type/value.rb | # frozen_string_literal: true
module ActiveModel
module Type
# = Active Model \Value \Type
#
# The base class for all attribute types. This class also serves as the
# default type for attributes that do not specify a type.
class Value
include SerializeCastValue
attr_reader :precision,... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/binary.rb | activemodel/lib/active_model/type/binary.rb | # frozen_string_literal: true
module ActiveModel
module Type
# = Active Model \Binary \Type
#
# Attribute type for representation of binary data. This type is registered
# under the +:binary+ key.
#
# Non-string values are coerced to strings using their +to_s+ method.
class Binary < Value... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/decimal.rb | activemodel/lib/active_model/type/decimal.rb | # frozen_string_literal: true
require "bigdecimal/util"
module ActiveModel
module Type
# = Active Model \Decimal \Type
#
# Attribute type for decimal, high-precision floating point numeric
# representation. It is registered under the +:decimal+ key.
#
# class BagOfCoffee
# include ... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/time.rb | activemodel/lib/active_model/type/time.rb | # frozen_string_literal: true
module ActiveModel
module Type
# = Active Model \Time \Type
#
# Attribute type for time of day representation. It is registered under the
# +:time+ key.
#
# class Event
# include ActiveModel::Attributes
#
# attribute :start, :time
# en... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/float.rb | activemodel/lib/active_model/type/float.rb | # frozen_string_literal: true
require "active_support/core_ext/object/try"
module ActiveModel
module Type
# = Active Model \Float \Type
#
# Attribute type for floating point numeric values. It is registered under
# the +:float+ key.
#
# class BagOfCoffee
# include ActiveModel::Attr... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/registry.rb | activemodel/lib/active_model/type/registry.rb | # frozen_string_literal: true
module ActiveModel
module Type
class Registry # :nodoc:
def initialize
@registrations = {}
end
def initialize_copy(other)
@registrations = @registrations.dup
super
end
def register(type_name, klass = nil, &block)
unless... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/boolean.rb | activemodel/lib/active_model/type/boolean.rb | # frozen_string_literal: true
module ActiveModel
module Type
# = Active Model \Boolean \Type
#
# A class that behaves like a boolean type, including rules for coercion of
# user input.
#
# - <tt>"false"</tt>, <tt>"f"</tt>, <tt>"0"</tt>, +0+ or any other value in
# +FALSE_VALUES+ will be... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/immutable_string.rb | activemodel/lib/active_model/type/immutable_string.rb | # frozen_string_literal: true
module ActiveModel
module Type
# = Active Model \ImmutableString \Type
#
# Attribute type to represent immutable strings. It casts incoming values to
# frozen strings.
#
# class Person
# include ActiveModel::Attributes
#
# attribute :name, :... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/helpers.rb | activemodel/lib/active_model/type/helpers.rb | # frozen_string_literal: true
require "active_model/type/helpers/accepts_multiparameter_time"
require "active_model/type/helpers/numeric"
require "active_model/type/helpers/mutable"
require "active_model/type/helpers/immutable"
require "active_model/type/helpers/time_value"
require "active_model/type/helpers/timezone"... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/big_integer.rb | activemodel/lib/active_model/type/big_integer.rb | # frozen_string_literal: true
require "active_model/type/integer"
module ActiveModel
module Type
# = Active Model \BigInteger \Type
#
# Attribute type for integers that can be serialized to an unlimited number
# of bytes. This type is registered under the +:big_integer+ key.
#
# class Pers... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/string.rb | activemodel/lib/active_model/type/string.rb | # frozen_string_literal: true
require "active_model/type/immutable_string"
module ActiveModel
module Type
# = Active Model \String \Type
#
# Attribute type for strings. It is registered under the +:string+ key.
#
# This class is a specialization of ActiveModel::Type::ImmutableString. It
# pe... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/integer.rb | activemodel/lib/active_model/type/integer.rb | # frozen_string_literal: true
module ActiveModel
module Type
# = Active Model \Integer \Type
#
# Attribute type for integer representation. This type is registered under
# the +:integer+ key.
#
# class Person
# include ActiveModel::Attributes
#
# attribute :age, :integer... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/serialize_cast_value.rb | activemodel/lib/active_model/type/serialize_cast_value.rb | # frozen_string_literal: true
module ActiveModel
module Type
module SerializeCastValue # :nodoc:
extend ActiveSupport::Concern
module ClassMethods
def serialize_cast_value_compatible?
return @serialize_cast_value_compatible if defined?(@serialize_cast_value_compatible)
@s... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/date_time.rb | activemodel/lib/active_model/type/date_time.rb | # frozen_string_literal: true
module ActiveModel
module Type
# = Active Model \DateTime \Type
#
# Attribute type to represent dates and times. It is registered under the
# +:datetime+ key.
#
# class Event
# include ActiveModel::Attributes
#
# attribute :start, :datetime
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/date.rb | activemodel/lib/active_model/type/date.rb | # frozen_string_literal: true
module ActiveModel
module Type
# = Active Model \Date \Type
#
# Attribute type for date representation. It is registered under the
# +:date+ key.
#
# class Person
# include ActiveModel::Attributes
#
# attribute :birthday, :date
# end
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/helpers/accepts_multiparameter_time.rb | activemodel/lib/active_model/type/helpers/accepts_multiparameter_time.rb | # frozen_string_literal: true
module ActiveModel
module Type
module Helpers # :nodoc: all
class AcceptsMultiparameterTime < Module
module InstanceMethods
def serialize(value)
serialize_cast_value(cast(value))
end
def serialize_cast_value(value)
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/helpers/timezone.rb | activemodel/lib/active_model/type/helpers/timezone.rb | # frozen_string_literal: true
require "active_support/core_ext/time/zones"
module ActiveModel
module Type
module Helpers # :nodoc: all
module Timezone
def is_utc?
if default = ::Time.zone_default
default.name == "UTC"
else
true
end
end
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/helpers/time_value.rb | activemodel/lib/active_model/type/helpers/time_value.rb | # frozen_string_literal: true
require "active_support/core_ext/string/zones"
require "active_support/core_ext/time/zones"
module ActiveModel
module Type
module Helpers # :nodoc: all
module TimeValue
def serialize_cast_value(value)
value = apply_seconds_precision(value)
if valu... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/helpers/numeric.rb | activemodel/lib/active_model/type/helpers/numeric.rb | # frozen_string_literal: true
module ActiveModel
module Type
module Helpers # :nodoc: all
module Numeric
def serialize(value)
cast(value)
end
def serialize_cast_value(value)
value
end
def cast(value)
# Checks whether the value is numer... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/helpers/immutable.rb | activemodel/lib/active_model/type/helpers/immutable.rb | # frozen_string_literal: true
module ActiveModel
module Type
module Helpers # :nodoc: all
module Immutable
def mutable? # :nodoc:
false
end
end
end
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/type/helpers/mutable.rb | activemodel/lib/active_model/type/helpers/mutable.rb | # frozen_string_literal: true
module ActiveModel
module Type
module Helpers # :nodoc: all
module Mutable
def cast(value)
deserialize(serialize(value))
end
# +raw_old_value+ will be the `_before_type_cast` version of the
# value (likely a string). +new_value+ will ... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/attribute_set/yaml_encoder.rb | activemodel/lib/active_model/attribute_set/yaml_encoder.rb | # frozen_string_literal: true
module ActiveModel
class AttributeSet
# Attempts to do more intelligent YAML dumping of an
# ActiveModel::AttributeSet to reduce the size of the resulting string
class YAMLEncoder # :nodoc:
def initialize(default_types)
@default_types = default_types
end
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/attribute_set/builder.rb | activemodel/lib/active_model/attribute_set/builder.rb | # frozen_string_literal: true
require "active_model/attribute"
module ActiveModel
class AttributeSet # :nodoc:
class Builder # :nodoc:
attr_reader :types, :default_attributes
def initialize(types, default_attributes = {})
@types = types
@default_attributes = default_attributes
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/secure_password/bcrypt_password.rb | activemodel/lib/active_model/secure_password/bcrypt_password.rb | # frozen_string_literal: true
module ActiveModel
module SecurePassword
class BCryptPassword
# 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.
MAX_PAS... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/secure_password/argon2_password.rb | activemodel/lib/active_model/secure_password/argon2_password.rb | # frozen_string_literal: true
module ActiveModel
module SecurePassword
class Argon2Password
def initialize
# Load argon2 gem only when has_secure_password with :argon2 is used.
# This is to avoid Active Model (and by extension the entire framework)
# being dependent on a binary libr... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/attributes/normalization.rb | activemodel/lib/active_model/attributes/normalization.rb | # frozen_string_literal: true
module ActiveModel
module Attributes
module Normalization
extend ActiveSupport::Concern
included do
include ActiveModel::Dirty
include ActiveModel::Validations::Callbacks
class_attribute :normalized_attributes, default: Set.new
before_v... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/helper_methods.rb | activemodel/lib/active_model/validations/helper_methods.rb | # frozen_string_literal: true
module ActiveModel
module Validations
module HelperMethods # :nodoc:
private
def _merge_attributes(attr_names)
options = attr_names.extract_options!.symbolize_keys
attr_names.flatten!
options[:attributes] = attr_names
options
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/absence.rb | activemodel/lib/active_model/validations/absence.rb | # frozen_string_literal: true
module ActiveModel
module Validations
# == \Active \Model Absence Validator
class AbsenceValidator < EachValidator # :nodoc:
def validate_each(record, attr_name, value)
record.errors.add(attr_name, :present, **options) if value.present?
end
end
modul... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/validates.rb | activemodel/lib/active_model/validations/validates.rb | # frozen_string_literal: true
require "active_support/core_ext/hash/slice"
module ActiveModel
module Validations
module ClassMethods
# This method is a shortcut to all default validators and any custom
# validator classes ending in 'Validator'. Note that \Rails default
# validators can be over... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/format.rb | activemodel/lib/active_model/validations/format.rb | # frozen_string_literal: true
require "active_model/validations/resolve_value"
module ActiveModel
module Validations
class FormatValidator < EachValidator # :nodoc:
include ResolveValue
def validate_each(record, attribute, value)
if options[:with]
regexp = resolve_value(record, op... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/confirmation.rb | activemodel/lib/active_model/validations/confirmation.rb | # frozen_string_literal: true
module ActiveModel
module Validations
class ConfirmationValidator < EachValidator # :nodoc:
def initialize(options)
super({ case_sensitive: true }.merge!(options))
setup!(options[:class])
end
def validate_each(record, attribute, value)
unle... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/presence.rb | activemodel/lib/active_model/validations/presence.rb | # frozen_string_literal: true
module ActiveModel
module Validations
class PresenceValidator < EachValidator # :nodoc:
def validate_each(record, attr_name, value)
record.errors.add(attr_name, :blank, **options) if value.blank?
end
end
module HelperMethods
# Validates that the sp... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/length.rb | activemodel/lib/active_model/validations/length.rb | # frozen_string_literal: true
require "active_model/validations/resolve_value"
module ActiveModel
module Validations
class LengthValidator < EachValidator # :nodoc:
include ResolveValue
MESSAGES = { is: :wrong_length, minimum: :too_short, maximum: :too_long }.freeze
CHECKS = { is: :==, mi... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/numericality.rb | activemodel/lib/active_model/validations/numericality.rb | # frozen_string_literal: true
require "active_model/validations/comparability"
require "active_model/validations/resolve_value"
require "bigdecimal/util"
module ActiveModel
module Validations
class NumericalityValidator < EachValidator # :nodoc:
include Comparability
include ResolveValue
RANG... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/callbacks.rb | activemodel/lib/active_model/validations/callbacks.rb | # frozen_string_literal: true
module ActiveModel
module Validations
# = Active \Model \Validation \Callbacks
#
# Provides an interface for any class to have ClassMethods#before_validation and
# ClassMethods#after_validation callbacks.
#
# First, include +ActiveModel::Validations::Callbacks+ f... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/exclusion.rb | activemodel/lib/active_model/validations/exclusion.rb | # frozen_string_literal: true
require "active_model/validations/clusivity"
module ActiveModel
module Validations
class ExclusionValidator < EachValidator # :nodoc:
include Clusivity
def validate_each(record, attribute, value)
if include?(record, value)
record.errors.add(attribute,... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/clusivity.rb | activemodel/lib/active_model/validations/clusivity.rb | # frozen_string_literal: true
require "active_model/validations/resolve_value"
require "active_support/core_ext/range"
module ActiveModel
module Validations
module Clusivity # :nodoc:
include ResolveValue
ERROR_MESSAGE = "An object with the method #include? or a proc, lambda or symbol is required, ... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/acceptance.rb | activemodel/lib/active_model/validations/acceptance.rb | # frozen_string_literal: true
module ActiveModel
module Validations
class AcceptanceValidator < EachValidator # :nodoc:
def initialize(options)
super({ allow_nil: true, accept: ["1", true] }.merge!(options))
setup!(options[:class])
end
def validate_each(record, attribute, value... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/inclusion.rb | activemodel/lib/active_model/validations/inclusion.rb | # frozen_string_literal: true
require "active_model/validations/clusivity"
module ActiveModel
module Validations
class InclusionValidator < EachValidator # :nodoc:
include Clusivity
def validate_each(record, attribute, value)
unless include?(record, value)
record.errors.add(attrib... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/comparability.rb | activemodel/lib/active_model/validations/comparability.rb | # frozen_string_literal: true
module ActiveModel
module Validations
module Comparability # :nodoc:
COMPARE_CHECKS = { greater_than: :>, greater_than_or_equal_to: :>=,
equal_to: :==, less_than: :<, less_than_or_equal_to: :<=,
other_than: :!= }.freeze
def error_options(value, option_va... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/comparison.rb | activemodel/lib/active_model/validations/comparison.rb | # frozen_string_literal: true
require "active_model/validations/comparability"
require "active_model/validations/resolve_value"
module ActiveModel
module Validations
class ComparisonValidator < EachValidator # :nodoc:
include Comparability
include ResolveValue
def check_validity!
unle... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/resolve_value.rb | activemodel/lib/active_model/validations/resolve_value.rb | # frozen_string_literal: true
module ActiveModel
module Validations
module ResolveValue # :nodoc:
def resolve_value(record, value)
case value
when Proc
if value.arity == 0
value.call
else
value.call(record)
end
when Symbol
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/validations/with.rb | activemodel/lib/active_model/validations/with.rb | # frozen_string_literal: true
require "active_support/core_ext/array/extract_options"
module ActiveModel
module Validations
class WithValidator < EachValidator # :nodoc:
def validate_each(record, attr, val)
method_name = options[:with]
if record.method(method_name).arity == 0
re... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activemodel/lib/active_model/attribute/user_provided_default.rb | activemodel/lib/active_model/attribute/user_provided_default.rb | # frozen_string_literal: true
require "active_model/attribute"
module ActiveModel
class Attribute # :nodoc:
def with_user_default(value)
UserProvidedDefault.new(name, value, type, self.is_a?(FromDatabase) ? self : original_attribute)
end
class UserProvidedDefault < FromUser # :nodoc:
def in... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/actionpack/test/abstract_unit.rb | actionpack/test/abstract_unit.rb | # frozen_string_literal: true
require_relative "../../tools/strict_warnings"
$:.unshift File.expand_path("lib", __dir__)
require "active_support/core_ext/kernel/reporting"
# These are the normal settings that will be set up by Railties
# TODO: Have these tests support other combinations of these values
silence_warn... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/actionpack/test/controller/render_js_test.rb | actionpack/test/controller/render_js_test.rb | # frozen_string_literal: true
require "abstract_unit"
require "controller/fake_models"
class RenderJSTest < ActionController::TestCase
class TestController < ActionController::Base
protect_from_forgery
def self.controller_path
"test"
end
def render_vanilla_js_hello
render js: "alert('h... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/actionpack/test/controller/integration_test.rb | actionpack/test/controller/integration_test.rb | # frozen_string_literal: true
require "abstract_unit"
require "controller/fake_controllers"
require "rails/engine"
require "launchy"
class SessionTest < ActiveSupport::TestCase
StubApp = lambda { |env|
[200, { "Content-Type" => "text/html", "Content-Length" => "13" }, ["Hello, World!"]]
}
def setup
@se... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | true |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/actionpack/test/controller/renderer_test.rb | actionpack/test/controller/renderer_test.rb | # frozen_string_literal: true
require "abstract_unit"
require "test_renderable"
class RendererTest < ActiveSupport::TestCase
test "action controller base has a renderer" do
assert ActionController::Base.renderer
end
test "creating with a controller" do
controller = CommentsController
renderer = A... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/actionpack/test/controller/http_basic_authentication_test.rb | actionpack/test/controller/http_basic_authentication_test.rb | # frozen_string_literal: true
require "abstract_unit"
class HttpBasicAuthenticationTest < ActionController::TestCase
class DummyController < ActionController::Base
before_action :authenticate, only: :index
before_action :authenticate_with_request, only: :display
before_action :authenticate_long_credenti... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/actionpack/test/controller/structured_event_subscriber_test.rb | actionpack/test/controller/structured_event_subscriber_test.rb | # frozen_string_literal: true
require "abstract_unit"
require "active_support/testing/event_reporter_assertions"
require "action_controller/structured_event_subscriber"
require "active_support/core_ext/object/with"
module ActionController
class StructuredEventSubscriberTest < ActionController::TestCase
module ... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/actionpack/test/controller/send_file_test.rb | actionpack/test/controller/send_file_test.rb | # frozen_string_literal: true
require "abstract_unit"
module TestFileUtils
def file_name() File.basename(__FILE__) end
def file_path() __FILE__ end
def file_data() @data ||= File.binread(file_path) end
end
class SendFileController < ActionController::Base
include TestFileUtils
include ActionController::Tes... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.