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/activesupport/lib/active_support/cache/memory_store.rb | activesupport/lib/active_support/cache/memory_store.rb | # frozen_string_literal: true
require "monitor"
module ActiveSupport
module Cache
# = Memory \Cache \Store
#
# A cache store implementation which stores everything into memory in the
# same process. If you're running multiple Ruby on \Rails server processes
# (which is the case if you're using P... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/cache/strategy/local_cache_middleware.rb | activesupport/lib/active_support/cache/strategy/local_cache_middleware.rb | # frozen_string_literal: true
require "rack/body_proxy"
require "rack/utils"
module ActiveSupport
module Cache
module Strategy
module LocalCache
#--
# This class wraps up local storage for middlewares. Only the middleware method should
# construct them.
class Middleware # :... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/cache/strategy/local_cache.rb | activesupport/lib/active_support/cache/strategy/local_cache.rb | # frozen_string_literal: true
require "active_support/core_ext/string/inflections"
module ActiveSupport
module Cache
module Strategy
# = Local \Cache \Strategy
#
# Caches that implement LocalCache will be backed by an in-memory cache for the
# duration of a block. Repeated calls to the c... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/error_reporter/test_helper.rb | activesupport/lib/active_support/error_reporter/test_helper.rb | # frozen_string_literal: true
module ActiveSupport::ErrorReporter::TestHelper # :nodoc:
class ErrorSubscriber
attr_reader :events
def initialize
@events = []
end
def report(error, handled:, severity:, source:, context:)
@events << [error, handled, severity, source, context]
end
en... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/inflector/methods.rb | activesupport/lib/active_support/inflector/methods.rb | # frozen_string_literal: true
require "active_support/inflections"
module ActiveSupport
# = Active Support \Inflector
#
# The Inflector transforms words from singular to plural, class names to table
# names, modularized class names to ones without, and class names to foreign
# keys. The default inflections ... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/inflector/transliterate.rb | activesupport/lib/active_support/inflector/transliterate.rb | # frozen_string_literal: true
require "active_support/core_ext/string/multibyte"
require "active_support/i18n"
module ActiveSupport
module Inflector
ALLOWED_ENCODINGS_FOR_TRANSLITERATE = [Encoding::UTF_8, Encoding::US_ASCII, Encoding::GB18030].freeze
# Replaces non-ASCII characters with an ASCII approximat... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/inflector/inflections.rb | activesupport/lib/active_support/inflector/inflections.rb | # frozen_string_literal: true
require "concurrent/map"
require "active_support/core_ext/module/delegation"
require "active_support/i18n"
module ActiveSupport
module Inflector
extend self
# = Active Support \Inflections
#
# A singleton instance of this class is yielded by Inflector.inflections,
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/concurrency/share_lock.rb | activesupport/lib/active_support/concurrency/share_lock.rb | # frozen_string_literal: true
require "monitor"
module ActiveSupport
module Concurrency
# A share/exclusive lock, otherwise known as a read/write lock.
#
# https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock
class ShareLock
include MonitorMixin
# We track Thread objects, instead o... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/concurrency/null_lock.rb | activesupport/lib/active_support/concurrency/null_lock.rb | # frozen_string_literal: true
module ActiveSupport
module Concurrency
module NullLock # :nodoc:
extend self
def synchronize
yield
end
end
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb | activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb | # frozen_string_literal: true
require "monitor"
module ActiveSupport
module Concurrency
# A monitor that will permit dependency loading while blocked waiting for
# the lock.
LoadInterlockAwareMonitor = ActiveSupport::Deprecation::DeprecatedConstantProxy.new(
"ActiveSupport::Concurrency::LoadInterl... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/concurrency/thread_monitor.rb | activesupport/lib/active_support/concurrency/thread_monitor.rb | # frozen_string_literal: true
module ActiveSupport
module Concurrency
class ThreadMonitor # :nodoc:
EXCEPTION_NEVER = { Exception => :never }.freeze
EXCEPTION_IMMEDIATE = { Exception => :immediate }.freeze
private_constant :EXCEPTION_NEVER, :EXCEPTION_IMMEDIATE
def initialize
@ow... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/message_pack/extensions.rb | activesupport/lib/active_support/message_pack/extensions.rb | # frozen_string_literal: true
require "bigdecimal"
require "date"
require "ipaddr"
require "pathname"
require "uri"
require "msgpack/bigint"
require "active_support/hash_with_indifferent_access"
require "active_support/core_ext/string/output_safety"
require "active_support/time"
module ActiveSupport
module MessageP... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/message_pack/cache_serializer.rb | activesupport/lib/active_support/message_pack/cache_serializer.rb | # frozen_string_literal: true
require_relative "serializer"
module ActiveSupport
module MessagePack
module CacheSerializer
include Serializer
extend self
def load(dumped)
super
rescue ActiveSupport::MessagePack::MissingClassError
# Treat missing class as cache miss => re... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/message_pack/serializer.rb | activesupport/lib/active_support/message_pack/serializer.rb | # frozen_string_literal: true
require_relative "extensions"
module ActiveSupport
module MessagePack
module Serializer # :nodoc:
SIGNATURE = "\xCC\x80".b.freeze # == 128.to_msgpack
SIGNATURE_INT = 128
def dump(object)
message_pack_pool.packer do |packer|
packer.write(SIGNATUR... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/json/encoding.rb | activesupport/lib/active_support/json/encoding.rb | # frozen_string_literal: true
require "active_support/core_ext/object/json"
require "active_support/core_ext/module/delegation"
module ActiveSupport
class << self
delegate :use_standard_json_time_format, :use_standard_json_time_format=,
:time_precision, :time_precision=,
:escape_html_entities_in_jso... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/json/decoding.rb | activesupport/lib/active_support/json/decoding.rb | # frozen_string_literal: true
require "active_support/core_ext/module/attribute_accessors"
require "active_support/core_ext/module/delegation"
require "json"
module ActiveSupport
# Look for and parse JSON strings that look like ISO 8601 times.
mattr_accessor :parse_json_times
module JSON
# matches YAML-for... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/number_helper/number_to_human_converter.rb | activesupport/lib/active_support/number_helper/number_to_human_converter.rb | # frozen_string_literal: true
require "active_support/number_helper/number_converter"
module ActiveSupport
module NumberHelper
class NumberToHumanConverter < NumberConverter # :nodoc:
DECIMAL_UNITS = { 0 => :unit, 1 => :ten, 2 => :hundred, 3 => :thousand, 6 => :million, 9 => :billion, 12 => :trillion, 15 ... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/number_helper/number_converter.rb | activesupport/lib/active_support/number_helper/number_converter.rb | # frozen_string_literal: true
require "bigdecimal"
require "bigdecimal/util"
require "active_support/core_ext/big_decimal/conversions"
require "active_support/core_ext/hash/keys"
require "active_support/i18n"
require "active_support/core_ext/class/attribute"
module ActiveSupport
module NumberHelper
class Number... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/number_helper/number_to_percentage_converter.rb | activesupport/lib/active_support/number_helper/number_to_percentage_converter.rb | # frozen_string_literal: true
require "active_support/number_helper/number_converter"
module ActiveSupport
module NumberHelper
class NumberToPercentageConverter < NumberConverter # :nodoc:
self.namespace = :percentage
def convert
rounded_number = NumberToRoundedConverter.convert(number, opt... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb | activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb | # frozen_string_literal: true
require "active_support/number_helper/number_converter"
module ActiveSupport
module NumberHelper
class NumberToHumanSizeConverter < NumberConverter # :nodoc:
STORAGE_UNITS = [:byte, :kb, :mb, :gb, :tb, :pb, :eb, :zb]
self.namespace = :human
self.validate_flo... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/number_helper/number_to_phone_converter.rb | activesupport/lib/active_support/number_helper/number_to_phone_converter.rb | # frozen_string_literal: true
require "active_support/core_ext/object/blank"
require "active_support/number_helper/number_converter"
module ActiveSupport
module NumberHelper
class NumberToPhoneConverter < NumberConverter # :nodoc:
def convert
str = country_code(opts[:country_code]).dup
str... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/number_helper/rounding_helper.rb | activesupport/lib/active_support/number_helper/rounding_helper.rb | # frozen_string_literal: true
module ActiveSupport
module NumberHelper
class RoundingHelper # :nodoc:
attr_reader :options
def initialize(options)
@options = options
end
def round(number)
precision = absolute_precision(number)
return number unless precision
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/number_helper/number_to_currency_converter.rb | activesupport/lib/active_support/number_helper/number_to_currency_converter.rb | # frozen_string_literal: true
require "active_support/number_helper/number_converter"
module ActiveSupport
module NumberHelper
class NumberToCurrencyConverter < NumberConverter # :nodoc:
self.namespace = :currency
def convert
format = options[:format]
number_d = valid_bigdecimal
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb | activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb | # frozen_string_literal: true
require "active_support/number_helper/number_converter"
module ActiveSupport
module NumberHelper
class NumberToRoundedConverter < NumberConverter # :nodoc:
self.namespace = :precision
self.validate_float = true
def convert
helper = RoundingHelper.new... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb | activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb | # frozen_string_literal: true
require "active_support/number_helper/number_converter"
module ActiveSupport
module NumberHelper
class NumberToDelimitedConverter < NumberConverter # :nodoc:
self.validate_float = true
DEFAULT_DELIMITER_REGEX = /(\d)(?=(\d\d\d)+(?!\d))/
def convert
parts... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/messages/rotation_coordinator.rb | activesupport/lib/active_support/messages/rotation_coordinator.rb | # frozen_string_literal: true
require "active_support/core_ext/hash/slice"
module ActiveSupport
module Messages
class RotationCoordinator # :nodoc:
attr_accessor :transitional
def initialize(&secret_generator)
raise ArgumentError, "A secret generator block is required" unless secret_generat... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/messages/rotator.rb | activesupport/lib/active_support/messages/rotator.rb | # frozen_string_literal: true
module ActiveSupport
module Messages
module Rotator # :nodoc:
def initialize(*args, on_rotation: nil, **options)
super(*args, **options)
@args = args
@options = options
@rotations = []
@on_rotation = on_rotation
end
def rota... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/messages/codec.rb | activesupport/lib/active_support/messages/codec.rb | # frozen_string_literal: true
require "active_support/core_ext/class/attribute"
require_relative "metadata"
require_relative "serializer_with_fallback"
module ActiveSupport
module Messages # :nodoc:
class Codec # :nodoc:
include Metadata
class_attribute :default_serializer, default: :marshal,
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/messages/serializer_with_fallback.rb | activesupport/lib/active_support/messages/serializer_with_fallback.rb | # frozen_string_literal: true
require "active_support/core_ext/kernel/reporting"
require "active_support/notifications"
module ActiveSupport
module Messages # :nodoc:
module SerializerWithFallback # :nodoc:
def self.[](format)
if format.to_s.include?("message_pack") && !defined?(ActiveSupport::Mes... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/messages/rotation_configuration.rb | activesupport/lib/active_support/messages/rotation_configuration.rb | # frozen_string_literal: true
module ActiveSupport
module Messages
class RotationConfiguration # :nodoc:
attr_reader :signed, :encrypted
def initialize
@signed, @encrypted = [], []
end
def rotate(kind, *args, **options)
args << options unless options.empty?
case ... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/messages/metadata.rb | activesupport/lib/active_support/messages/metadata.rb | # frozen_string_literal: true
require "time"
require "active_support/json"
require_relative "serializer_with_fallback"
module ActiveSupport
module Messages # :nodoc:
module Metadata # :nodoc:
singleton_class.attr_accessor :use_message_serializer_for_metadata
ENVELOPE_SERIALIZERS = [
*Serial... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/event_reporter/log_subscriber.rb | activesupport/lib/active_support/event_reporter/log_subscriber.rb | # frozen_string_literal: true
module ActiveSupport
class EventReporter
class LogSubscriber
include ColorizeLogging
LEVEL_CHECKS = {
debug: -> (logger) { logger.debug? },
info: -> (logger) { logger.info? },
error: -> (logger) { logger.error? },
}
class << self
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/event_reporter/test_helper.rb | activesupport/lib/active_support/event_reporter/test_helper.rb | # frozen_string_literal: true
module ActiveSupport::EventReporter::TestHelper # :nodoc:
class EventSubscriber # :nodoc:
attr_reader :events
def initialize
@events = []
end
def emit(event)
@events << event
end
end
def event_matcher(name:, payload: nil, tags: {}, context: {}, sou... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/big_decimal.rb | activesupport/lib/active_support/core_ext/big_decimal.rb | # frozen_string_literal: true
require_relative "big_decimal/conversions"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/range.rb | activesupport/lib/active_support/core_ext/range.rb | # frozen_string_literal: true
require_relative "range/conversions"
require_relative "range/compare_range"
require_relative "range/overlap"
require_relative "range/sole"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/load_error.rb | activesupport/lib/active_support/core_ext/load_error.rb | # frozen_string_literal: true
class LoadError
# Returns true if the given path name (except perhaps for the ".rb"
# extension) is the missing file which caused the exception to be raised.
def is_missing?(location)
location.delete_suffix(".rb") == path.to_s.delete_suffix(".rb")
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/securerandom.rb | activesupport/lib/active_support/core_ext/securerandom.rb | # frozen_string_literal: true
require "securerandom"
module SecureRandom
BASE58_ALPHABET = ("0".."9").to_a + ("A".."Z").to_a + ("a".."z").to_a - ["0", "O", "I", "l"]
BASE36_ALPHABET = ("0".."9").to_a + ("a".."z").to_a
BASE32_ALPHABET = ("0".."9").to_a + ("A".."Z").to_a - ["I", "L", "O", "U"]
# SecureRandom.b... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/name_error.rb | activesupport/lib/active_support/core_ext/name_error.rb | # frozen_string_literal: true
class NameError
# Extract the name of the missing constant from the exception message.
#
# begin
# HelloWorld
# rescue NameError => e
# e.missing_name
# end
# # => "HelloWorld"
def missing_name
# Since ruby v2.3.0 `did_you_mean` gem is loaded by defau... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/digest.rb | activesupport/lib/active_support/core_ext/digest.rb | # frozen_string_literal: true
require_relative "digest/uuid"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/benchmark.rb | activesupport/lib/active_support/core_ext/benchmark.rb | # frozen_string_literal: true
# Remove this file from activesupport/lib/active_support/core_ext.rb when deleting the deprecation.
ActiveSupport.deprecator.warn <<~TEXT
active_support/core_ext/benchmark.rb is deprecated and will be removed in Rails 8.2 without replacement.
TEXT
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/array.rb | activesupport/lib/active_support/core_ext/array.rb | # frozen_string_literal: true
require_relative "array/wrap"
require_relative "array/access"
require_relative "array/conversions"
require_relative "array/extract"
require_relative "array/extract_options"
require_relative "array/grouping"
require_relative "array/inquiry"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/time.rb | activesupport/lib/active_support/core_ext/time.rb | # frozen_string_literal: true
require_relative "time/acts_like"
require_relative "time/calculations"
require_relative "time/compatibility"
require_relative "time/conversions"
require_relative "time/zones"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/file.rb | activesupport/lib/active_support/core_ext/file.rb | # frozen_string_literal: true
require_relative "file/atomic"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/kernel.rb | activesupport/lib/active_support/core_ext/kernel.rb | # frozen_string_literal: true
require_relative "kernel/concern"
require_relative "kernel/reporting"
require_relative "kernel/singleton_class"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/class.rb | activesupport/lib/active_support/core_ext/class.rb | # frozen_string_literal: true
require_relative "class/attribute"
require_relative "class/subclasses"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/string.rb | activesupport/lib/active_support/core_ext/string.rb | # frozen_string_literal: true
require_relative "string/conversions"
require_relative "string/filters"
require_relative "string/multibyte"
require_relative "string/starts_ends_with"
require_relative "string/inflections"
require_relative "string/access"
require_relative "string/behavior"
require_relative "string/output_... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/object.rb | activesupport/lib/active_support/core_ext/object.rb | # frozen_string_literal: true
require_relative "object/acts_like"
require_relative "object/blank"
require_relative "object/duplicable"
require_relative "object/deep_dup"
require_relative "object/try"
require_relative "object/inclusion"
require_relative "object/conversions"
require_relative "object/instance_variables"... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/enumerable.rb | activesupport/lib/active_support/core_ext/enumerable.rb | # frozen_string_literal: true
module ActiveSupport
module EnumerableCoreExt # :nodoc:
module Constants
private
def const_missing(name)
if name == :SoleItemExpectedError
::ActiveSupport::EnumerableCoreExt::SoleItemExpectedError
else
super
end
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/pathname.rb | activesupport/lib/active_support/core_ext/pathname.rb | # frozen_string_literal: true
require_relative "pathname/blank"
require_relative "pathname/existence"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/integer.rb | activesupport/lib/active_support/core_ext/integer.rb | # frozen_string_literal: true
require_relative "integer/multiple"
require_relative "integer/inflections"
require_relative "integer/time"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/regexp.rb | activesupport/lib/active_support/core_ext/regexp.rb | # frozen_string_literal: true
class Regexp
# Returns +true+ if the regexp has the multiline flag set.
#
# (/./).multiline? # => false
# (/./m).multiline? # => true
#
# Regexp.new(".").multiline? # => false
# Regexp.new(".", Regexp::MULTILINE).multiline? # => true
def multili... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/module.rb | activesupport/lib/active_support/core_ext/module.rb | # frozen_string_literal: true
require_relative "module/aliasing"
require_relative "module/introspection"
require_relative "module/anonymous"
require_relative "module/attribute_accessors"
require_relative "module/attribute_accessors_per_thread"
require_relative "module/attr_internal"
require_relative "module/concerning... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/date_time.rb | activesupport/lib/active_support/core_ext/date_time.rb | # frozen_string_literal: true
require_relative "date_time/acts_like"
require_relative "date_time/blank"
require_relative "date_time/calculations"
require_relative "date_time/compatibility"
require_relative "date_time/conversions"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/hash.rb | activesupport/lib/active_support/core_ext/hash.rb | # frozen_string_literal: true
require_relative "hash/conversions"
require_relative "hash/deep_merge"
require_relative "hash/deep_transform_values"
require_relative "hash/except"
require_relative "hash/indifferent_access"
require_relative "hash/keys"
require_relative "hash/reverse_merge"
require_relative "hash/slice"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/date.rb | activesupport/lib/active_support/core_ext/date.rb | # frozen_string_literal: true
require_relative "date/acts_like"
require_relative "date/blank"
require_relative "date/calculations"
require_relative "date/conversions"
require_relative "date/zones"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/symbol.rb | activesupport/lib/active_support/core_ext/symbol.rb | # frozen_string_literal: true
require_relative "symbol/starts_ends_with"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/numeric.rb | activesupport/lib/active_support/core_ext/numeric.rb | # frozen_string_literal: true
require_relative "numeric/bytes"
require_relative "numeric/time"
require_relative "numeric/conversions"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/string/inquiry.rb | activesupport/lib/active_support/core_ext/string/inquiry.rb | # frozen_string_literal: true
require "active_support/string_inquirer"
require "active_support/environment_inquirer"
class String
# Wraps the current string in the ActiveSupport::StringInquirer class,
# which gives you a prettier way to test for equality.
#
# env = 'production'.inquiry
# env.production?... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/string/indent.rb | activesupport/lib/active_support/core_ext/string/indent.rb | # frozen_string_literal: true
class String
# Same as +indent+, except it indents the receiver in-place.
#
# Returns the indented string, or +nil+ if there was nothing to indent.
def indent!(amount, indent_string = nil, indent_empty_lines = false)
indent_string = indent_string || self[/^[ \t]/] || " "
r... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/string/output_safety.rb | activesupport/lib/active_support/core_ext/string/output_safety.rb | # frozen_string_literal: true
require "active_support/core_ext/erb/util"
require "active_support/multibyte/unicode"
class Object
def html_safe?
false
end
end
class Numeric
def html_safe?
true
end
end
module ActiveSupport # :nodoc:
class SafeBuffer < String
UNSAFE_STRING_METHODS = %w(
cap... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/string/conversions.rb | activesupport/lib/active_support/core_ext/string/conversions.rb | # frozen_string_literal: true
require "date"
require "active_support/core_ext/time/calculations"
class String
# Converts a string to a Time value.
# The +form+ can be either +:utc+ or +:local+ (default +:local+).
#
# The time is parsed using Time.parse method.
# If +form+ is +:local+, then the time is in th... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/string/strip.rb | activesupport/lib/active_support/core_ext/string/strip.rb | # frozen_string_literal: true
require "strscan"
class String
# Strips indentation in heredocs.
#
# Note that since Ruby 2.3, heredocs can directly created with their indentation striped
# by using the <tt><<~</tt> syntax instead of <tt><<-</tt>.
# Hence the strip_heredoc method is rarely useful nowadays.
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/string/access.rb | activesupport/lib/active_support/core_ext/string/access.rb | # frozen_string_literal: true
class String
# If you pass a single integer, returns a substring of one character at that
# position. The first character of the string is at position 0, the next at
# position 1, and so on. If a range is supplied, a substring containing
# characters at offsets given by the range ... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb | activesupport/lib/active_support/core_ext/string/starts_ends_with.rb | # frozen_string_literal: true
class String
alias :starts_with? :start_with?
alias :ends_with? :end_with?
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/string/inflections.rb | activesupport/lib/active_support/core_ext/string/inflections.rb | # frozen_string_literal: true
require "active_support/inflector/methods"
require "active_support/inflector/transliterate"
# String inflections define new methods on the String class to transform names for different purposes.
# For instance, you can figure out the name of a table from the name of a class.
#
# 'Scale... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/string/filters.rb | activesupport/lib/active_support/core_ext/string/filters.rb | # frozen_string_literal: true
class String
# Returns the string, first removing all whitespace on both ends of
# the string, and then changing remaining consecutive whitespace
# groups into one space each.
#
# Note that it handles both ASCII and Unicode whitespace.
#
# %{ Multi-line
# string }.s... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/string/exclude.rb | activesupport/lib/active_support/core_ext/string/exclude.rb | # frozen_string_literal: true
class String
# The inverse of <tt>String#include?</tt>. Returns true if the string
# does not include the other string.
#
# "hello".exclude? "lo" # => false
# "hello".exclude? "ol" # => true
# "hello".exclude? ?h # => false
def exclude?(string)
!include?(string)
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/string/behavior.rb | activesupport/lib/active_support/core_ext/string/behavior.rb | # frozen_string_literal: true
class String
# Enables more predictable duck-typing on String-like classes. See <tt>Object#acts_like?</tt>.
def acts_like_string?
true
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/string/multibyte.rb | activesupport/lib/active_support/core_ext/string/multibyte.rb | # frozen_string_literal: true
require "active_support/multibyte"
class String
# == Multibyte proxy
#
# +mb_chars+ is a multibyte safe proxy for string methods.
#
# It creates and returns an instance of the ActiveSupport::Multibyte::Chars class which
# encapsulates the original string. A Unicode safe versi... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/string/zones.rb | activesupport/lib/active_support/core_ext/string/zones.rb | # frozen_string_literal: true
require "active_support/core_ext/string/conversions"
require "active_support/core_ext/time/zones"
class String
# Converts String to a TimeWithZone in the current zone if Time.zone or Time.zone_default
# is set, otherwise converts String to a Time via String#to_time
def in_time_zone... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/pathname/blank.rb | activesupport/lib/active_support/core_ext/pathname/blank.rb | # frozen_string_literal: true
require "pathname"
class Pathname
# An Pathname is blank if it's empty:
#
# Pathname.new("").blank? # => true
# Pathname.new(" ").blank? # => false
# Pathname.new("test").blank? # => false
#
# @return [true, false]
def blank?
to_s.empty?
end
def p... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/pathname/existence.rb | activesupport/lib/active_support/core_ext/pathname/existence.rb | # frozen_string_literal: true
require "pathname"
class Pathname
# Returns the receiver if the named file exists otherwise returns +nil+.
# <tt>pathname.existence</tt> is equivalent to
#
# pathname.exist? ? pathname : nil
#
# For example, something like
#
# content = pathname.read if pathname.exis... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/file/atomic.rb | activesupport/lib/active_support/core_ext/file/atomic.rb | # frozen_string_literal: true
require "securerandom"
class File
# Write to a file atomically. Useful for situations where you don't
# want other processes or threads to see half-written files.
#
# File.atomic_write('important.file') do |file|
# file.write('hello')
# end
#
# This method needs t... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/hash/slice.rb | activesupport/lib/active_support/core_ext/hash/slice.rb | # frozen_string_literal: true
class Hash
# Replaces the hash with only the given keys.
# Returns a hash containing the removed key/value pairs.
#
# hash = { a: 1, b: 2, c: 3, d: 4 }
# hash.slice!(:a, :b) # => {:c=>3, :d=>4}
# hash # => {:a=>1, :b=>2}
def slice!(*keys)
omit = sl... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb | activesupport/lib/active_support/core_ext/hash/reverse_merge.rb | # frozen_string_literal: true
class Hash
# Merges the caller into +other_hash+. For example,
#
# options = options.reverse_merge(size: 25, velocity: 10)
#
# is equivalent to
#
# options = { size: 25, velocity: 10 }.merge(options)
#
# This is particularly useful for initializing an options hash
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/hash/keys.rb | activesupport/lib/active_support/core_ext/hash/keys.rb | # frozen_string_literal: true
class Hash
# Returns a new hash with all keys converted to strings.
#
# hash = { name: 'Rob', age: '28' }
#
# hash.stringify_keys
# # => {"name"=>"Rob", "age"=>"28"}
def stringify_keys
transform_keys { |k| Symbol === k ? k.name : k.to_s }
end
# Destructively c... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/hash/conversions.rb | activesupport/lib/active_support/core_ext/hash/conversions.rb | # frozen_string_literal: true
require "active_support/core_ext/object/blank"
require "active_support/core_ext/object/to_param"
require "active_support/core_ext/object/to_query"
require "active_support/core_ext/object/try"
require "active_support/core_ext/array/wrap"
require "active_support/core_ext/hash/reverse_merge"... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb | activesupport/lib/active_support/core_ext/hash/indifferent_access.rb | # frozen_string_literal: true
require "active_support/hash_with_indifferent_access"
class Hash
# Returns an ActiveSupport::HashWithIndifferentAccess out of its receiver:
#
# { a: 1 }.with_indifferent_access['a'] # => 1
def with_indifferent_access
ActiveSupport::HashWithIndifferentAccess.new(self)
end
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/hash/deep_merge.rb | activesupport/lib/active_support/core_ext/hash/deep_merge.rb | # frozen_string_literal: true
require "active_support/deep_mergeable"
class Hash
include ActiveSupport::DeepMergeable
##
# :method: deep_merge
# :call-seq: deep_merge(other_hash, &block)
#
# Returns a new hash with +self+ and +other_hash+ merged recursively.
#
# h1 = { a: true, b: { c: [1, 2, 3] } ... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/hash/except.rb | activesupport/lib/active_support/core_ext/hash/except.rb | # frozen_string_literal: true
class Hash
# Removes the given keys from hash and returns it.
# hash = { a: true, b: false, c: nil }
# hash.except!(:c) # => { a: true, b: false }
# hash # => { a: true, b: false }
def except!(*keys)
keys.each { |key| delete(key) }
self
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/hash/deep_transform_values.rb | activesupport/lib/active_support/core_ext/hash/deep_transform_values.rb | # frozen_string_literal: true
class Hash
# Returns a new hash with all values converted by the block operation.
# This includes the values from the root hash and from all
# nested hashes and arrays.
#
# hash = { person: { name: 'Rob', age: '28' } }
#
# hash.deep_transform_values{ |value| value.to_s.u... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/date/blank.rb | activesupport/lib/active_support/core_ext/date/blank.rb | # frozen_string_literal: true
require "date"
class Date # :nodoc:
# No Date is blank:
#
# Date.today.blank? # => false
#
# @return [false]
def blank?
false
end
def present?
true
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/date/conversions.rb | activesupport/lib/active_support/core_ext/date/conversions.rb | # frozen_string_literal: true
require "date"
require "active_support/inflector/methods"
require "active_support/core_ext/date/zones"
require "active_support/core_ext/module/redefine_method"
class Date
DATE_FORMATS = {
short: "%d %b",
long: "%B %d, %Y",
db: "%Y-%m-%d",
inspect: "%Y-%m-%d",
number... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/date/acts_like.rb | activesupport/lib/active_support/core_ext/date/acts_like.rb | # frozen_string_literal: true
require "active_support/core_ext/object/acts_like"
class Date
# Duck-types as a Date-like class. See Object#acts_like?.
def acts_like_date?
true
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/date/calculations.rb | activesupport/lib/active_support/core_ext/date/calculations.rb | # frozen_string_literal: true
require "date"
require "active_support/duration"
require "active_support/core_ext/object/acts_like"
require "active_support/core_ext/date/zones"
require "active_support/core_ext/time/zones"
require "active_support/core_ext/date_and_time/calculations"
class Date
include DateAndTime::Cal... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/date/zones.rb | activesupport/lib/active_support/core_ext/date/zones.rb | # frozen_string_literal: true
require "date"
require "active_support/core_ext/date_and_time/zones"
class Date
include DateAndTime::Zones
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/integer/time.rb | activesupport/lib/active_support/core_ext/integer/time.rb | # frozen_string_literal: true
require "active_support/duration"
require "active_support/core_ext/numeric/time"
class Integer
# Returns a Duration instance matching the number of months provided.
#
# 2.months # => 2 months
def months
ActiveSupport::Duration.months(self)
end
alias :month :months
# ... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/integer/inflections.rb | activesupport/lib/active_support/core_ext/integer/inflections.rb | # frozen_string_literal: true
require "active_support/inflector"
class Integer
# Ordinalize turns a number into an ordinal string used to denote the
# position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
#
# 1.ordinalize # => "1st"
# 2.ordinalize # => "2nd"
# 1002.ordinalize # => "10... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/integer/multiple.rb | activesupport/lib/active_support/core_ext/integer/multiple.rb | # frozen_string_literal: true
class Integer
# Check whether the integer is evenly divisible by the argument.
#
# 0.multiple_of?(0) # => true
# 6.multiple_of?(5) # => false
# 10.multiple_of?(2) # => true
def multiple_of?(number)
number == 0 ? self == 0 : self % number == 0
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb | activesupport/lib/active_support/core_ext/kernel/singleton_class.rb | # frozen_string_literal: true
module Kernel
# class_eval on an object acts like +singleton_class.class_eval+.
def class_eval(*args, &block)
singleton_class.class_eval(*args, &block)
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/kernel/reporting.rb | activesupport/lib/active_support/core_ext/kernel/reporting.rb | # frozen_string_literal: true
module Kernel
module_function
# Sets $VERBOSE to +nil+ for the duration of the block and back to its original
# value afterwards.
#
# silence_warnings do
# value = noisy_call # no warning voiced
# end
#
# noisy_call # warning voiced
def silence_warnings(&blo... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/kernel/concern.rb | activesupport/lib/active_support/core_ext/kernel/concern.rb | # frozen_string_literal: true
require "active_support/core_ext/module/concerning"
module Kernel
module_function
# A shortcut to define a toplevel concern, not within a module.
#
# See Module::Concerning for more.
def concern(topic, &module_definition)
Object.concern topic, &module_definition
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/range/sole.rb | activesupport/lib/active_support/core_ext/range/sole.rb | # frozen_string_literal: true
class Range
# Returns the sole item in the range. If there are no items, or more
# than one item, raises Enumerable::SoleItemExpectedError.
#
# (1..1).sole # => 1
# (2..1).sole # => Enumerable::SoleItemExpectedError: no item found
# (..1).sole # => Enumerable::Sol... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/range/overlap.rb | activesupport/lib/active_support/core_ext/range/overlap.rb | # frozen_string_literal: true
class Range
unless Range.method_defined?(:overlap?) # Ruby 3.3+
# Compare two ranges and see if they overlap each other
# (1..5).overlap?(4..6) # => true
# (1..5).overlap?(7..9) # => false
def overlap?(other)
raise TypeError unless other.is_a? Range
self_b... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/range/compare_range.rb | activesupport/lib/active_support/core_ext/range/compare_range.rb | # frozen_string_literal: true
module ActiveSupport
module CompareWithRange
# Extends the default Range#=== to support range comparisons.
# (1..5) === (1..5) # => true
# (1..5) === (2..3) # => true
# (1..5) === (1...6) # => true
# (1..5) === (2..6) # => false
#
# The native Range#==... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/range/conversions.rb | activesupport/lib/active_support/core_ext/range/conversions.rb | # frozen_string_literal: true
module ActiveSupport
# = \Range With Format
module RangeWithFormat
RANGE_FORMATS = {
db: -> (start, stop) do
if start && stop
case start
when String then "BETWEEN '#{start}' AND '#{stop}'"
else
"BETWEEN '#{start.to_fs(:db)}' ... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/thread/backtrace/location.rb | activesupport/lib/active_support/core_ext/thread/backtrace/location.rb | # frozen_string_literal: true
class Thread::Backtrace::Location # :nodoc:
def spot(ex)
ErrorHighlight.spot(ex, backtrace_location: self)
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/time/conversions.rb | activesupport/lib/active_support/core_ext/time/conversions.rb | # frozen_string_literal: true
require "time"
require "active_support/inflector/methods"
require "active_support/values/time_zone"
class Time
DATE_FORMATS = {
db: "%Y-%m-%d %H:%M:%S",
inspect: "%Y-%m-%d %H:%M:%S.%9N %z",
number: "%Y%m%d%H%M%S",
nsec: "%Y%m%d%H%M%S%9N",
usec: "%Y%m%d%H%M%S%6N",
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/time/acts_like.rb | activesupport/lib/active_support/core_ext/time/acts_like.rb | # frozen_string_literal: true
require "active_support/core_ext/object/acts_like"
class Time
# Duck-types as a Time-like class. See Object#acts_like?.
def acts_like_time?
true
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activesupport/lib/active_support/core_ext/time/compatibility.rb | activesupport/lib/active_support/core_ext/time/compatibility.rb | # frozen_string_literal: true
require "active_support/core_ext/date_and_time/compatibility"
require "active_support/core_ext/module/redefine_method"
class Time
include DateAndTime::Compatibility
silence_redefinition_of_method :to_time
# Return +self+.
def to_time
self
end
end
| 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.