rbs_rails 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -2
- data/README.md +1 -0
- data/Rakefile +10 -2
- data/Steepfile +1 -0
- data/assets/sig/active_record.rbs +1 -1
- data/assets/sig/generated/actionpack.rbs +697 -543
- data/assets/sig/generated/actionview.rbs +313 -213
- data/assets/sig/generated/activejob.rbs +1920 -0
- data/assets/sig/generated/activemodel.rbs +690 -615
- data/assets/sig/generated/activerecord.rbs +5521 -4942
- data/assets/sig/generated/activesupport.rbs +1613 -1207
- data/assets/sig/generated/railties.rbs +426 -386
- data/assets/sig/patches/README.md +4 -0
- data/assets/sig/patches/for_actionpack.rbs +74 -0
- data/assets/sig/patches/for_actionview.rbs +19 -0
- data/assets/sig/patches/for_activemodel.rbs +11 -0
- data/assets/sig/patches/for_activerecord.rbs +84 -0
- data/assets/sig/patches/for_activesupport.rbs +48 -0
- data/assets/sig/patches/for_railties.rbs +30 -0
- data/assets/sig/pg.rbs +5 -0
- data/assets/sig/que.rbs +4 -0
- data/assets/sig/queue_classic.rbs +4 -0
- data/assets/sig/rack.rbs +1 -0
- data/assets/sig/sidekiq.rbs +4 -0
- data/assets/sig/sneakers.rbs +4 -0
- data/assets/sig/sucker_punch.rbs +4 -0
- data/bin/add-type-params.rb +7 -0
- data/bin/generate_rbs_from_rails_source_code.rb +195 -0
- data/bin/postprocess.rb +15 -6
- data/bin/rbs +1 -1
- data/lib/rbs_rails/active_record.rb +40 -10
- data/lib/rbs_rails/version.rb +1 -1
- metadata +18 -3
@@ -94,6 +94,8 @@ module ActiveSupport
|
|
94
94
|
# against it. Filters run first, then silencers.
|
95
95
|
def clean: (untyped backtrace, ?::Symbol kind) -> untyped
|
96
96
|
|
97
|
+
alias filter clean
|
98
|
+
|
97
99
|
# Adds a filter from the block provided. Each line in the backtrace will be
|
98
100
|
# mapped against this filter.
|
99
101
|
#
|
@@ -415,737 +417,739 @@ module ActiveSupport
|
|
415
417
|
end
|
416
418
|
|
417
419
|
module ActiveSupport
|
418
|
-
# See ActiveSupport::Cache::Store for documentation.
|
419
420
|
module Cache
|
420
|
-
|
421
|
-
|
422
|
-
UNIVERSAL_OPTIONS: ::Array[untyped]
|
423
|
-
|
424
|
-
module Strategy
|
421
|
+
module ConnectionPoolLike
|
422
|
+
def with: () { (untyped) -> untyped } -> untyped
|
425
423
|
end
|
426
424
|
|
427
|
-
#
|
428
|
-
#
|
429
|
-
# If no arguments are passed to this method, then a new
|
430
|
-
# ActiveSupport::Cache::MemoryStore object will be returned.
|
431
|
-
#
|
432
|
-
# If you pass a Symbol as the first argument, then a corresponding cache
|
433
|
-
# store class under the ActiveSupport::Cache namespace will be created.
|
434
|
-
# For example:
|
435
|
-
#
|
436
|
-
# ActiveSupport::Cache.lookup_store(:memory_store)
|
437
|
-
# # => returns a new ActiveSupport::Cache::MemoryStore object
|
438
|
-
#
|
439
|
-
# ActiveSupport::Cache.lookup_store(:mem_cache_store)
|
440
|
-
# # => returns a new ActiveSupport::Cache::MemCacheStore object
|
441
|
-
#
|
442
|
-
# Any additional arguments will be passed to the corresponding cache store
|
443
|
-
# class's constructor:
|
425
|
+
# Redis cache store.
|
444
426
|
#
|
445
|
-
#
|
446
|
-
#
|
427
|
+
# Deployment note: Take care to use a *dedicated Redis cache* rather
|
428
|
+
# than pointing this at your existing Redis server. It won't cope well
|
429
|
+
# with mixed usage patterns and it won't expire cache entries by default.
|
447
430
|
#
|
448
|
-
#
|
431
|
+
# Redis cache server setup guide: https://redis.io/topics/lru-cache
|
449
432
|
#
|
450
|
-
#
|
451
|
-
#
|
452
|
-
|
433
|
+
# * Supports vanilla Redis, hiredis, and Redis::Distributed.
|
434
|
+
# * Supports Memcached-like sharding across Redises with Redis::Distributed.
|
435
|
+
# * Fault tolerant. If the Redis server is unavailable, no exceptions are
|
436
|
+
# raised. Cache fetches are all misses and writes are dropped.
|
437
|
+
# * Local cache. Hot in-memory primary cache within block/middleware scope.
|
438
|
+
# * +read_multi+ and +write_multi+ support for Redis mget/mset. Use Redis::Distributed
|
439
|
+
# 4.0.1+ for distributed mget support.
|
440
|
+
# * +delete_matched+ support for Redis KEYS globs.
|
441
|
+
class RedisCacheStore < Store
|
442
|
+
# Keys are truncated with their own SHA2 digest if they exceed 1kB
|
443
|
+
MAX_KEY_BYTESIZE: ::Integer
|
453
444
|
|
454
|
-
|
455
|
-
# cache store. Optionally accepts a namespace, and all keys will be
|
456
|
-
# scoped within that namespace.
|
457
|
-
#
|
458
|
-
# If the +key+ argument provided is an array, or responds to +to_a+, then
|
459
|
-
# each of elements in the array will be turned into parameters/keys and
|
460
|
-
# concatenated into a single key. For example:
|
461
|
-
#
|
462
|
-
# ActiveSupport::Cache.expand_cache_key([:foo, :bar]) # => "foo/bar"
|
463
|
-
# ActiveSupport::Cache.expand_cache_key([:foo, :bar], "namespace") # => "namespace/foo/bar"
|
464
|
-
#
|
465
|
-
# The +key+ argument can also respond to +cache_key+ or +to_param+.
|
466
|
-
def self.expand_cache_key: (untyped key, ?untyped? namespace) -> untyped
|
445
|
+
DEFAULT_REDIS_OPTIONS: ::Hash[untyped, untyped]
|
467
446
|
|
468
|
-
|
447
|
+
DEFAULT_ERROR_HANDLER: untyped
|
469
448
|
|
470
|
-
|
471
|
-
|
472
|
-
def self.retrieve_store_class: (untyped store) -> untyped
|
449
|
+
# The maximum number of entries to receive per SCAN call.
|
450
|
+
SCAN_BATCH_SIZE: ::Integer
|
473
451
|
|
474
|
-
|
475
|
-
|
476
|
-
# under the ActiveSupport::Cache module, e.g.
|
477
|
-
# ActiveSupport::Cache::MemCacheStore. MemCacheStore is currently the most
|
478
|
-
# popular cache store for large production websites.
|
479
|
-
#
|
480
|
-
# Some implementations may not support all methods beyond the basic cache
|
481
|
-
# methods of +fetch+, +write+, +read+, +exist?+, and +delete+.
|
482
|
-
#
|
483
|
-
# ActiveSupport::Cache::Store can store any serializable Ruby object.
|
484
|
-
#
|
485
|
-
# cache = ActiveSupport::Cache::MemoryStore.new
|
486
|
-
#
|
487
|
-
# cache.read('city') # => nil
|
488
|
-
# cache.write('city', "Duckburgh")
|
489
|
-
# cache.read('city') # => "Duckburgh"
|
490
|
-
#
|
491
|
-
# Keys are always translated into Strings and are case sensitive. When an
|
492
|
-
# object is specified as a key and has a +cache_key+ method defined, this
|
493
|
-
# method will be called to define the key. Otherwise, the +to_param+
|
494
|
-
# method will be called. Hashes and Arrays can also be used as keys. The
|
495
|
-
# elements will be delimited by slashes, and the elements within a Hash
|
496
|
-
# will be sorted by key so they are consistent.
|
497
|
-
#
|
498
|
-
# cache.read('city') == cache.read(:city) # => true
|
499
|
-
#
|
500
|
-
# Nil values can be cached.
|
501
|
-
#
|
502
|
-
# If your cache is on a shared infrastructure, you can define a namespace
|
503
|
-
# for your cache entries. If a namespace is defined, it will be prefixed on
|
504
|
-
# to every key. The namespace can be either a static value or a Proc. If it
|
505
|
-
# is a Proc, it will be invoked when each key is evaluated so that you can
|
506
|
-
# use application logic to invalidate keys.
|
507
|
-
#
|
508
|
-
# cache.namespace = -> { @last_mod_time } # Set the namespace to a variable
|
509
|
-
# @last_mod_time = Time.now # Invalidate the entire cache by changing namespace
|
510
|
-
#
|
511
|
-
# Cached data larger than 1kB are compressed by default. To turn off
|
512
|
-
# compression, pass <tt>compress: false</tt> to the initializer or to
|
513
|
-
# individual +fetch+ or +write+ method calls. The 1kB compression
|
514
|
-
# threshold is configurable with the <tt>:compress_threshold</tt> option,
|
515
|
-
# specified in bytes.
|
516
|
-
class Store
|
517
|
-
attr_reader silence: untyped
|
452
|
+
# Advertise cache versioning support.
|
453
|
+
def self.supports_cache_versioning?: () -> ::TrueClass
|
518
454
|
|
519
|
-
|
455
|
+
module LocalCacheWithRaw
|
456
|
+
def write_entry: (untyped key, untyped entry, **untyped options) -> untyped
|
520
457
|
|
521
|
-
|
458
|
+
def write_multi_entries: (untyped entries, **untyped options) -> untyped
|
459
|
+
end
|
522
460
|
|
523
|
-
def self.
|
461
|
+
def self.build_redis: (?redis: untyped? redis, ?url: untyped? url, **untyped redis_options) -> untyped
|
524
462
|
|
525
|
-
|
526
|
-
# except for <tt>:namespace</tt> which can be used to set the global
|
527
|
-
# namespace for the cache.
|
528
|
-
def initialize: (?untyped? options) -> untyped
|
463
|
+
def self.build_redis_distributed_client: (urls: untyped urls, **untyped redis_options) -> untyped
|
529
464
|
|
530
|
-
|
531
|
-
def silence!: () -> untyped
|
465
|
+
def self.build_redis_client: (url: untyped url, **untyped redis_options) -> untyped
|
532
466
|
|
533
|
-
|
534
|
-
def mute: () { () -> untyped } -> untyped
|
467
|
+
attr_reader redis_options: untyped
|
535
468
|
|
536
|
-
|
537
|
-
|
469
|
+
attr_reader max_key_bytesize: untyped
|
470
|
+
|
471
|
+
# Creates a new Redis cache store.
|
538
472
|
#
|
539
|
-
#
|
540
|
-
#
|
541
|
-
# the key and executed in the event of a cache miss. The return value of the
|
542
|
-
# block will be written to the cache under the given cache key, and that
|
543
|
-
# return value will be returned.
|
473
|
+
# Handles four options: :redis block, :redis instance, single :url
|
474
|
+
# string, and multiple :url strings.
|
544
475
|
#
|
545
|
-
#
|
546
|
-
#
|
476
|
+
# Option Class Result
|
477
|
+
# :redis Proc -> options[:redis].call
|
478
|
+
# :redis Object -> options[:redis]
|
479
|
+
# :url String -> Redis.new(url: (trim non-ascii characters))
|
480
|
+
# :url Array -> Redis::Distributed.new([{ url: (trim non-ascii characters) }, { url: (trim non-ascii characters) }, (trim non-ascii characters)])
|
547
481
|
#
|
548
|
-
#
|
549
|
-
#
|
550
|
-
# 'Duckburgh'
|
551
|
-
# end
|
552
|
-
# cache.fetch('city') # => "Duckburgh"
|
482
|
+
# No namespace is set by default. Provide one if the Redis cache
|
483
|
+
# server is shared with other apps: <tt>namespace: 'myapp-cache'</tt>.
|
553
484
|
#
|
554
|
-
#
|
555
|
-
#
|
556
|
-
#
|
557
|
-
#
|
485
|
+
# Compression is enabled by default with a 1kB threshold, so cached
|
486
|
+
# values larger than 1kB are automatically compressed. Disable by
|
487
|
+
# passing <tt>compress: false</tt> or change the threshold by passing
|
488
|
+
# <tt>compress_threshold: 4.kilobytes</tt>.
|
558
489
|
#
|
559
|
-
#
|
560
|
-
#
|
561
|
-
#
|
490
|
+
# No expiry is set on cache entries by default. Redis is expected to
|
491
|
+
# be configured with an eviction policy that automatically deletes
|
492
|
+
# least-recently or -frequently used keys when it reaches max memory.
|
493
|
+
# See https://redis.io/topics/lru-cache for cache server setup.
|
562
494
|
#
|
563
|
-
#
|
564
|
-
#
|
565
|
-
#
|
495
|
+
# Race condition TTL is not set by default. This can be used to avoid
|
496
|
+
# "thundering herd" cache writes when hot cache entries are expired.
|
497
|
+
# See <tt>ActiveSupport::Cache::Store#fetch</tt> for more.
|
498
|
+
def initialize: (?namespace: untyped? namespace, ?compress: bool compress, ?compress_threshold: untyped compress_threshold, ?expires_in: untyped? expires_in, ?race_condition_ttl: untyped? race_condition_ttl, ?error_handler: untyped error_handler, **untyped redis_options) -> untyped
|
499
|
+
|
500
|
+
def redis: () -> untyped
|
501
|
+
|
502
|
+
def inspect: () -> ::String
|
503
|
+
|
504
|
+
# Cache Store API implementation.
|
566
505
|
#
|
567
|
-
#
|
506
|
+
# Read multiple values at once. Returns a hash of requested keys ->
|
507
|
+
# fetched values.
|
508
|
+
def read_multi: (*untyped names) -> untyped
|
509
|
+
|
510
|
+
# Cache Store API implementation.
|
568
511
|
#
|
569
|
-
#
|
570
|
-
# cache.fetch('bar', skip_nil: true) { nil }
|
571
|
-
# cache.exist?('foo') # => true
|
572
|
-
# cache.exist?('bar') # => false
|
512
|
+
# Supports Redis KEYS glob patterns:
|
573
513
|
#
|
514
|
+
# h?llo matches hello, hallo and hxllo
|
515
|
+
# h*llo matches hllo and heeeello
|
516
|
+
# h[ae]llo matches hello and hallo, but not hillo
|
517
|
+
# h[^e]llo matches hallo, hbllo, ... but not hello
|
518
|
+
# h[a-b]llo matches hallo and hbllo
|
574
519
|
#
|
575
|
-
#
|
520
|
+
# Use \ to escape special characters if you want to match them verbatim.
|
576
521
|
#
|
577
|
-
#
|
578
|
-
# All caches support auto-expiring content after a specified number of
|
579
|
-
# seconds. This value can be specified as an option to the constructor
|
580
|
-
# (in which case all entries will be affected), or it can be supplied to
|
581
|
-
# the +fetch+ or +write+ method to effect just one entry.
|
522
|
+
# See https://redis.io/commands/KEYS for more.
|
582
523
|
#
|
583
|
-
#
|
584
|
-
|
524
|
+
# Failsafe: Raises errors.
|
525
|
+
def delete_matched: (untyped matcher, ?untyped? options) -> untyped
|
526
|
+
|
527
|
+
# Cache Store API implementation.
|
585
528
|
#
|
586
|
-
#
|
587
|
-
#
|
588
|
-
#
|
529
|
+
# Increment a cached value. This method uses the Redis incr atomic
|
530
|
+
# operator and can only be used on values written with the :raw option.
|
531
|
+
# Calling it on a value not stored with :raw will initialize that value
|
532
|
+
# to zero.
|
589
533
|
#
|
590
|
-
#
|
591
|
-
|
592
|
-
|
593
|
-
#
|
594
|
-
# avoid that case the first process to find an expired cache entry will
|
595
|
-
# bump the cache expiration time by the value set in <tt>:race_condition_ttl</tt>.
|
596
|
-
# Yes, this process is extending the time for a stale value by another few
|
597
|
-
# seconds. Because of extended life of the previous cache, other processes
|
598
|
-
# will continue to use slightly stale data for a just a bit longer. In the
|
599
|
-
# meantime that first process will go ahead and will write into cache the
|
600
|
-
# new value. After that all the processes will start getting the new value.
|
601
|
-
# The key is to keep <tt>:race_condition_ttl</tt> small.
|
534
|
+
# Failsafe: Raises errors.
|
535
|
+
def increment: (untyped name, ?::Integer amount, ?untyped? options) -> untyped
|
536
|
+
|
537
|
+
# Cache Store API implementation.
|
602
538
|
#
|
603
|
-
#
|
604
|
-
#
|
605
|
-
#
|
606
|
-
#
|
607
|
-
# any role.
|
539
|
+
# Decrement a cached value. This method uses the Redis decr atomic
|
540
|
+
# operator and can only be used on values written with the :raw option.
|
541
|
+
# Calling it on a value not stored with :raw will initialize that value
|
542
|
+
# to zero.
|
608
543
|
#
|
609
|
-
#
|
610
|
-
|
544
|
+
# Failsafe: Raises errors.
|
545
|
+
def decrement: (untyped name, ?::Integer amount, ?untyped? options) -> untyped
|
546
|
+
|
547
|
+
# Cache Store API implementation.
|
611
548
|
#
|
612
|
-
#
|
613
|
-
#
|
614
|
-
|
615
|
-
# sleep 60
|
616
|
-
#
|
617
|
-
# Thread.new do
|
618
|
-
# val_1 = cache.fetch('foo', race_condition_ttl: 10.seconds) do
|
619
|
-
# sleep 1
|
620
|
-
# 'new value 1'
|
621
|
-
# end
|
622
|
-
# end
|
623
|
-
#
|
624
|
-
# Thread.new do
|
625
|
-
# val_2 = cache.fetch('foo', race_condition_ttl: 10.seconds) do
|
626
|
-
# 'new value 2'
|
627
|
-
# end
|
628
|
-
# end
|
629
|
-
#
|
630
|
-
# cache.fetch('foo') # => "original value"
|
631
|
-
# sleep 10 # First thread extended the life of cache by another 10 seconds
|
632
|
-
# cache.fetch('foo') # => "new value 1"
|
633
|
-
# val_1 # => "new value 1"
|
634
|
-
# val_2 # => "original value"
|
635
|
-
#
|
636
|
-
# Other options will be handled by the specific cache store implementation.
|
637
|
-
# Internally, #fetch calls #read_entry, and calls #write_entry on a cache
|
638
|
-
# miss. +options+ will be passed to the #read and #write calls.
|
639
|
-
#
|
640
|
-
# For example, MemCacheStore's #write method supports the +:raw+
|
641
|
-
# option, which tells the memcached server to store all values as strings.
|
642
|
-
# We can use this option with #fetch too:
|
643
|
-
#
|
644
|
-
# cache = ActiveSupport::Cache::MemCacheStore.new
|
645
|
-
# cache.fetch("foo", force: true, raw: true) do
|
646
|
-
# :bar
|
647
|
-
# end
|
648
|
-
# cache.fetch('foo') # => "bar"
|
649
|
-
def fetch: (untyped name, ?untyped? options) { (untyped) -> untyped } -> untyped
|
549
|
+
# Removes expired entries. Handled natively by Redis least-recently-/
|
550
|
+
# least-frequently-used expiry, so manual cleanup is not supported.
|
551
|
+
def cleanup: (?untyped? options) -> untyped
|
650
552
|
|
651
|
-
#
|
652
|
-
#
|
653
|
-
# +nil+ is returned.
|
654
|
-
#
|
655
|
-
# Note, if data was written with the <tt>:expires_in</tt> or
|
656
|
-
# <tt>:version</tt> options, both of these conditions are applied before
|
657
|
-
# the data is returned.
|
553
|
+
# Clear the entire cache on all Redis servers. Safe to use on
|
554
|
+
# shared servers if the cache is namespaced.
|
658
555
|
#
|
659
|
-
#
|
660
|
-
def
|
556
|
+
# Failsafe: Raises errors.
|
557
|
+
def clear: (?untyped? options) -> untyped
|
661
558
|
|
662
|
-
|
663
|
-
# in the last argument.
|
664
|
-
#
|
665
|
-
# Some cache implementation may optimize this method.
|
666
|
-
#
|
667
|
-
# Returns a hash mapping the names provided to the values found.
|
668
|
-
def read_multi: (*untyped names) -> untyped
|
559
|
+
def mget_capable?: () -> untyped
|
669
560
|
|
670
|
-
|
671
|
-
def write_multi: (untyped hash, ?untyped? options) -> untyped
|
561
|
+
def mset_capable?: () -> untyped
|
672
562
|
|
673
|
-
|
674
|
-
# the cache with the given keys, then that data is returned. Otherwise,
|
675
|
-
# the supplied block is called for each key for which there was no data,
|
676
|
-
# and the result will be written to the cache and returned.
|
677
|
-
# Therefore, you need to pass a block that returns the data to be written
|
678
|
-
# to the cache. If you do not want to write the cache when the cache is
|
679
|
-
# not found, use #read_multi.
|
680
|
-
#
|
681
|
-
# Returns a hash with the data for each of the names. For example:
|
682
|
-
#
|
683
|
-
# cache.write("bim", "bam")
|
684
|
-
# cache.fetch_multi("bim", "unknown_key") do |key|
|
685
|
-
# "Fallback value for key: #{key}"
|
686
|
-
# end
|
687
|
-
# # => { "bim" => "bam",
|
688
|
-
# # "unknown_key" => "Fallback value for key: unknown_key" }
|
689
|
-
#
|
690
|
-
# Options are passed to the underlying cache implementation. For example:
|
691
|
-
#
|
692
|
-
# cache.fetch_multi("fizz", expires_in: 5.seconds) do |key|
|
693
|
-
# "buzz"
|
694
|
-
# end
|
695
|
-
# # => {"fizz"=>"buzz"}
|
696
|
-
# cache.read("fizz")
|
697
|
-
# # => "buzz"
|
698
|
-
# sleep(6)
|
699
|
-
# cache.read("fizz")
|
700
|
-
# # => nil
|
701
|
-
def fetch_multi: (*untyped names) { (untyped) -> untyped } -> untyped
|
563
|
+
def set_redis_capabilities: () -> untyped
|
702
564
|
|
703
|
-
#
|
704
|
-
#
|
705
|
-
|
706
|
-
def write: (untyped name, untyped value, ?untyped? options) -> untyped
|
565
|
+
# Store provider interface:
|
566
|
+
# Read an entry from the cache.
|
567
|
+
def read_entry: (untyped key, **untyped options) -> untyped
|
707
568
|
|
708
|
-
|
709
|
-
#
|
710
|
-
# Options are passed to the underlying cache implementation.
|
711
|
-
def delete: (untyped name, ?untyped? options) -> untyped
|
569
|
+
def read_multi_entries: (untyped names, **untyped options) -> untyped
|
712
570
|
|
713
|
-
|
714
|
-
#
|
715
|
-
# Options are passed to the underlying cache implementation.
|
716
|
-
def exist?: (untyped name, ?untyped? options) -> untyped
|
571
|
+
def read_multi_mget: (*untyped names) -> (::Hash[untyped, untyped] | untyped)
|
717
572
|
|
718
|
-
#
|
719
|
-
#
|
720
|
-
# Options are passed to the underlying cache implementation.
|
573
|
+
# Write an entry to the cache.
|
721
574
|
#
|
722
|
-
#
|
723
|
-
def
|
575
|
+
# Requires Redis 2.6.12+ for extended SET options.
|
576
|
+
def write_entry: (untyped key, untyped entry, ?unless_exist: bool unless_exist, ?raw: bool raw, ?expires_in: untyped? expires_in, ?race_condition_ttl: untyped? race_condition_ttl, **untyped options) -> untyped
|
724
577
|
|
725
|
-
|
726
|
-
#
|
727
|
-
# Options are passed to the underlying cache implementation.
|
728
|
-
#
|
729
|
-
# Some implementations may not support this method.
|
730
|
-
def increment: (untyped name, ?::Integer amount, ?untyped? options) -> untyped
|
578
|
+
def write_key_expiry: (untyped client, untyped key, untyped options) -> untyped
|
731
579
|
|
732
|
-
#
|
733
|
-
|
734
|
-
# Options are passed to the underlying cache implementation.
|
735
|
-
#
|
736
|
-
# Some implementations may not support this method.
|
737
|
-
def decrement: (untyped name, ?::Integer amount, ?untyped? options) -> untyped
|
580
|
+
# Delete an entry from the cache.
|
581
|
+
def delete_entry: (untyped key, untyped options) -> untyped
|
738
582
|
|
739
|
-
#
|
740
|
-
|
741
|
-
# Options are passed to the underlying cache implementation.
|
742
|
-
#
|
743
|
-
# Some implementations may not support this method.
|
744
|
-
def cleanup: (?untyped? options) -> untyped
|
583
|
+
# Nonstandard store provider API to write multiple values at once.
|
584
|
+
def write_multi_entries: (untyped entries, ?expires_in: untyped? expires_in, **untyped options) -> untyped
|
745
585
|
|
746
|
-
#
|
747
|
-
|
748
|
-
#
|
749
|
-
# The options hash is passed to the underlying cache implementation.
|
750
|
-
#
|
751
|
-
# Some implementations may not support this method.
|
752
|
-
def clear: (?untyped? options) -> untyped
|
586
|
+
# Truncate keys that exceed 1kB.
|
587
|
+
def normalize_key: (untyped key, untyped options) -> untyped
|
753
588
|
|
754
|
-
def
|
589
|
+
def truncate_key: (untyped key) -> untyped
|
755
590
|
|
756
|
-
|
757
|
-
# this method.
|
758
|
-
def read_entry: (untyped key, **untyped options) -> untyped
|
591
|
+
def deserialize_entry: (untyped serialized_entry, raw: untyped raw) -> untyped
|
759
592
|
|
760
|
-
|
761
|
-
# this method.
|
762
|
-
def write_entry: (untyped key, untyped entry, **untyped options) -> untyped
|
593
|
+
def serialize_entry: (untyped entry, ?raw: bool raw) -> untyped
|
763
594
|
|
764
|
-
|
765
|
-
# implement this method.
|
766
|
-
def read_multi_entries: (untyped names, **untyped options) -> untyped
|
595
|
+
def serialize_entries: (untyped entries, ?raw: bool raw) -> untyped
|
767
596
|
|
768
|
-
|
769
|
-
# implement this method.
|
770
|
-
def write_multi_entries: (untyped hash, **untyped options) -> untyped
|
597
|
+
def failsafe: (untyped method, ?returning: untyped? returning) { () -> untyped } -> untyped
|
771
598
|
|
772
|
-
|
773
|
-
|
774
|
-
|
599
|
+
def handle_exception: (exception: untyped exception, method: untyped method, returning: untyped returning) -> untyped
|
600
|
+
end
|
601
|
+
end
|
602
|
+
end
|
775
603
|
|
776
|
-
|
777
|
-
|
604
|
+
module ActiveSupport
|
605
|
+
module Cache
|
606
|
+
module Strategy
|
607
|
+
# Caches that implement LocalCache will be backed by an in-memory cache for the
|
608
|
+
# duration of a block. Repeated calls to the cache for the same key will hit the
|
609
|
+
# in-memory cache for faster access.
|
610
|
+
module LocalCache
|
611
|
+
class LocalCacheRegistry
|
612
|
+
# Class for storing and registering the local caches.
|
613
|
+
# :nodoc:
|
614
|
+
extend ActiveSupport::PerThreadRegistry
|
778
615
|
|
779
|
-
|
780
|
-
# cache stores to do additional normalization.
|
781
|
-
def normalize_key: (untyped key, ?untyped? options) -> untyped
|
616
|
+
def initialize: () -> untyped
|
782
617
|
|
783
|
-
|
784
|
-
#
|
785
|
-
# namespace_key 'foo', namespace: 'cache'
|
786
|
-
# # => 'cache:foo'
|
787
|
-
#
|
788
|
-
# With a namespace block:
|
789
|
-
#
|
790
|
-
# namespace_key 'foo', namespace: -> { 'cache' }
|
791
|
-
# # => 'cache:foo'
|
792
|
-
def namespace_key: (untyped key, ?untyped? options) -> untyped
|
618
|
+
def cache_for: (untyped local_cache_key) -> untyped
|
793
619
|
|
794
|
-
|
795
|
-
# object responds to +cache_key+. Otherwise, +to_param+ method will be
|
796
|
-
# called. If the key is a Hash, then keys will be sorted alphabetically.
|
797
|
-
def expanded_key: (untyped key) -> untyped
|
620
|
+
def set_cache_for: (untyped local_cache_key, untyped value) -> untyped
|
798
621
|
|
799
|
-
|
622
|
+
def self.set_cache_for: (untyped l, untyped v) -> untyped
|
800
623
|
|
801
|
-
|
624
|
+
def self.cache_for: (untyped l) -> untyped
|
625
|
+
end
|
802
626
|
|
803
|
-
|
627
|
+
# Simple memory backed cache. This cache is not thread safe and is intended only
|
628
|
+
# for serving as a temporary memory cache for a single thread.
|
629
|
+
class LocalStore < Store
|
630
|
+
def initialize: () -> untyped
|
804
631
|
|
805
|
-
|
632
|
+
def synchronize: () { () -> untyped } -> untyped
|
806
633
|
|
807
|
-
|
634
|
+
def clear: (?untyped? options) -> untyped
|
808
635
|
|
809
|
-
|
636
|
+
def read_entry: (untyped key, **untyped options) -> untyped
|
810
637
|
|
811
|
-
|
812
|
-
end
|
638
|
+
def read_multi_entries: (untyped keys, **untyped options) -> untyped
|
813
639
|
|
814
|
-
|
815
|
-
# This class is used to represent cache entries. Cache entries have a value, an optional
|
816
|
-
# expiration time, and an optional version. The expiration time is used to support the :race_condition_ttl option
|
817
|
-
# on the cache. The version is used to support the :version option on the cache for rejecting
|
818
|
-
# mismatches.
|
819
|
-
#
|
820
|
-
# Since cache entries in most instances will be serialized, the internals of this class are highly optimized
|
821
|
-
# using short instance variable names that are lazily defined.
|
822
|
-
# :nodoc:
|
823
|
-
attr_reader version: untyped
|
640
|
+
def write_entry: (untyped key, untyped value, **untyped options) -> ::TrueClass
|
824
641
|
|
825
|
-
|
642
|
+
def delete_entry: (untyped key, **untyped options) -> untyped
|
826
643
|
|
827
|
-
|
828
|
-
|
829
|
-
def initialize: (untyped value, ?expires_in: untyped? expires_in, ?version: untyped? version, ?compress_threshold: untyped compress_threshold, ?compress: bool compress) -> untyped
|
644
|
+
def fetch_entry: (untyped key, ?untyped? options) { () -> untyped } -> untyped
|
645
|
+
end
|
830
646
|
|
831
|
-
|
647
|
+
# Use a local cache for the duration of block.
|
648
|
+
def with_local_cache: () { () -> untyped } -> untyped
|
832
649
|
|
833
|
-
|
650
|
+
# Middleware class can be inserted as a Rack handler to be local cache for the
|
651
|
+
# duration of request.
|
652
|
+
def middleware: () -> untyped
|
834
653
|
|
835
|
-
|
836
|
-
# the value set when the entry was created.
|
837
|
-
def expired?: () -> untyped
|
654
|
+
def clear: (**untyped options) -> untyped
|
838
655
|
|
839
|
-
|
656
|
+
def cleanup: (**untyped options) -> untyped
|
840
657
|
|
841
|
-
|
658
|
+
def increment: (untyped name, ?::Integer amount, **untyped options) -> untyped
|
842
659
|
|
843
|
-
|
844
|
-
# <tt>value.size</tt> if the data is compressed.
|
845
|
-
def size: () -> untyped
|
660
|
+
def decrement: (untyped name, ?::Integer amount, **untyped options) -> untyped
|
846
661
|
|
847
|
-
|
848
|
-
# serialize entries to protect against accidental cache modifications.
|
849
|
-
def dup_value!: () -> untyped
|
662
|
+
def read_entry: (untyped key, **untyped options) -> untyped
|
850
663
|
|
851
|
-
|
664
|
+
def read_multi_entries: (untyped keys, **untyped options) -> untyped
|
852
665
|
|
853
|
-
|
666
|
+
def write_entry: (untyped key, untyped entry, **untyped options) -> untyped
|
854
667
|
|
855
|
-
|
668
|
+
def delete_entry: (untyped key, **untyped options) -> untyped
|
669
|
+
|
670
|
+
def write_cache_value: (untyped name, untyped value, **untyped options) -> untyped
|
671
|
+
|
672
|
+
def local_cache_key: () -> untyped
|
673
|
+
|
674
|
+
def local_cache: () -> untyped
|
675
|
+
|
676
|
+
def bypass_local_cache: () { () -> untyped } -> untyped
|
677
|
+
|
678
|
+
def use_temporary_local_cache: (untyped temporary_cache) { () -> untyped } -> untyped
|
679
|
+
end
|
856
680
|
end
|
857
681
|
end
|
858
682
|
end
|
859
683
|
|
860
684
|
module ActiveSupport
|
861
685
|
module Cache
|
862
|
-
module
|
863
|
-
|
686
|
+
module Strategy
|
687
|
+
module LocalCache
|
688
|
+
class Middleware
|
689
|
+
# -
|
690
|
+
# This class wraps up local storage for middlewares. Only the middleware method should
|
691
|
+
# construct them.
|
692
|
+
# :nodoc:
|
693
|
+
attr_reader name: untyped
|
694
|
+
|
695
|
+
# -
|
696
|
+
# This class wraps up local storage for middlewares. Only the middleware method should
|
697
|
+
# construct them.
|
698
|
+
# :nodoc:
|
699
|
+
attr_reader local_cache_key: untyped
|
700
|
+
|
701
|
+
def initialize: (untyped name, untyped local_cache_key) -> untyped
|
702
|
+
|
703
|
+
def new: (untyped app) -> untyped
|
704
|
+
|
705
|
+
def call: (untyped env) -> untyped
|
706
|
+
end
|
707
|
+
end
|
864
708
|
end
|
709
|
+
end
|
710
|
+
end
|
865
711
|
|
866
|
-
|
712
|
+
module ActiveSupport
|
713
|
+
# See ActiveSupport::Cache::Store for documentation.
|
714
|
+
module Cache
|
715
|
+
# These options mean something to all cache implementations. Individual cache
|
716
|
+
# implementations may support additional options.
|
717
|
+
UNIVERSAL_OPTIONS: ::Array[untyped]
|
718
|
+
|
719
|
+
module Strategy
|
720
|
+
end
|
721
|
+
|
722
|
+
# Creates a new Store object according to the given options.
|
867
723
|
#
|
868
|
-
#
|
869
|
-
#
|
870
|
-
# with mixed usage patterns and it won't expire cache entries by default.
|
724
|
+
# If no arguments are passed to this method, then a new
|
725
|
+
# ActiveSupport::Cache::MemoryStore object will be returned.
|
871
726
|
#
|
872
|
-
#
|
727
|
+
# If you pass a Symbol as the first argument, then a corresponding cache
|
728
|
+
# store class under the ActiveSupport::Cache namespace will be created.
|
729
|
+
# For example:
|
873
730
|
#
|
874
|
-
#
|
875
|
-
#
|
876
|
-
#
|
877
|
-
#
|
878
|
-
#
|
879
|
-
#
|
880
|
-
#
|
881
|
-
#
|
882
|
-
|
883
|
-
|
884
|
-
|
731
|
+
# ActiveSupport::Cache.lookup_store(:memory_store)
|
732
|
+
# # => returns a new ActiveSupport::Cache::MemoryStore object
|
733
|
+
#
|
734
|
+
# ActiveSupport::Cache.lookup_store(:mem_cache_store)
|
735
|
+
# # => returns a new ActiveSupport::Cache::MemCacheStore object
|
736
|
+
#
|
737
|
+
# Any additional arguments will be passed to the corresponding cache store
|
738
|
+
# class's constructor:
|
739
|
+
#
|
740
|
+
# ActiveSupport::Cache.lookup_store(:file_store, '/tmp/cache')
|
741
|
+
# # => same as: ActiveSupport::Cache::FileStore.new('/tmp/cache')
|
742
|
+
#
|
743
|
+
# If the first argument is not a Symbol, then it will simply be returned:
|
744
|
+
#
|
745
|
+
# ActiveSupport::Cache.lookup_store(MyOwnCacheStore.new)
|
746
|
+
# # => returns MyOwnCacheStore.new
|
747
|
+
def self.lookup_store: (?untyped? store, *untyped parameters) -> untyped
|
885
748
|
|
886
|
-
|
749
|
+
# Expands out the +key+ argument into a key that can be used for the
|
750
|
+
# cache store. Optionally accepts a namespace, and all keys will be
|
751
|
+
# scoped within that namespace.
|
752
|
+
#
|
753
|
+
# If the +key+ argument provided is an array, or responds to +to_a+, then
|
754
|
+
# each of elements in the array will be turned into parameters/keys and
|
755
|
+
# concatenated into a single key. For example:
|
756
|
+
#
|
757
|
+
# ActiveSupport::Cache.expand_cache_key([:foo, :bar]) # => "foo/bar"
|
758
|
+
# ActiveSupport::Cache.expand_cache_key([:foo, :bar], "namespace") # => "namespace/foo/bar"
|
759
|
+
#
|
760
|
+
# The +key+ argument can also respond to +cache_key+ or +to_param+.
|
761
|
+
def self.expand_cache_key: (untyped key, ?untyped? namespace) -> untyped
|
887
762
|
|
888
|
-
|
763
|
+
def self.retrieve_cache_key: (untyped key) -> untyped
|
889
764
|
|
890
|
-
|
891
|
-
|
765
|
+
# Obtains the specified cache store class, given the name of the +store+.
|
766
|
+
# Raises an error when the store class cannot be found.
|
767
|
+
def self.retrieve_store_class: (untyped store) -> untyped
|
892
768
|
|
893
|
-
|
894
|
-
|
769
|
+
# An abstract cache store class. There are multiple cache store
|
770
|
+
# implementations, each having its own additional features. See the classes
|
771
|
+
# under the ActiveSupport::Cache module, e.g.
|
772
|
+
# ActiveSupport::Cache::MemCacheStore. MemCacheStore is currently the most
|
773
|
+
# popular cache store for large production websites.
|
774
|
+
#
|
775
|
+
# Some implementations may not support all methods beyond the basic cache
|
776
|
+
# methods of +fetch+, +write+, +read+, +exist?+, and +delete+.
|
777
|
+
#
|
778
|
+
# ActiveSupport::Cache::Store can store any serializable Ruby object.
|
779
|
+
#
|
780
|
+
# cache = ActiveSupport::Cache::MemoryStore.new
|
781
|
+
#
|
782
|
+
# cache.read('city') # => nil
|
783
|
+
# cache.write('city', "Duckburgh")
|
784
|
+
# cache.read('city') # => "Duckburgh"
|
785
|
+
#
|
786
|
+
# Keys are always translated into Strings and are case sensitive. When an
|
787
|
+
# object is specified as a key and has a +cache_key+ method defined, this
|
788
|
+
# method will be called to define the key. Otherwise, the +to_param+
|
789
|
+
# method will be called. Hashes and Arrays can also be used as keys. The
|
790
|
+
# elements will be delimited by slashes, and the elements within a Hash
|
791
|
+
# will be sorted by key so they are consistent.
|
792
|
+
#
|
793
|
+
# cache.read('city') == cache.read(:city) # => true
|
794
|
+
#
|
795
|
+
# Nil values can be cached.
|
796
|
+
#
|
797
|
+
# If your cache is on a shared infrastructure, you can define a namespace
|
798
|
+
# for your cache entries. If a namespace is defined, it will be prefixed on
|
799
|
+
# to every key. The namespace can be either a static value or a Proc. If it
|
800
|
+
# is a Proc, it will be invoked when each key is evaluated so that you can
|
801
|
+
# use application logic to invalidate keys.
|
802
|
+
#
|
803
|
+
# cache.namespace = -> { @last_mod_time } # Set the namespace to a variable
|
804
|
+
# @last_mod_time = Time.now # Invalidate the entire cache by changing namespace
|
805
|
+
#
|
806
|
+
# Cached data larger than 1kB are compressed by default. To turn off
|
807
|
+
# compression, pass <tt>compress: false</tt> to the initializer or to
|
808
|
+
# individual +fetch+ or +write+ method calls. The 1kB compression
|
809
|
+
# threshold is configurable with the <tt>:compress_threshold</tt> option,
|
810
|
+
# specified in bytes.
|
811
|
+
class Store
|
812
|
+
attr_reader silence: untyped
|
895
813
|
|
896
|
-
|
897
|
-
def write_entry: (untyped key, untyped entry, **untyped options) -> untyped
|
814
|
+
attr_reader options: untyped
|
898
815
|
|
899
|
-
|
900
|
-
end
|
816
|
+
alias silence? silence
|
901
817
|
|
902
|
-
def self.
|
818
|
+
def self.retrieve_pool_options: (untyped options) -> untyped
|
903
819
|
|
904
|
-
def self.
|
820
|
+
def self.ensure_connection_pool_added!: () -> untyped
|
905
821
|
|
906
|
-
|
822
|
+
# Creates a new cache. The options will be passed to any write method calls
|
823
|
+
# except for <tt>:namespace</tt> which can be used to set the global
|
824
|
+
# namespace for the cache.
|
825
|
+
def initialize: (?untyped? options) -> untyped
|
907
826
|
|
908
|
-
|
827
|
+
# Silences the logger.
|
828
|
+
def silence!: () -> untyped
|
909
829
|
|
910
|
-
|
830
|
+
# Silences the logger within a block.
|
831
|
+
def mute: () { () -> untyped } -> untyped
|
911
832
|
|
912
|
-
#
|
833
|
+
# Fetches data from the cache, using the given key. If there is data in
|
834
|
+
# the cache with the given key, then that data is returned.
|
913
835
|
#
|
914
|
-
#
|
915
|
-
#
|
836
|
+
# If there is no such data in the cache (a cache miss), then +nil+ will be
|
837
|
+
# returned. However, if a block has been passed, that block will be passed
|
838
|
+
# the key and executed in the event of a cache miss. The return value of the
|
839
|
+
# block will be written to the cache under the given cache key, and that
|
840
|
+
# return value will be returned.
|
916
841
|
#
|
917
|
-
#
|
918
|
-
#
|
919
|
-
# :redis Object -> options[:redis]
|
920
|
-
# :url String -> Redis.new(url: (trim non-ascii characters))
|
921
|
-
# :url Array -> Redis::Distributed.new([{ url: (trim non-ascii characters) }, { url: (trim non-ascii characters) }, (trim non-ascii characters)])
|
842
|
+
# cache.write('today', 'Monday')
|
843
|
+
# cache.fetch('today') # => "Monday"
|
922
844
|
#
|
923
|
-
#
|
924
|
-
#
|
845
|
+
# cache.fetch('city') # => nil
|
846
|
+
# cache.fetch('city') do
|
847
|
+
# 'Duckburgh'
|
848
|
+
# end
|
849
|
+
# cache.fetch('city') # => "Duckburgh"
|
925
850
|
#
|
926
|
-
#
|
927
|
-
#
|
928
|
-
#
|
929
|
-
#
|
851
|
+
# You may also specify additional options via the +options+ argument.
|
852
|
+
# Setting <tt>force: true</tt> forces a cache "miss," meaning we treat
|
853
|
+
# the cache value as missing even if it's present. Passing a block is
|
854
|
+
# required when +force+ is true so this always results in a cache write.
|
930
855
|
#
|
931
|
-
#
|
932
|
-
#
|
933
|
-
#
|
934
|
-
# See https://redis.io/topics/lru-cache for cache server setup.
|
856
|
+
# cache.write('today', 'Monday')
|
857
|
+
# cache.fetch('today', force: true) { 'Tuesday' } # => 'Tuesday'
|
858
|
+
# cache.fetch('today', force: true) # => ArgumentError
|
935
859
|
#
|
936
|
-
#
|
937
|
-
#
|
938
|
-
#
|
939
|
-
def initialize: (?error_handler: untyped error_handler, ?race_condition_ttl: untyped? race_condition_ttl, ?expires_in: untyped? expires_in, ?compress_threshold: untyped compress_threshold, ?compress: bool compress, ?namespace: untyped? namespace, **untyped redis_options) -> untyped
|
940
|
-
|
941
|
-
def redis: () -> untyped
|
942
|
-
|
943
|
-
def inspect: () -> ::String
|
944
|
-
|
945
|
-
# Cache Store API implementation.
|
860
|
+
# The +:force+ option is useful when you're calling some other method to
|
861
|
+
# ask whether you should force a cache write. Otherwise, it's clearer to
|
862
|
+
# just call <tt>Cache#write</tt>.
|
946
863
|
#
|
947
|
-
#
|
948
|
-
# fetched values.
|
949
|
-
def read_multi: (*untyped names) -> untyped
|
950
|
-
|
951
|
-
# Cache Store API implementation.
|
864
|
+
# Setting <tt>skip_nil: true</tt> will not cache nil result:
|
952
865
|
#
|
953
|
-
#
|
866
|
+
# cache.fetch('foo') { nil }
|
867
|
+
# cache.fetch('bar', skip_nil: true) { nil }
|
868
|
+
# cache.exist?('foo') # => true
|
869
|
+
# cache.exist?('bar') # => false
|
954
870
|
#
|
955
|
-
# h?llo matches hello, hallo and hxllo
|
956
|
-
# h*llo matches hllo and heeeello
|
957
|
-
# h[ae]llo matches hello and hallo, but not hillo
|
958
|
-
# h[^e]llo matches hallo, hbllo, ... but not hello
|
959
|
-
# h[a-b]llo matches hallo and hbllo
|
960
871
|
#
|
961
|
-
#
|
872
|
+
# Setting <tt>compress: false</tt> disables compression of the cache entry.
|
962
873
|
#
|
963
|
-
#
|
874
|
+
# Setting <tt>:expires_in</tt> will set an expiration time on the cache.
|
875
|
+
# All caches support auto-expiring content after a specified number of
|
876
|
+
# seconds. This value can be specified as an option to the constructor
|
877
|
+
# (in which case all entries will be affected), or it can be supplied to
|
878
|
+
# the +fetch+ or +write+ method to effect just one entry.
|
964
879
|
#
|
965
|
-
#
|
966
|
-
|
967
|
-
|
968
|
-
# Cache Store API implementation.
|
880
|
+
# cache = ActiveSupport::Cache::MemoryStore.new(expires_in: 5.minutes)
|
881
|
+
# cache.write(key, value, expires_in: 1.minute) # Set a lower value for one entry
|
969
882
|
#
|
970
|
-
#
|
971
|
-
#
|
972
|
-
#
|
973
|
-
# to zero.
|
883
|
+
# Setting <tt>:version</tt> verifies the cache stored under <tt>name</tt>
|
884
|
+
# is of the same version. nil is returned on mismatches despite contents.
|
885
|
+
# This feature is used to support recyclable cache keys.
|
974
886
|
#
|
975
|
-
#
|
976
|
-
|
977
|
-
|
978
|
-
#
|
887
|
+
# Setting <tt>:race_condition_ttl</tt> is very useful in situations where
|
888
|
+
# a cache entry is used very frequently and is under heavy load. If a
|
889
|
+
# cache expires and due to heavy load several different processes will try
|
890
|
+
# to read data natively and then they all will try to write to cache. To
|
891
|
+
# avoid that case the first process to find an expired cache entry will
|
892
|
+
# bump the cache expiration time by the value set in <tt>:race_condition_ttl</tt>.
|
893
|
+
# Yes, this process is extending the time for a stale value by another few
|
894
|
+
# seconds. Because of extended life of the previous cache, other processes
|
895
|
+
# will continue to use slightly stale data for a just a bit longer. In the
|
896
|
+
# meantime that first process will go ahead and will write into cache the
|
897
|
+
# new value. After that all the processes will start getting the new value.
|
898
|
+
# The key is to keep <tt>:race_condition_ttl</tt> small.
|
979
899
|
#
|
980
|
-
#
|
981
|
-
#
|
982
|
-
#
|
983
|
-
#
|
900
|
+
# If the process regenerating the entry errors out, the entry will be
|
901
|
+
# regenerated after the specified number of seconds. Also note that the
|
902
|
+
# life of stale cache is extended only if it expired recently. Otherwise
|
903
|
+
# a new value is generated and <tt>:race_condition_ttl</tt> does not play
|
904
|
+
# any role.
|
984
905
|
#
|
985
|
-
#
|
986
|
-
|
987
|
-
|
988
|
-
# Cache Store API implementation.
|
906
|
+
# # Set all values to expire after one minute.
|
907
|
+
# cache = ActiveSupport::Cache::MemoryStore.new(expires_in: 1.minute)
|
989
908
|
#
|
990
|
-
#
|
991
|
-
#
|
992
|
-
|
993
|
-
|
994
|
-
# Clear the entire cache on all Redis servers. Safe to use on
|
995
|
-
# shared servers if the cache is namespaced.
|
909
|
+
# cache.write('foo', 'original value')
|
910
|
+
# val_1 = nil
|
911
|
+
# val_2 = nil
|
912
|
+
# sleep 60
|
996
913
|
#
|
997
|
-
#
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
def set_redis_capabilities: () -> untyped
|
1005
|
-
|
1006
|
-
# Store provider interface:
|
1007
|
-
# Read an entry from the cache.
|
1008
|
-
def read_entry: (untyped key, **untyped options) -> untyped
|
1009
|
-
|
1010
|
-
def read_multi_entries: (untyped names, **untyped options) -> untyped
|
1011
|
-
|
1012
|
-
def read_multi_mget: (*untyped names) -> (::Hash[untyped, untyped] | untyped)
|
1013
|
-
|
1014
|
-
# Write an entry to the cache.
|
914
|
+
# Thread.new do
|
915
|
+
# val_1 = cache.fetch('foo', race_condition_ttl: 10.seconds) do
|
916
|
+
# sleep 1
|
917
|
+
# 'new value 1'
|
918
|
+
# end
|
919
|
+
# end
|
1015
920
|
#
|
1016
|
-
#
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
#
|
1022
|
-
|
921
|
+
# Thread.new do
|
922
|
+
# val_2 = cache.fetch('foo', race_condition_ttl: 10.seconds) do
|
923
|
+
# 'new value 2'
|
924
|
+
# end
|
925
|
+
# end
|
926
|
+
#
|
927
|
+
# cache.fetch('foo') # => "original value"
|
928
|
+
# sleep 10 # First thread extended the life of cache by another 10 seconds
|
929
|
+
# cache.fetch('foo') # => "new value 1"
|
930
|
+
# val_1 # => "new value 1"
|
931
|
+
# val_2 # => "original value"
|
932
|
+
#
|
933
|
+
# Other options will be handled by the specific cache store implementation.
|
934
|
+
# Internally, #fetch calls #read_entry, and calls #write_entry on a cache
|
935
|
+
# miss. +options+ will be passed to the #read and #write calls.
|
936
|
+
#
|
937
|
+
# For example, MemCacheStore's #write method supports the +:raw+
|
938
|
+
# option, which tells the memcached server to store all values as strings.
|
939
|
+
# We can use this option with #fetch too:
|
940
|
+
#
|
941
|
+
# cache = ActiveSupport::Cache::MemCacheStore.new
|
942
|
+
# cache.fetch("foo", force: true, raw: true) do
|
943
|
+
# :bar
|
944
|
+
# end
|
945
|
+
# cache.fetch('foo') # => "bar"
|
946
|
+
def fetch: (untyped name, ?untyped? options) { (untyped) -> untyped } -> untyped
|
1023
947
|
|
1024
|
-
#
|
1025
|
-
|
948
|
+
# Reads data from the cache, using the given key. If there is data in
|
949
|
+
# the cache with the given key, then that data is returned. Otherwise,
|
950
|
+
# +nil+ is returned.
|
951
|
+
#
|
952
|
+
# Note, if data was written with the <tt>:expires_in</tt> or
|
953
|
+
# <tt>:version</tt> options, both of these conditions are applied before
|
954
|
+
# the data is returned.
|
955
|
+
#
|
956
|
+
# Options are passed to the underlying cache implementation.
|
957
|
+
def read: (untyped name, ?untyped? options) -> untyped
|
1026
958
|
|
1027
|
-
#
|
1028
|
-
|
959
|
+
# Reads multiple values at once from the cache. Options can be passed
|
960
|
+
# in the last argument.
|
961
|
+
#
|
962
|
+
# Some cache implementation may optimize this method.
|
963
|
+
#
|
964
|
+
# Returns a hash mapping the names provided to the values found.
|
965
|
+
def read_multi: (*untyped names) -> untyped
|
1029
966
|
|
1030
|
-
|
967
|
+
# Cache Storage API to write multiple values at once.
|
968
|
+
def write_multi: (untyped hash, ?untyped? options) -> untyped
|
1031
969
|
|
1032
|
-
|
970
|
+
# Fetches data from the cache, using the given keys. If there is data in
|
971
|
+
# the cache with the given keys, then that data is returned. Otherwise,
|
972
|
+
# the supplied block is called for each key for which there was no data,
|
973
|
+
# and the result will be written to the cache and returned.
|
974
|
+
# Therefore, you need to pass a block that returns the data to be written
|
975
|
+
# to the cache. If you do not want to write the cache when the cache is
|
976
|
+
# not found, use #read_multi.
|
977
|
+
#
|
978
|
+
# Returns a hash with the data for each of the names. For example:
|
979
|
+
#
|
980
|
+
# cache.write("bim", "bam")
|
981
|
+
# cache.fetch_multi("bim", "unknown_key") do |key|
|
982
|
+
# "Fallback value for key: #{key}"
|
983
|
+
# end
|
984
|
+
# # => { "bim" => "bam",
|
985
|
+
# # "unknown_key" => "Fallback value for key: unknown_key" }
|
986
|
+
#
|
987
|
+
# Options are passed to the underlying cache implementation. For example:
|
988
|
+
#
|
989
|
+
# cache.fetch_multi("fizz", expires_in: 5.seconds) do |key|
|
990
|
+
# "buzz"
|
991
|
+
# end
|
992
|
+
# # => {"fizz"=>"buzz"}
|
993
|
+
# cache.read("fizz")
|
994
|
+
# # => "buzz"
|
995
|
+
# sleep(6)
|
996
|
+
# cache.read("fizz")
|
997
|
+
# # => nil
|
998
|
+
def fetch_multi: (*untyped names) { (untyped) -> untyped } -> untyped
|
1033
999
|
|
1034
|
-
|
1000
|
+
# Writes the value to the cache, with the key.
|
1001
|
+
#
|
1002
|
+
# Options are passed to the underlying cache implementation.
|
1003
|
+
def write: (untyped name, untyped value, ?untyped? options) -> untyped
|
1035
1004
|
|
1036
|
-
|
1005
|
+
# Deletes an entry in the cache. Returns +true+ if an entry is deleted.
|
1006
|
+
#
|
1007
|
+
# Options are passed to the underlying cache implementation.
|
1008
|
+
def delete: (untyped name, ?untyped? options) -> untyped
|
1037
1009
|
|
1038
|
-
|
1010
|
+
# Returns +true+ if the cache contains an entry for the given key.
|
1011
|
+
#
|
1012
|
+
# Options are passed to the underlying cache implementation.
|
1013
|
+
def exist?: (untyped name, ?untyped? options) -> untyped
|
1039
1014
|
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1015
|
+
# Deletes all entries with keys matching the pattern.
|
1016
|
+
#
|
1017
|
+
# Options are passed to the underlying cache implementation.
|
1018
|
+
#
|
1019
|
+
# Some implementations may not support this method.
|
1020
|
+
def delete_matched: (untyped matcher, ?untyped? options) -> untyped
|
1044
1021
|
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
# This class wraps up local storage for middlewares. Only the middleware method should
|
1052
|
-
# construct them.
|
1053
|
-
# :nodoc:
|
1054
|
-
attr_reader name: untyped
|
1022
|
+
# Increments an integer value in the cache.
|
1023
|
+
#
|
1024
|
+
# Options are passed to the underlying cache implementation.
|
1025
|
+
#
|
1026
|
+
# Some implementations may not support this method.
|
1027
|
+
def increment: (untyped name, ?::Integer amount, ?untyped? options) -> untyped
|
1055
1028
|
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1029
|
+
# Decrements an integer value in the cache.
|
1030
|
+
#
|
1031
|
+
# Options are passed to the underlying cache implementation.
|
1032
|
+
#
|
1033
|
+
# Some implementations may not support this method.
|
1034
|
+
def decrement: (untyped name, ?::Integer amount, ?untyped? options) -> untyped
|
1061
1035
|
|
1062
|
-
|
1036
|
+
# Cleanups the cache by removing expired entries.
|
1037
|
+
#
|
1038
|
+
# Options are passed to the underlying cache implementation.
|
1039
|
+
#
|
1040
|
+
# Some implementations may not support this method.
|
1041
|
+
def cleanup: (?untyped? options) -> untyped
|
1063
1042
|
|
1064
|
-
|
1043
|
+
# Clears the entire cache. Be careful with this method since it could
|
1044
|
+
# affect other processes if shared cache is being used.
|
1045
|
+
#
|
1046
|
+
# The options hash is passed to the underlying cache implementation.
|
1047
|
+
#
|
1048
|
+
# Some implementations may not support this method.
|
1049
|
+
def clear: (?untyped? options) -> untyped
|
1065
1050
|
|
1066
|
-
|
1067
|
-
end
|
1068
|
-
end
|
1069
|
-
end
|
1070
|
-
end
|
1071
|
-
end
|
1051
|
+
def key_matcher: (untyped pattern, untyped options) -> untyped
|
1072
1052
|
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
# Caches that implement LocalCache will be backed by an in-memory cache for the
|
1077
|
-
# duration of a block. Repeated calls to the cache for the same key will hit the
|
1078
|
-
# in-memory cache for faster access.
|
1079
|
-
module LocalCache
|
1080
|
-
class LocalCacheRegistry
|
1081
|
-
# Class for storing and registering the local caches.
|
1082
|
-
# :nodoc:
|
1083
|
-
extend ActiveSupport::PerThreadRegistry
|
1053
|
+
# Reads an entry from the cache implementation. Subclasses must implement
|
1054
|
+
# this method.
|
1055
|
+
def read_entry: (untyped key, **untyped options) -> untyped
|
1084
1056
|
|
1085
|
-
|
1057
|
+
# Writes an entry to the cache implementation. Subclasses must implement
|
1058
|
+
# this method.
|
1059
|
+
def write_entry: (untyped key, untyped entry, **untyped options) -> untyped
|
1086
1060
|
|
1087
|
-
|
1061
|
+
# Reads multiple entries from the cache implementation. Subclasses MAY
|
1062
|
+
# implement this method.
|
1063
|
+
def read_multi_entries: (untyped names, **untyped options) -> untyped
|
1088
1064
|
|
1089
|
-
|
1065
|
+
# Writes multiple entries to the cache implementation. Subclasses MAY
|
1066
|
+
# implement this method.
|
1067
|
+
def write_multi_entries: (untyped hash, **untyped options) -> untyped
|
1090
1068
|
|
1091
|
-
|
1069
|
+
# Deletes an entry from the cache implementation. Subclasses must
|
1070
|
+
# implement this method.
|
1071
|
+
def delete_entry: (untyped key, **untyped options) -> untyped
|
1092
1072
|
|
1093
|
-
|
1094
|
-
|
1073
|
+
# Merges the default options with ones specific to a method call.
|
1074
|
+
def merged_options: (untyped call_options) -> untyped
|
1095
1075
|
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
def initialize: () -> untyped
|
1076
|
+
# Expands and namespaces the cache key. May be overridden by
|
1077
|
+
# cache stores to do additional normalization.
|
1078
|
+
def normalize_key: (untyped key, ?untyped? options) -> untyped
|
1100
1079
|
|
1101
|
-
|
1080
|
+
# Prefix the key with a namespace string:
|
1081
|
+
#
|
1082
|
+
# namespace_key 'foo', namespace: 'cache'
|
1083
|
+
# # => 'cache:foo'
|
1084
|
+
#
|
1085
|
+
# With a namespace block:
|
1086
|
+
#
|
1087
|
+
# namespace_key 'foo', namespace: -> { 'cache' }
|
1088
|
+
# # => 'cache:foo'
|
1089
|
+
def namespace_key: (untyped key, ?untyped? options) -> untyped
|
1102
1090
|
|
1103
|
-
|
1091
|
+
# Expands key to be a consistent string value. Invokes +cache_key+ if
|
1092
|
+
# object responds to +cache_key+. Otherwise, +to_param+ method will be
|
1093
|
+
# called. If the key is a Hash, then keys will be sorted alphabetically.
|
1094
|
+
def expanded_key: (untyped key) -> untyped
|
1104
1095
|
|
1105
|
-
|
1096
|
+
def normalize_version: (untyped key, ?untyped? options) -> untyped
|
1106
1097
|
|
1107
|
-
|
1098
|
+
def expanded_version: (untyped key) -> untyped
|
1108
1099
|
|
1109
|
-
|
1100
|
+
def instrument: (untyped operation, untyped key, ?untyped? options) { (untyped) -> untyped } -> untyped
|
1110
1101
|
|
1111
|
-
|
1102
|
+
def log: () { () -> untyped } -> (nil | untyped)
|
1112
1103
|
|
1113
|
-
|
1114
|
-
end
|
1104
|
+
def handle_expired_entry: (untyped entry, untyped key, untyped options) -> untyped
|
1115
1105
|
|
1116
|
-
|
1117
|
-
def with_local_cache: () { () -> untyped } -> untyped
|
1106
|
+
def get_entry_value: (untyped entry, untyped name, untyped options) -> untyped
|
1118
1107
|
|
1119
|
-
|
1120
|
-
|
1121
|
-
def middleware: () -> untyped
|
1108
|
+
def save_block_result_to_cache: (untyped name, **untyped options) { (untyped) -> untyped } -> untyped
|
1109
|
+
end
|
1122
1110
|
|
1123
|
-
|
1111
|
+
class Entry
|
1112
|
+
# This class is used to represent cache entries. Cache entries have a value, an optional
|
1113
|
+
# expiration time, and an optional version. The expiration time is used to support the :race_condition_ttl option
|
1114
|
+
# on the cache. The version is used to support the :version option on the cache for rejecting
|
1115
|
+
# mismatches.
|
1116
|
+
#
|
1117
|
+
# Since cache entries in most instances will be serialized, the internals of this class are highly optimized
|
1118
|
+
# using short instance variable names that are lazily defined.
|
1119
|
+
# :nodoc:
|
1120
|
+
attr_reader version: untyped
|
1124
1121
|
|
1125
|
-
|
1122
|
+
DEFAULT_COMPRESS_LIMIT: untyped
|
1126
1123
|
|
1127
|
-
|
1124
|
+
# Creates a new cache entry for the specified value. Options supported are
|
1125
|
+
# +:compress+, +:compress_threshold+, +:version+ and +:expires_in+.
|
1126
|
+
def initialize: (untyped value, ?compress: bool compress, ?compress_threshold: untyped compress_threshold, ?version: untyped? version, ?expires_in: untyped? expires_in) -> untyped
|
1128
1127
|
|
1129
|
-
|
1128
|
+
def value: () -> untyped
|
1130
1129
|
|
1131
|
-
|
1130
|
+
def mismatched?: (untyped version) -> untyped
|
1132
1131
|
|
1133
|
-
|
1132
|
+
# Checks if the entry is expired. The +expires_in+ parameter can override
|
1133
|
+
# the value set when the entry was created.
|
1134
|
+
def expired?: () -> untyped
|
1134
1135
|
|
1135
|
-
|
1136
|
+
def expires_at: () -> untyped
|
1136
1137
|
|
1137
|
-
|
1138
|
+
def expires_at=: (untyped value) -> untyped
|
1138
1139
|
|
1139
|
-
|
1140
|
+
# Returns the size of the cached value. This could be less than
|
1141
|
+
# <tt>value.size</tt> if the data is compressed.
|
1142
|
+
def size: () -> untyped
|
1140
1143
|
|
1141
|
-
|
1144
|
+
# Duplicates the value in a class. This is used by cache implementations that don't natively
|
1145
|
+
# serialize entries to protect against accidental cache modifications.
|
1146
|
+
def dup_value!: () -> untyped
|
1142
1147
|
|
1143
|
-
|
1148
|
+
def compress!: (untyped compress_threshold) -> untyped
|
1144
1149
|
|
1145
|
-
|
1150
|
+
def compressed?: () -> untyped
|
1146
1151
|
|
1147
|
-
|
1148
|
-
end
|
1152
|
+
def uncompress: (untyped value) -> untyped
|
1149
1153
|
end
|
1150
1154
|
end
|
1151
1155
|
end
|
@@ -1248,7 +1252,7 @@ module ActiveSupport
|
|
1248
1252
|
end
|
1249
1253
|
|
1250
1254
|
module Filters
|
1251
|
-
class Environment < ::Struct[
|
1255
|
+
class Environment[T] < ::Struct[T]
|
1252
1256
|
attr_accessor target(): untyped
|
1253
1257
|
|
1254
1258
|
attr_accessor halted(): untyped
|
@@ -1293,7 +1297,7 @@ module ActiveSupport
|
|
1293
1297
|
|
1294
1298
|
def raw_filter: () -> untyped
|
1295
1299
|
|
1296
|
-
def merge_conditional_options: (untyped chain,
|
1300
|
+
def merge_conditional_options: (untyped chain, if_option: untyped if_option, unless_option: untyped unless_option) -> untyped
|
1297
1301
|
|
1298
1302
|
def matches?: (untyped _kind, untyped _filter) -> untyped
|
1299
1303
|
|
@@ -1752,7 +1756,7 @@ module ActiveSupport
|
|
1752
1756
|
# is awaiting a lock, it is not running any other code. With
|
1753
1757
|
# +purpose+ matching, it is possible to yield only to other
|
1754
1758
|
# threads whose activity will not interfere.
|
1755
|
-
def start_exclusive: (?
|
1759
|
+
def start_exclusive: (?purpose: untyped? purpose, ?compatible: untyped compatible, ?no_wait: bool no_wait) -> untyped
|
1756
1760
|
|
1757
1761
|
# Relinquish the exclusive lock. Must only be called by the thread
|
1758
1762
|
# that called start_exclusive (and currently holds the lock).
|
@@ -1768,7 +1772,7 @@ module ActiveSupport
|
|
1768
1772
|
# the block.
|
1769
1773
|
#
|
1770
1774
|
# See +start_exclusive+ for other options.
|
1771
|
-
def exclusive: (?
|
1775
|
+
def exclusive: (?purpose: untyped? purpose, ?compatible: untyped compatible, ?after_compatible: untyped after_compatible, ?no_wait: bool no_wait) { () -> untyped } -> untyped
|
1772
1776
|
|
1773
1777
|
# Execute the supplied block while holding the Share lock.
|
1774
1778
|
def sharing: () { () -> untyped } -> untyped
|
@@ -1776,7 +1780,7 @@ module ActiveSupport
|
|
1776
1780
|
# Temporarily give up all held Share locks while executing the
|
1777
1781
|
# supplied block, allowing any +compatible+ exclusive lock request
|
1778
1782
|
# to proceed.
|
1779
|
-
def yield_shares: (?
|
1783
|
+
def yield_shares: (?purpose: untyped? purpose, ?compatible: untyped compatible, ?block_share: bool block_share) { () -> untyped } -> untyped
|
1780
1784
|
|
1781
1785
|
# Must be called within synchronize
|
1782
1786
|
def busy_for_exclusive?: (untyped purpose) -> untyped
|
@@ -1808,7 +1812,7 @@ module ActiveSupport
|
|
1808
1812
|
|
1809
1813
|
def configure: () { (untyped) -> untyped } -> untyped
|
1810
1814
|
|
1811
|
-
def config_accessor: (*untyped names, ?
|
1815
|
+
def config_accessor: (*untyped names, ?instance_reader: bool instance_reader, ?instance_writer: bool instance_writer, ?instance_accessor: bool instance_accessor) { () -> untyped } -> untyped
|
1812
1816
|
end
|
1813
1817
|
|
1814
1818
|
# Reads and writes attributes from a configuration <tt>OrderedHash</tt>.
|
@@ -1967,6 +1971,8 @@ class Array[unchecked out Elem]
|
|
1967
1971
|
# [1,2].to_formatted_s # => "[1, 2]"
|
1968
1972
|
def to_formatted_s: (?::Symbol format) -> untyped
|
1969
1973
|
|
1974
|
+
alias to_default_s to_s
|
1975
|
+
|
1970
1976
|
# Returns a string that represents the array in XML by invoking +to_xml+
|
1971
1977
|
# on each element. Active Record collections delegate their representation
|
1972
1978
|
# in XML to this method.
|
@@ -2045,6 +2051,16 @@ class Array[unchecked out Elem]
|
|
2045
2051
|
def to_xml: (?::Hash[untyped, untyped] options) { (untyped) -> untyped } -> untyped
|
2046
2052
|
end
|
2047
2053
|
|
2054
|
+
class Array[unchecked out Elem]
|
2055
|
+
# Removes and returns the elements for which the block returns a true value.
|
2056
|
+
# If no block is given, an Enumerator is returned instead.
|
2057
|
+
#
|
2058
|
+
# numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
2059
|
+
# odd_numbers = numbers.extract! { |number| number.odd? } # => [1, 3, 5, 7, 9]
|
2060
|
+
# numbers # => [0, 2, 4, 6, 8]
|
2061
|
+
def extract!: () { (untyped) -> untyped } -> untyped
|
2062
|
+
end
|
2063
|
+
|
2048
2064
|
class Hash[unchecked out K, unchecked out V]
|
2049
2065
|
# By default, only instances of Hash itself are extractable.
|
2050
2066
|
# Subclasses of Hash may implement this method and return
|
@@ -2067,16 +2083,6 @@ class Array[unchecked out Elem]
|
|
2067
2083
|
def extract_options!: () -> untyped
|
2068
2084
|
end
|
2069
2085
|
|
2070
|
-
class Array[unchecked out Elem]
|
2071
|
-
# Removes and returns the elements for which the block returns a true value.
|
2072
|
-
# If no block is given, an Enumerator is returned instead.
|
2073
|
-
#
|
2074
|
-
# numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
2075
|
-
# odd_numbers = numbers.extract! { |number| number.odd? } # => [1, 3, 5, 7, 9]
|
2076
|
-
# numbers # => [0, 2, 4, 6, 8]
|
2077
|
-
def extract!: () { (untyped) -> untyped } -> untyped
|
2078
|
-
end
|
2079
|
-
|
2080
2086
|
class Array[unchecked out Elem]
|
2081
2087
|
# Splits or iterates over the array in groups of size +number+,
|
2082
2088
|
# padding any remaining slots with +fill_with+ unless it is +false+.
|
@@ -2136,7 +2142,7 @@ class Array[unchecked out Elem]
|
|
2136
2142
|
#
|
2137
2143
|
# pets.any?(:cat, :ferret) # => true
|
2138
2144
|
# pets.any?(:ferret, :alligator) # => false
|
2139
|
-
def inquiry: () ->
|
2145
|
+
def inquiry: () -> ActiveSupport::ArrayInquirer[Elem]
|
2140
2146
|
end
|
2141
2147
|
|
2142
2148
|
class Array[unchecked out Elem]
|
@@ -2251,52 +2257,212 @@ class Class
|
|
2251
2257
|
# object.setting # => false
|
2252
2258
|
# Base.setting # => true
|
2253
2259
|
#
|
2254
|
-
# To opt out of the instance reader method, pass <tt>instance_reader: false</tt>.
|
2260
|
+
# To opt out of the instance reader method, pass <tt>instance_reader: false</tt>.
|
2261
|
+
#
|
2262
|
+
# object.setting # => NoMethodError
|
2263
|
+
# object.setting? # => NoMethodError
|
2264
|
+
#
|
2265
|
+
# To opt out of the instance writer method, pass <tt>instance_writer: false</tt>.
|
2266
|
+
#
|
2267
|
+
# object.setting = false # => NoMethodError
|
2268
|
+
#
|
2269
|
+
# To opt out of both instance methods, pass <tt>instance_accessor: false</tt>.
|
2270
|
+
#
|
2271
|
+
# To set a default value for the attribute, pass <tt>default:</tt>, like so:
|
2272
|
+
#
|
2273
|
+
# class_attribute :settings, default: {}
|
2274
|
+
def class_attribute: (*untyped attrs, ?instance_accessor: bool instance_accessor, ?instance_reader: untyped instance_reader, ?instance_writer: untyped instance_writer, ?instance_predicate: bool instance_predicate, ?default: untyped? default) -> untyped
|
2275
|
+
end
|
2276
|
+
|
2277
|
+
class Class
|
2278
|
+
# Returns an array with all classes that are < than its receiver.
|
2279
|
+
#
|
2280
|
+
# class C; end
|
2281
|
+
# C.descendants # => []
|
2282
|
+
#
|
2283
|
+
# class B < C; end
|
2284
|
+
# C.descendants # => [B]
|
2285
|
+
#
|
2286
|
+
# class A < B; end
|
2287
|
+
# C.descendants # => [B, A]
|
2288
|
+
#
|
2289
|
+
# class D < C; end
|
2290
|
+
# C.descendants # => [B, A, D]
|
2291
|
+
def descendants: () -> untyped
|
2292
|
+
|
2293
|
+
# Returns an array with the direct children of +self+.
|
2294
|
+
#
|
2295
|
+
# class Foo; end
|
2296
|
+
# class Bar < Foo; end
|
2297
|
+
# class Baz < Bar; end
|
2298
|
+
#
|
2299
|
+
# Foo.subclasses # => [Bar]
|
2300
|
+
def subclasses: () -> untyped
|
2301
|
+
end
|
2302
|
+
|
2303
|
+
class Date
|
2304
|
+
# Duck-types as a Date-like class. See Object#acts_like?.
|
2305
|
+
def acts_like_date?: () -> ::TrueClass
|
2306
|
+
end
|
2307
|
+
|
2308
|
+
class Date
|
2309
|
+
# nodoc:
|
2310
|
+
# No Date is blank:
|
2311
|
+
#
|
2312
|
+
# Date.today.blank? # => false
|
2313
|
+
#
|
2314
|
+
# @return [false]
|
2315
|
+
def blank?: () -> ::FalseClass
|
2316
|
+
end
|
2317
|
+
|
2318
|
+
class Date
|
2319
|
+
include DateAndTime::Calculations
|
2320
|
+
|
2321
|
+
attr_accessor beginning_of_week_default: untyped
|
2322
|
+
|
2323
|
+
# Returns the week start (e.g. :monday) for the current request, if this has been set (via Date.beginning_of_week=).
|
2324
|
+
# If <tt>Date.beginning_of_week</tt> has not been set for the current request, returns the week start specified in <tt>config.beginning_of_week</tt>.
|
2325
|
+
# If no config.beginning_of_week was specified, returns :monday.
|
2326
|
+
def self.beginning_of_week: () -> untyped
|
2327
|
+
|
2328
|
+
# Sets <tt>Date.beginning_of_week</tt> to a week start (e.g. :monday) for current request/thread.
|
2329
|
+
#
|
2330
|
+
# This method accepts any of the following day symbols:
|
2331
|
+
# :monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday
|
2332
|
+
def self.beginning_of_week=: (untyped week_start) -> untyped
|
2333
|
+
|
2334
|
+
# Returns week start day symbol (e.g. :monday), or raises an +ArgumentError+ for invalid day symbol.
|
2335
|
+
def self.find_beginning_of_week!: (untyped week_start) -> untyped
|
2336
|
+
|
2337
|
+
# Returns a new Date representing the date 1 day ago (i.e. yesterday's date).
|
2338
|
+
def self.yesterday: () -> untyped
|
2339
|
+
|
2340
|
+
# Returns a new Date representing the date 1 day after today (i.e. tomorrow's date).
|
2341
|
+
def self.tomorrow: () -> untyped
|
2342
|
+
|
2343
|
+
# Returns Time.zone.today when <tt>Time.zone</tt> or <tt>config.time_zone</tt> are set, otherwise just returns Date.today.
|
2344
|
+
def self.current: () -> untyped
|
2345
|
+
|
2346
|
+
# Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00)
|
2347
|
+
# and then subtracts the specified number of seconds.
|
2348
|
+
def ago: (untyped seconds) -> untyped
|
2349
|
+
|
2350
|
+
# Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00)
|
2351
|
+
# and then adds the specified number of seconds
|
2352
|
+
def since: (untyped seconds) -> untyped
|
2353
|
+
|
2354
|
+
alias in since
|
2355
|
+
|
2356
|
+
# Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00)
|
2357
|
+
def beginning_of_day: () -> untyped
|
2358
|
+
|
2359
|
+
alias midnight beginning_of_day
|
2360
|
+
|
2361
|
+
alias at_midnight beginning_of_day
|
2362
|
+
|
2363
|
+
alias at_beginning_of_day beginning_of_day
|
2364
|
+
|
2365
|
+
# Converts Date to a Time (or DateTime if necessary) with the time portion set to the middle of the day (12:00)
|
2366
|
+
def middle_of_day: () -> untyped
|
2367
|
+
|
2368
|
+
alias midday middle_of_day
|
2369
|
+
|
2370
|
+
alias noon middle_of_day
|
2371
|
+
|
2372
|
+
alias at_midday middle_of_day
|
2373
|
+
|
2374
|
+
alias at_noon middle_of_day
|
2375
|
+
|
2376
|
+
alias at_middle_of_day middle_of_day
|
2377
|
+
|
2378
|
+
# Converts Date to a Time (or DateTime if necessary) with the time portion set to the end of the day (23:59:59)
|
2379
|
+
def end_of_day: () -> untyped
|
2380
|
+
|
2381
|
+
alias at_end_of_day end_of_day
|
2382
|
+
|
2383
|
+
def plus_with_duration: (untyped other) -> untyped
|
2384
|
+
|
2385
|
+
alias plus_without_duration +
|
2386
|
+
|
2387
|
+
def minus_with_duration: (untyped other) -> untyped
|
2388
|
+
|
2389
|
+
alias minus_without_duration -
|
2390
|
+
|
2391
|
+
# Provides precise Date calculations for years, months, and days. The +options+ parameter takes a hash with
|
2392
|
+
# any of these keys: <tt>:years</tt>, <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>.
|
2393
|
+
def advance: (untyped options) -> untyped
|
2394
|
+
|
2395
|
+
# Returns a new Date where one or more of the elements have been changed according to the +options+ parameter.
|
2396
|
+
# The +options+ parameter is a hash with a combination of these keys: <tt>:year</tt>, <tt>:month</tt>, <tt>:day</tt>.
|
2397
|
+
#
|
2398
|
+
# Date.new(2007, 5, 12).change(day: 1) # => Date.new(2007, 5, 1)
|
2399
|
+
# Date.new(2007, 5, 12).change(year: 2005, month: 1) # => Date.new(2005, 1, 12)
|
2400
|
+
def change: (untyped options) -> untyped
|
2401
|
+
|
2402
|
+
# Allow Date to be compared with Time by converting to DateTime and relying on the <=> from there.
|
2403
|
+
def compare_with_coercion: (untyped other) -> untyped
|
2404
|
+
|
2405
|
+
alias compare_without_coercion <=>
|
2406
|
+
end
|
2407
|
+
|
2408
|
+
class Date
|
2409
|
+
DATE_FORMATS: ::Hash[untyped, untyped]
|
2410
|
+
|
2411
|
+
# Convert to a formatted string. See DATE_FORMATS for predefined formats.
|
2255
2412
|
#
|
2256
|
-
#
|
2257
|
-
# object.setting? # => NoMethodError
|
2413
|
+
# This method is aliased to <tt>to_s</tt>.
|
2258
2414
|
#
|
2259
|
-
#
|
2415
|
+
# date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
|
2260
2416
|
#
|
2261
|
-
#
|
2417
|
+
# date.to_formatted_s(:db) # => "2007-11-10"
|
2418
|
+
# date.to_s(:db) # => "2007-11-10"
|
2262
2419
|
#
|
2263
|
-
#
|
2420
|
+
# date.to_formatted_s(:short) # => "10 Nov"
|
2421
|
+
# date.to_formatted_s(:number) # => "20071110"
|
2422
|
+
# date.to_formatted_s(:long) # => "November 10, 2007"
|
2423
|
+
# date.to_formatted_s(:long_ordinal) # => "November 10th, 2007"
|
2424
|
+
# date.to_formatted_s(:rfc822) # => "10 Nov 2007"
|
2425
|
+
# date.to_formatted_s(:iso8601) # => "2007-11-10"
|
2264
2426
|
#
|
2265
|
-
#
|
2427
|
+
# == Adding your own date formats to to_formatted_s
|
2428
|
+
# You can add your own formats to the Date::DATE_FORMATS hash.
|
2429
|
+
# Use the format name as the hash key and either a strftime string
|
2430
|
+
# or Proc instance that takes a date argument as the value.
|
2266
2431
|
#
|
2267
|
-
#
|
2268
|
-
|
2269
|
-
|
2432
|
+
# # config/initializers/date_formats.rb
|
2433
|
+
# Date::DATE_FORMATS[:month_and_year] = '%B %Y'
|
2434
|
+
# Date::DATE_FORMATS[:short_ordinal] = ->(date) { date.strftime("%B #{date.day.ordinalize}") }
|
2435
|
+
def to_formatted_s: (?::Symbol format) -> untyped
|
2270
2436
|
|
2271
|
-
|
2272
|
-
|
2437
|
+
alias to_default_s to_s
|
2438
|
+
|
2439
|
+
# Overrides the default inspect method with a human readable one, e.g., "Mon, 21 Feb 2005"
|
2440
|
+
def readable_inspect: () -> untyped
|
2441
|
+
|
2442
|
+
# Converts a Date instance to a Time, where the time is set to the beginning of the day.
|
2443
|
+
# The timezone can be either :local or :utc (default :local).
|
2273
2444
|
#
|
2274
|
-
#
|
2275
|
-
# C.descendants # => []
|
2445
|
+
# date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
|
2276
2446
|
#
|
2277
|
-
#
|
2278
|
-
#
|
2447
|
+
# date.to_time # => 2007-11-10 00:00:00 0800
|
2448
|
+
# date.to_time(:local) # => 2007-11-10 00:00:00 0800
|
2279
2449
|
#
|
2280
|
-
#
|
2281
|
-
# C.descendants # => [B, A]
|
2450
|
+
# date.to_time(:utc) # => 2007-11-10 00:00:00 UTC
|
2282
2451
|
#
|
2283
|
-
#
|
2284
|
-
#
|
2285
|
-
def
|
2452
|
+
# NOTE: The :local timezone is Ruby's *process* timezone, i.e. ENV['TZ'].
|
2453
|
+
# If the *application's* timezone is needed, then use +in_time_zone+ instead.
|
2454
|
+
def to_time: (?::Symbol form) -> untyped
|
2286
2455
|
|
2287
|
-
# Returns
|
2288
|
-
#
|
2289
|
-
# class Foo; end
|
2290
|
-
# class Bar < Foo; end
|
2291
|
-
# class Baz < Bar; end
|
2456
|
+
# Returns a string which represents the time in used time zone as DateTime
|
2457
|
+
# defined by XML Schema:
|
2292
2458
|
#
|
2293
|
-
#
|
2294
|
-
|
2459
|
+
# date = Date.new(2015, 05, 23) # => Sat, 23 May 2015
|
2460
|
+
# date.xmlschema # => "2015-05-23T00:00:00+04:00"
|
2461
|
+
def xmlschema: () -> untyped
|
2295
2462
|
end
|
2296
2463
|
|
2297
2464
|
class Date
|
2298
|
-
|
2299
|
-
def acts_like_date?: () -> ::TrueClass
|
2465
|
+
include DateAndTime::Zones
|
2300
2466
|
end
|
2301
2467
|
|
2302
2468
|
module DateAndTime
|
@@ -2367,6 +2533,8 @@ module DateAndTime
|
|
2367
2533
|
# now.beginning_of_month # => Mon, 01 Jun 2015 00:00:00 +0000
|
2368
2534
|
def beginning_of_month: () -> untyped
|
2369
2535
|
|
2536
|
+
alias at_beginning_of_month beginning_of_month
|
2537
|
+
|
2370
2538
|
# Returns a new date/time at the start of the quarter.
|
2371
2539
|
#
|
2372
2540
|
# today = Date.today # => Fri, 10 Jul 2015
|
@@ -2378,6 +2546,8 @@ module DateAndTime
|
|
2378
2546
|
# now.beginning_of_quarter # => Wed, 01 Jul 2015 00:00:00 +0000
|
2379
2547
|
def beginning_of_quarter: () -> untyped
|
2380
2548
|
|
2549
|
+
alias at_beginning_of_quarter beginning_of_quarter
|
2550
|
+
|
2381
2551
|
# Returns a new date/time at the end of the quarter.
|
2382
2552
|
#
|
2383
2553
|
# today = Date.today # => Fri, 10 Jul 2015
|
@@ -2389,6 +2559,8 @@ module DateAndTime
|
|
2389
2559
|
# now.end_of_quarter # => Wed, 30 Sep 2015 23:59:59 +0000
|
2390
2560
|
def end_of_quarter: () -> untyped
|
2391
2561
|
|
2562
|
+
alias at_end_of_quarter end_of_quarter
|
2563
|
+
|
2392
2564
|
# Returns a new date/time at the beginning of the year.
|
2393
2565
|
#
|
2394
2566
|
# today = Date.today # => Fri, 10 Jul 2015
|
@@ -2400,6 +2572,8 @@ module DateAndTime
|
|
2400
2572
|
# now.beginning_of_year # => Thu, 01 Jan 2015 00:00:00 +0000
|
2401
2573
|
def beginning_of_year: () -> untyped
|
2402
2574
|
|
2575
|
+
alias at_beginning_of_year beginning_of_year
|
2576
|
+
|
2403
2577
|
# Returns a new date/time representing the given day in the next week.
|
2404
2578
|
#
|
2405
2579
|
# today = Date.today # => Thu, 07 May 2015
|
@@ -2430,15 +2604,21 @@ module DateAndTime
|
|
2430
2604
|
# DateTime objects have their time set to 0:00 unless +same_time+ is true.
|
2431
2605
|
def prev_week: (?untyped start_day, ?same_time: bool same_time) -> untyped
|
2432
2606
|
|
2607
|
+
alias last_week prev_week
|
2608
|
+
|
2433
2609
|
# Returns a new date/time representing the previous weekday.
|
2434
2610
|
def prev_weekday: () -> untyped
|
2435
2611
|
|
2612
|
+
alias last_weekday prev_weekday
|
2613
|
+
|
2436
2614
|
# Short-hand for months_ago(1).
|
2437
2615
|
def last_month: () -> untyped
|
2438
2616
|
|
2439
2617
|
# Short-hand for months_ago(3).
|
2440
2618
|
def prev_quarter: () -> untyped
|
2441
2619
|
|
2620
|
+
alias last_quarter prev_quarter
|
2621
|
+
|
2442
2622
|
# Short-hand for years_ago(1).
|
2443
2623
|
def last_year: () -> untyped
|
2444
2624
|
|
@@ -2453,6 +2633,8 @@ module DateAndTime
|
|
2453
2633
|
# +DateTime+ objects have their time set to 0:00.
|
2454
2634
|
def beginning_of_week: (?untyped start_day) -> untyped
|
2455
2635
|
|
2636
|
+
alias at_beginning_of_week beginning_of_week
|
2637
|
+
|
2456
2638
|
# Returns Monday of this week assuming that week starts on Monday.
|
2457
2639
|
# +DateTime+ objects have their time set to 0:00.
|
2458
2640
|
def monday: () -> untyped
|
@@ -2463,6 +2645,8 @@ module DateAndTime
|
|
2463
2645
|
# DateTime objects have their time set to 23:59:59.
|
2464
2646
|
def end_of_week: (?untyped start_day) -> untyped
|
2465
2647
|
|
2648
|
+
alias at_end_of_week end_of_week
|
2649
|
+
|
2466
2650
|
# Returns Sunday of this week assuming that week starts on Monday.
|
2467
2651
|
# +DateTime+ objects have their time set to 23:59:59.
|
2468
2652
|
def sunday: () -> untyped
|
@@ -2471,10 +2655,14 @@ module DateAndTime
|
|
2471
2655
|
# DateTime objects will have a time set to 23:59:59.
|
2472
2656
|
def end_of_month: () -> untyped
|
2473
2657
|
|
2658
|
+
alias at_end_of_month end_of_month
|
2659
|
+
|
2474
2660
|
# Returns a new date/time representing the end of the year.
|
2475
2661
|
# DateTime objects will have a time set to 23:59:59.
|
2476
2662
|
def end_of_year: () -> untyped
|
2477
2663
|
|
2664
|
+
alias at_end_of_year end_of_year
|
2665
|
+
|
2478
2666
|
# Returns a Range representing the whole day of the current date/time.
|
2479
2667
|
def all_day: () -> ::Range[untyped]
|
2480
2668
|
|
@@ -2543,134 +2731,6 @@ module DateAndTime
|
|
2543
2731
|
end
|
2544
2732
|
end
|
2545
2733
|
|
2546
|
-
class Date
|
2547
|
-
# nodoc:
|
2548
|
-
# No Date is blank:
|
2549
|
-
#
|
2550
|
-
# Date.today.blank? # => false
|
2551
|
-
#
|
2552
|
-
# @return [false]
|
2553
|
-
def blank?: () -> ::FalseClass
|
2554
|
-
end
|
2555
|
-
|
2556
|
-
class Date
|
2557
|
-
include DateAndTime::Calculations
|
2558
|
-
|
2559
|
-
attr_accessor beginning_of_week_default: untyped
|
2560
|
-
|
2561
|
-
# Returns the week start (e.g. :monday) for the current request, if this has been set (via Date.beginning_of_week=).
|
2562
|
-
# If <tt>Date.beginning_of_week</tt> has not been set for the current request, returns the week start specified in <tt>config.beginning_of_week</tt>.
|
2563
|
-
# If no config.beginning_of_week was specified, returns :monday.
|
2564
|
-
def self.beginning_of_week: () -> untyped
|
2565
|
-
|
2566
|
-
# Sets <tt>Date.beginning_of_week</tt> to a week start (e.g. :monday) for current request/thread.
|
2567
|
-
#
|
2568
|
-
# This method accepts any of the following day symbols:
|
2569
|
-
# :monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday
|
2570
|
-
def self.beginning_of_week=: (untyped week_start) -> untyped
|
2571
|
-
|
2572
|
-
# Returns week start day symbol (e.g. :monday), or raises an +ArgumentError+ for invalid day symbol.
|
2573
|
-
def self.find_beginning_of_week!: (untyped week_start) -> untyped
|
2574
|
-
|
2575
|
-
# Returns a new Date representing the date 1 day ago (i.e. yesterday's date).
|
2576
|
-
def self.yesterday: () -> untyped
|
2577
|
-
|
2578
|
-
# Returns a new Date representing the date 1 day after today (i.e. tomorrow's date).
|
2579
|
-
def self.tomorrow: () -> untyped
|
2580
|
-
|
2581
|
-
# Returns Time.zone.today when <tt>Time.zone</tt> or <tt>config.time_zone</tt> are set, otherwise just returns Date.today.
|
2582
|
-
def self.current: () -> untyped
|
2583
|
-
|
2584
|
-
# Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00)
|
2585
|
-
# and then subtracts the specified number of seconds.
|
2586
|
-
def ago: (untyped seconds) -> untyped
|
2587
|
-
|
2588
|
-
# Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00)
|
2589
|
-
# and then adds the specified number of seconds
|
2590
|
-
def since: (untyped seconds) -> untyped
|
2591
|
-
|
2592
|
-
# Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00)
|
2593
|
-
def beginning_of_day: () -> untyped
|
2594
|
-
|
2595
|
-
# Converts Date to a Time (or DateTime if necessary) with the time portion set to the middle of the day (12:00)
|
2596
|
-
def middle_of_day: () -> untyped
|
2597
|
-
|
2598
|
-
# Converts Date to a Time (or DateTime if necessary) with the time portion set to the end of the day (23:59:59)
|
2599
|
-
def end_of_day: () -> untyped
|
2600
|
-
|
2601
|
-
def plus_with_duration: (untyped other) -> untyped
|
2602
|
-
|
2603
|
-
def minus_with_duration: (untyped other) -> untyped
|
2604
|
-
|
2605
|
-
# Provides precise Date calculations for years, months, and days. The +options+ parameter takes a hash with
|
2606
|
-
# any of these keys: <tt>:years</tt>, <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>.
|
2607
|
-
def advance: (untyped options) -> untyped
|
2608
|
-
|
2609
|
-
# Returns a new Date where one or more of the elements have been changed according to the +options+ parameter.
|
2610
|
-
# The +options+ parameter is a hash with a combination of these keys: <tt>:year</tt>, <tt>:month</tt>, <tt>:day</tt>.
|
2611
|
-
#
|
2612
|
-
# Date.new(2007, 5, 12).change(day: 1) # => Date.new(2007, 5, 1)
|
2613
|
-
# Date.new(2007, 5, 12).change(year: 2005, month: 1) # => Date.new(2005, 1, 12)
|
2614
|
-
def change: (untyped options) -> untyped
|
2615
|
-
|
2616
|
-
# Allow Date to be compared with Time by converting to DateTime and relying on the <=> from there.
|
2617
|
-
def compare_with_coercion: (untyped other) -> untyped
|
2618
|
-
end
|
2619
|
-
|
2620
|
-
class Date
|
2621
|
-
DATE_FORMATS: ::Hash[untyped, untyped]
|
2622
|
-
|
2623
|
-
# Convert to a formatted string. See DATE_FORMATS for predefined formats.
|
2624
|
-
#
|
2625
|
-
# This method is aliased to <tt>to_s</tt>.
|
2626
|
-
#
|
2627
|
-
# date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
|
2628
|
-
#
|
2629
|
-
# date.to_formatted_s(:db) # => "2007-11-10"
|
2630
|
-
# date.to_s(:db) # => "2007-11-10"
|
2631
|
-
#
|
2632
|
-
# date.to_formatted_s(:short) # => "10 Nov"
|
2633
|
-
# date.to_formatted_s(:number) # => "20071110"
|
2634
|
-
# date.to_formatted_s(:long) # => "November 10, 2007"
|
2635
|
-
# date.to_formatted_s(:long_ordinal) # => "November 10th, 2007"
|
2636
|
-
# date.to_formatted_s(:rfc822) # => "10 Nov 2007"
|
2637
|
-
# date.to_formatted_s(:iso8601) # => "2007-11-10"
|
2638
|
-
#
|
2639
|
-
# == Adding your own date formats to to_formatted_s
|
2640
|
-
# You can add your own formats to the Date::DATE_FORMATS hash.
|
2641
|
-
# Use the format name as the hash key and either a strftime string
|
2642
|
-
# or Proc instance that takes a date argument as the value.
|
2643
|
-
#
|
2644
|
-
# # config/initializers/date_formats.rb
|
2645
|
-
# Date::DATE_FORMATS[:month_and_year] = '%B %Y'
|
2646
|
-
# Date::DATE_FORMATS[:short_ordinal] = ->(date) { date.strftime("%B #{date.day.ordinalize}") }
|
2647
|
-
def to_formatted_s: (?::Symbol format) -> untyped
|
2648
|
-
|
2649
|
-
# Overrides the default inspect method with a human readable one, e.g., "Mon, 21 Feb 2005"
|
2650
|
-
def readable_inspect: () -> untyped
|
2651
|
-
|
2652
|
-
# Converts a Date instance to a Time, where the time is set to the beginning of the day.
|
2653
|
-
# The timezone can be either :local or :utc (default :local).
|
2654
|
-
#
|
2655
|
-
# date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
|
2656
|
-
#
|
2657
|
-
# date.to_time # => 2007-11-10 00:00:00 0800
|
2658
|
-
# date.to_time(:local) # => 2007-11-10 00:00:00 0800
|
2659
|
-
#
|
2660
|
-
# date.to_time(:utc) # => 2007-11-10 00:00:00 UTC
|
2661
|
-
#
|
2662
|
-
# NOTE: The :local timezone is Ruby's *process* timezone, i.e. ENV['TZ'].
|
2663
|
-
# If the *application's* timezone is needed, then use +in_time_zone+ instead.
|
2664
|
-
def to_time: (?::Symbol form) -> untyped
|
2665
|
-
|
2666
|
-
# Returns a string which represents the time in used time zone as DateTime
|
2667
|
-
# defined by XML Schema:
|
2668
|
-
#
|
2669
|
-
# date = Date.new(2015, 05, 23) # => Sat, 23 May 2015
|
2670
|
-
# date.xmlschema # => "2015-05-23T00:00:00+04:00"
|
2671
|
-
def xmlschema: () -> untyped
|
2672
|
-
end
|
2673
|
-
|
2674
2734
|
class DateTime
|
2675
2735
|
# Duck-types as a Date-like class. See Object#acts_like?.
|
2676
2736
|
def acts_like_date?: () -> ::TrueClass
|
@@ -2742,36 +2802,72 @@ class DateTime
|
|
2742
2802
|
# months_since instead!
|
2743
2803
|
def since: (untyped seconds) -> untyped
|
2744
2804
|
|
2805
|
+
alias in since
|
2806
|
+
|
2745
2807
|
# Returns a new DateTime representing the start of the day (0:00).
|
2746
2808
|
def beginning_of_day: () -> untyped
|
2747
2809
|
|
2810
|
+
alias midnight beginning_of_day
|
2811
|
+
|
2812
|
+
alias at_midnight beginning_of_day
|
2813
|
+
|
2814
|
+
alias at_beginning_of_day beginning_of_day
|
2815
|
+
|
2748
2816
|
# Returns a new DateTime representing the middle of the day (12:00)
|
2749
2817
|
def middle_of_day: () -> untyped
|
2750
2818
|
|
2819
|
+
alias midday middle_of_day
|
2820
|
+
|
2821
|
+
alias noon middle_of_day
|
2822
|
+
|
2823
|
+
alias at_midday middle_of_day
|
2824
|
+
|
2825
|
+
alias at_noon middle_of_day
|
2826
|
+
|
2827
|
+
alias at_middle_of_day middle_of_day
|
2828
|
+
|
2751
2829
|
# Returns a new DateTime representing the end of the day (23:59:59).
|
2752
2830
|
def end_of_day: () -> untyped
|
2753
2831
|
|
2832
|
+
alias at_end_of_day end_of_day
|
2833
|
+
|
2754
2834
|
# Returns a new DateTime representing the start of the hour (hh:00:00).
|
2755
2835
|
def beginning_of_hour: () -> untyped
|
2756
2836
|
|
2837
|
+
alias at_beginning_of_hour beginning_of_hour
|
2838
|
+
|
2757
2839
|
# Returns a new DateTime representing the end of the hour (hh:59:59).
|
2758
2840
|
def end_of_hour: () -> untyped
|
2759
2841
|
|
2842
|
+
alias at_end_of_hour end_of_hour
|
2843
|
+
|
2760
2844
|
# Returns a new DateTime representing the start of the minute (hh:mm:00).
|
2761
2845
|
def beginning_of_minute: () -> untyped
|
2762
2846
|
|
2847
|
+
alias at_beginning_of_minute beginning_of_minute
|
2848
|
+
|
2763
2849
|
# Returns a new DateTime representing the end of the minute (hh:mm:59).
|
2764
2850
|
def end_of_minute: () -> untyped
|
2765
2851
|
|
2852
|
+
alias at_end_of_minute end_of_minute
|
2853
|
+
|
2766
2854
|
# Returns a <tt>Time</tt> instance of the simultaneous time in the system timezone.
|
2767
2855
|
def localtime: (?untyped? utc_offset) -> untyped
|
2768
2856
|
|
2857
|
+
alias getlocal localtime
|
2858
|
+
|
2769
2859
|
# Returns a <tt>Time</tt> instance of the simultaneous time in the UTC timezone.
|
2770
2860
|
#
|
2771
2861
|
# DateTime.civil(2005, 2, 21, 10, 11, 12, Rational(-6, 24)) # => Mon, 21 Feb 2005 10:11:12 -0600
|
2772
2862
|
# DateTime.civil(2005, 2, 21, 10, 11, 12, Rational(-6, 24)).utc # => Mon, 21 Feb 2005 16:11:12 UTC
|
2773
2863
|
def utc: () -> untyped
|
2774
2864
|
|
2865
|
+
alias getgm utc
|
2866
|
+
|
2867
|
+
alias getutc utc
|
2868
|
+
|
2869
|
+
alias gmtime utc
|
2870
|
+
|
2775
2871
|
# Returns +true+ if <tt>offset == 0</tt>.
|
2776
2872
|
def utc?: () -> untyped
|
2777
2873
|
|
@@ -2821,6 +2917,8 @@ class DateTime
|
|
2821
2917
|
# Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") }
|
2822
2918
|
def to_formatted_s: (?::Symbol format) -> untyped
|
2823
2919
|
|
2920
|
+
alias to_default_s to_s
|
2921
|
+
|
2824
2922
|
# Returns a formatted string of the offset from UTC, or an alternative
|
2825
2923
|
# string if the time zone is already UTC.
|
2826
2924
|
#
|
@@ -2858,10 +2956,6 @@ class DateTime
|
|
2858
2956
|
def seconds_since_unix_epoch: () -> untyped
|
2859
2957
|
end
|
2860
2958
|
|
2861
|
-
class Date
|
2862
|
-
include DateAndTime::Zones
|
2863
|
-
end
|
2864
|
-
|
2865
2959
|
module Digest
|
2866
2960
|
module UUID
|
2867
2961
|
DNS_NAMESPACE: ::String
|
@@ -2894,6 +2988,30 @@ end
|
|
2894
2988
|
module Enumerable[unchecked out Elem, out Return]
|
2895
2989
|
INDEX_WITH_DEFAULT: untyped
|
2896
2990
|
|
2991
|
+
# We can't use Refinements here because Refinements with Module which will be prepended
|
2992
|
+
# doesn't work well https://bugs.ruby-lang.org/issues/13446
|
2993
|
+
alias _original_sum_with_required_identity sum
|
2994
|
+
|
2995
|
+
# Calculates a sum from the elements.
|
2996
|
+
#
|
2997
|
+
# payments.sum { |p| p.price * p.tax_rate }
|
2998
|
+
# payments.sum(&:price)
|
2999
|
+
#
|
3000
|
+
# The latter is a shortcut for:
|
3001
|
+
#
|
3002
|
+
# payments.inject(0) { |sum, p| sum + p.price }
|
3003
|
+
#
|
3004
|
+
# It can also calculate the sum without the use of a block.
|
3005
|
+
#
|
3006
|
+
# [5, 15, 10].sum # => 30
|
3007
|
+
# ['foo', 'bar'].sum # => "foobar"
|
3008
|
+
# [[1, 2], [3, 1, 5]].sum # => [1, 2, 3, 1, 5]
|
3009
|
+
#
|
3010
|
+
# The default sum of an empty list is zero. You can override this default:
|
3011
|
+
#
|
3012
|
+
# [].sum(Payment.new(0)) { |i| i.amount } # => Payment.new(0)
|
3013
|
+
def sum: (?untyped? identity) { () -> untyped } -> untyped
|
3014
|
+
|
2897
3015
|
# Convert an enumerable to a hash keying it by the block return value.
|
2898
3016
|
#
|
2899
3017
|
# people.index_by(&:login)
|
@@ -2955,6 +3073,19 @@ module Enumerable[unchecked out Elem, out Return]
|
|
2955
3073
|
def pluck: (*untyped keys) -> untyped
|
2956
3074
|
end
|
2957
3075
|
|
3076
|
+
class Range[out Elem]
|
3077
|
+
# nodoc:
|
3078
|
+
# Optimize range sum to use arithmetic progression if a block is not given and
|
3079
|
+
# we have a range of numeric values.
|
3080
|
+
def sum: (?untyped? identity) -> untyped
|
3081
|
+
end
|
3082
|
+
|
3083
|
+
class Array[unchecked out Elem]
|
3084
|
+
# nodoc:
|
3085
|
+
# Array#sum was added in Ruby 2.4 but it only works with Numeric elements.
|
3086
|
+
def sum: (?untyped? init) { () -> untyped } -> untyped
|
3087
|
+
end
|
3088
|
+
|
2958
3089
|
class File
|
2959
3090
|
# Write to a file atomically. Useful for situations where you don't
|
2960
3091
|
# want other processes or threads to see half-written files.
|
@@ -3186,6 +3317,18 @@ class Hash[unchecked out K, unchecked out V]
|
|
3186
3317
|
#
|
3187
3318
|
# { a: 1 }.with_indifferent_access['a'] # => 1
|
3188
3319
|
def with_indifferent_access: () -> ActiveSupport::HashWithIndifferentAccess[K, V]
|
3320
|
+
|
3321
|
+
# Called when object is nested under an object that receives
|
3322
|
+
# #with_indifferent_access. This method will be called on the current object
|
3323
|
+
# by the enclosing object and is aliased to #with_indifferent_access by
|
3324
|
+
# default. Subclasses of Hash may overwrite this method to return +self+ if
|
3325
|
+
# converting to an <tt>ActiveSupport::HashWithIndifferentAccess</tt> would not be
|
3326
|
+
# desirable.
|
3327
|
+
#
|
3328
|
+
# b = { b: 1 }
|
3329
|
+
# { a: b }.with_indifferent_access['a'] # calls b.nested_under_indifferent_access
|
3330
|
+
# # => {"b"=>1}
|
3331
|
+
alias nested_under_indifferent_access with_indifferent_access
|
3189
3332
|
end
|
3190
3333
|
|
3191
3334
|
class Hash[unchecked out K, unchecked out V]
|
@@ -3210,10 +3353,14 @@ class Hash[unchecked out K, unchecked out V]
|
|
3210
3353
|
# # => {:name=>"Rob", :age=>"28"}
|
3211
3354
|
def symbolize_keys: () -> untyped
|
3212
3355
|
|
3356
|
+
alias to_options symbolize_keys
|
3357
|
+
|
3213
3358
|
# Destructively converts all keys to symbols, as long as they respond
|
3214
3359
|
# to +to_sym+. Same as +symbolize_keys+, but modifies +self+.
|
3215
3360
|
def symbolize_keys!: () -> untyped
|
3216
3361
|
|
3362
|
+
alias to_options! symbolize_keys!
|
3363
|
+
|
3217
3364
|
# Validates all keys in a hash match <tt>*valid_keys</tt>, raising
|
3218
3365
|
# +ArgumentError+ on a mismatch.
|
3219
3366
|
#
|
@@ -3289,8 +3436,14 @@ class Hash[unchecked out K, unchecked out V]
|
|
3289
3436
|
# with default values.
|
3290
3437
|
def reverse_merge: (untyped other_hash) -> untyped
|
3291
3438
|
|
3439
|
+
alias with_defaults reverse_merge
|
3440
|
+
|
3292
3441
|
# Destructive +reverse_merge+.
|
3293
3442
|
def reverse_merge!: (untyped other_hash) -> untyped
|
3443
|
+
|
3444
|
+
alias reverse_update reverse_merge!
|
3445
|
+
|
3446
|
+
alias with_defaults! reverse_merge!
|
3294
3447
|
end
|
3295
3448
|
|
3296
3449
|
class Hash[unchecked out K, unchecked out V]
|
@@ -3348,10 +3501,14 @@ class Integer
|
|
3348
3501
|
# 2.months # => 2 months
|
3349
3502
|
def months: () -> untyped
|
3350
3503
|
|
3504
|
+
alias month months
|
3505
|
+
|
3351
3506
|
# Returns a Duration instance matching the number of years provided.
|
3352
3507
|
#
|
3353
3508
|
# 2.years # => 2 years
|
3354
3509
|
def years: () -> untyped
|
3510
|
+
|
3511
|
+
alias year years
|
3355
3512
|
end
|
3356
3513
|
|
3357
3514
|
module Kernel
|
@@ -3457,57 +3614,24 @@ class Module
|
|
3457
3614
|
def anonymous?: () -> untyped
|
3458
3615
|
end
|
3459
3616
|
|
3460
|
-
# Extends the module object with class/module and instance accessors for
|
3461
|
-
# class/module attributes, just like the native attr* accessors for instance
|
3462
|
-
# attributes, but does so on a per-thread basis.
|
3463
|
-
#
|
3464
|
-
# So the values are scoped within the Thread.current space under the class name
|
3465
|
-
# of the module.
|
3466
3617
|
class Module
|
3467
|
-
|
3618
|
+
# Declares an attribute reader backed by an internally-named instance variable.
|
3619
|
+
def attr_internal_reader: (*untyped attrs) -> untyped
|
3468
3620
|
|
3469
|
-
|
3621
|
+
# Declares an attribute writer backed by an internally-named instance variable.
|
3622
|
+
def attr_internal_writer: (*untyped attrs) -> untyped
|
3470
3623
|
|
3471
|
-
#
|
3472
|
-
#
|
3473
|
-
|
3474
|
-
|
3475
|
-
|
3476
|
-
|
3477
|
-
|
3478
|
-
|
3479
|
-
|
3480
|
-
|
3481
|
-
|
3482
|
-
# Similarly, if the parent class changes the value, the value of subclasses
|
3483
|
-
# is not changed.
|
3484
|
-
#
|
3485
|
-
# class Customer < Account
|
3486
|
-
# end
|
3487
|
-
#
|
3488
|
-
# Customer.user = "Rafael"
|
3489
|
-
# Customer.user # => "Rafael"
|
3490
|
-
# Account.user # => "DHH"
|
3491
|
-
#
|
3492
|
-
# To omit the instance writer method, pass <tt>instance_writer: false</tt>.
|
3493
|
-
# To omit the instance reader method, pass <tt>instance_reader: false</tt>.
|
3494
|
-
#
|
3495
|
-
# class Current
|
3496
|
-
# thread_mattr_accessor :user, instance_writer: false, instance_reader: false
|
3497
|
-
# end
|
3498
|
-
#
|
3499
|
-
# Current.new.user = "DHH" # => NoMethodError
|
3500
|
-
# Current.new.user # => NoMethodError
|
3501
|
-
#
|
3502
|
-
# Or pass <tt>instance_accessor: false</tt>, to omit both instance methods.
|
3503
|
-
#
|
3504
|
-
# class Current
|
3505
|
-
# thread_mattr_accessor :user, instance_accessor: false
|
3506
|
-
# end
|
3507
|
-
#
|
3508
|
-
# Current.new.user = "DHH" # => NoMethodError
|
3509
|
-
# Current.new.user # => NoMethodError
|
3510
|
-
def thread_mattr_accessor: (*untyped syms, ?instance_accessor: bool instance_accessor, ?instance_writer: bool instance_writer, ?instance_reader: bool instance_reader) -> untyped
|
3624
|
+
# Declares an attribute reader and writer backed by an internally-named instance
|
3625
|
+
# variable.
|
3626
|
+
def attr_internal_accessor: (*untyped attrs) -> untyped
|
3627
|
+
|
3628
|
+
alias attr_internal attr_internal_accessor
|
3629
|
+
|
3630
|
+
attr_accessor attr_internal_naming_format: untyped
|
3631
|
+
|
3632
|
+
def attr_internal_ivar_name: (untyped attr) -> untyped
|
3633
|
+
|
3634
|
+
def attr_internal_define: (untyped attr_name, untyped `type`) -> untyped
|
3511
3635
|
end
|
3512
3636
|
|
3513
3637
|
# Extends the module object with class/module and instance accessors for
|
@@ -3558,7 +3682,9 @@ class Module
|
|
3558
3682
|
# end
|
3559
3683
|
#
|
3560
3684
|
# Person.new.hair_colors # => [:brown, :black, :blonde, :red]
|
3561
|
-
def mattr_reader: (*untyped syms, ?
|
3685
|
+
def mattr_reader: (*untyped syms, ?instance_reader: bool instance_reader, ?instance_accessor: bool instance_accessor, ?default: untyped? default) { () -> untyped } -> untyped
|
3686
|
+
|
3687
|
+
alias cattr_reader mattr_reader
|
3562
3688
|
|
3563
3689
|
# Defines a class attribute and creates a class and instance writer methods to
|
3564
3690
|
# allow assignment to the attribute. All class and instance methods created
|
@@ -3602,7 +3728,9 @@ class Module
|
|
3602
3728
|
# end
|
3603
3729
|
#
|
3604
3730
|
# Person.class_variable_get("@@hair_colors") # => [:brown, :black, :blonde, :red]
|
3605
|
-
def mattr_writer: (*untyped syms, ?
|
3731
|
+
def mattr_writer: (*untyped syms, ?instance_writer: bool instance_writer, ?instance_accessor: bool instance_accessor, ?default: untyped? default) { () -> untyped } -> untyped
|
3732
|
+
|
3733
|
+
alias cattr_writer mattr_writer
|
3606
3734
|
|
3607
3735
|
# Defines both class and instance accessors for class attributes.
|
3608
3736
|
# All class and instance methods created will be public, even if
|
@@ -3668,25 +3796,68 @@ class Module
|
|
3668
3796
|
# end
|
3669
3797
|
#
|
3670
3798
|
# Person.class_variable_get("@@hair_colors") # => [:brown, :black, :blonde, :red]
|
3671
|
-
def mattr_accessor: (*untyped syms, ?
|
3799
|
+
def mattr_accessor: (*untyped syms, ?instance_reader: bool instance_reader, ?instance_writer: bool instance_writer, ?instance_accessor: bool instance_accessor, ?default: untyped? default) { () -> untyped } -> untyped
|
3800
|
+
|
3801
|
+
alias cattr_accessor mattr_accessor
|
3672
3802
|
end
|
3673
3803
|
|
3804
|
+
# Extends the module object with class/module and instance accessors for
|
3805
|
+
# class/module attributes, just like the native attr* accessors for instance
|
3806
|
+
# attributes, but does so on a per-thread basis.
|
3807
|
+
#
|
3808
|
+
# So the values are scoped within the Thread.current space under the class name
|
3809
|
+
# of the module.
|
3674
3810
|
class Module
|
3675
|
-
|
3676
|
-
def attr_internal_reader: (*untyped attrs) -> untyped
|
3811
|
+
def thread_mattr_reader: (*untyped syms, ?instance_reader: bool instance_reader, ?instance_accessor: bool instance_accessor) -> untyped
|
3677
3812
|
|
3678
|
-
|
3679
|
-
def attr_internal_writer: (*untyped attrs) -> untyped
|
3813
|
+
alias thread_cattr_reader thread_mattr_reader
|
3680
3814
|
|
3681
|
-
|
3682
|
-
# variable.
|
3683
|
-
def attr_internal_accessor: (*untyped attrs) -> untyped
|
3815
|
+
def thread_mattr_writer: (*untyped syms, ?instance_writer: bool instance_writer, ?instance_accessor: bool instance_accessor) -> untyped
|
3684
3816
|
|
3685
|
-
|
3817
|
+
alias thread_cattr_writer thread_mattr_writer
|
3686
3818
|
|
3687
|
-
|
3819
|
+
# Defines both class and instance accessors for class attributes.
|
3820
|
+
#
|
3821
|
+
# class Account
|
3822
|
+
# thread_mattr_accessor :user
|
3823
|
+
# end
|
3824
|
+
#
|
3825
|
+
# Account.user = "DHH"
|
3826
|
+
# Account.user # => "DHH"
|
3827
|
+
# Account.new.user # => "DHH"
|
3828
|
+
#
|
3829
|
+
# If a subclass changes the value, the parent class' value is not changed.
|
3830
|
+
# Similarly, if the parent class changes the value, the value of subclasses
|
3831
|
+
# is not changed.
|
3832
|
+
#
|
3833
|
+
# class Customer < Account
|
3834
|
+
# end
|
3835
|
+
#
|
3836
|
+
# Customer.user = "Rafael"
|
3837
|
+
# Customer.user # => "Rafael"
|
3838
|
+
# Account.user # => "DHH"
|
3839
|
+
#
|
3840
|
+
# To omit the instance writer method, pass <tt>instance_writer: false</tt>.
|
3841
|
+
# To omit the instance reader method, pass <tt>instance_reader: false</tt>.
|
3842
|
+
#
|
3843
|
+
# class Current
|
3844
|
+
# thread_mattr_accessor :user, instance_writer: false, instance_reader: false
|
3845
|
+
# end
|
3846
|
+
#
|
3847
|
+
# Current.new.user = "DHH" # => NoMethodError
|
3848
|
+
# Current.new.user # => NoMethodError
|
3849
|
+
#
|
3850
|
+
# Or pass <tt>instance_accessor: false</tt>, to omit both instance methods.
|
3851
|
+
#
|
3852
|
+
# class Current
|
3853
|
+
# thread_mattr_accessor :user, instance_accessor: false
|
3854
|
+
# end
|
3855
|
+
#
|
3856
|
+
# Current.new.user = "DHH" # => NoMethodError
|
3857
|
+
# Current.new.user # => NoMethodError
|
3858
|
+
def thread_mattr_accessor: (*untyped syms, ?instance_reader: bool instance_reader, ?instance_writer: bool instance_writer, ?instance_accessor: bool instance_accessor) -> untyped
|
3688
3859
|
|
3689
|
-
|
3860
|
+
alias thread_cattr_accessor thread_mattr_accessor
|
3690
3861
|
end
|
3691
3862
|
|
3692
3863
|
class Module
|
@@ -3979,7 +4150,7 @@ class Module
|
|
3979
4150
|
# Foo.new("Bar").name # raises NoMethodError: undefined method `name'
|
3980
4151
|
#
|
3981
4152
|
# The target method must be public, otherwise it will raise +NoMethodError+.
|
3982
|
-
def delegate: (*untyped methods, ?
|
4153
|
+
def delegate: (*untyped methods, ?to: untyped? to, ?prefix: untyped? prefix, ?allow_nil: untyped? allow_nil, ?private: untyped? `private`) -> untyped
|
3983
4154
|
|
3984
4155
|
# When building decorators, a common pattern may emerge:
|
3985
4156
|
#
|
@@ -4160,35 +4331,49 @@ class Numeric
|
|
4160
4331
|
# 2.bytes # => 2
|
4161
4332
|
def bytes: () -> untyped
|
4162
4333
|
|
4334
|
+
alias byte bytes
|
4335
|
+
|
4163
4336
|
# Returns the number of bytes equivalent to the kilobytes provided.
|
4164
4337
|
#
|
4165
4338
|
# 2.kilobytes # => 2048
|
4166
4339
|
def kilobytes: () -> untyped
|
4167
4340
|
|
4341
|
+
alias kilobyte kilobytes
|
4342
|
+
|
4168
4343
|
# Returns the number of bytes equivalent to the megabytes provided.
|
4169
4344
|
#
|
4170
4345
|
# 2.megabytes # => 2_097_152
|
4171
4346
|
def megabytes: () -> untyped
|
4172
4347
|
|
4348
|
+
alias megabyte megabytes
|
4349
|
+
|
4173
4350
|
# Returns the number of bytes equivalent to the gigabytes provided.
|
4174
4351
|
#
|
4175
4352
|
# 2.gigabytes # => 2_147_483_648
|
4176
4353
|
def gigabytes: () -> untyped
|
4177
4354
|
|
4355
|
+
alias gigabyte gigabytes
|
4356
|
+
|
4178
4357
|
# Returns the number of bytes equivalent to the terabytes provided.
|
4179
4358
|
#
|
4180
4359
|
# 2.terabytes # => 2_199_023_255_552
|
4181
4360
|
def terabytes: () -> untyped
|
4182
4361
|
|
4362
|
+
alias terabyte terabytes
|
4363
|
+
|
4183
4364
|
# Returns the number of bytes equivalent to the petabytes provided.
|
4184
4365
|
#
|
4185
4366
|
# 2.petabytes # => 2_251_799_813_685_248
|
4186
4367
|
def petabytes: () -> untyped
|
4187
4368
|
|
4369
|
+
alias petabyte petabytes
|
4370
|
+
|
4188
4371
|
# Returns the number of bytes equivalent to the exabytes provided.
|
4189
4372
|
#
|
4190
4373
|
# 2.exabytes # => 2_305_843_009_213_693_952
|
4191
4374
|
def exabytes: () -> untyped
|
4375
|
+
|
4376
|
+
alias exabyte exabytes
|
4192
4377
|
end
|
4193
4378
|
|
4194
4379
|
module ActiveSupport
|
@@ -4299,31 +4484,43 @@ class Numeric
|
|
4299
4484
|
# 2.seconds # => 2 seconds
|
4300
4485
|
def seconds: () -> untyped
|
4301
4486
|
|
4487
|
+
alias second seconds
|
4488
|
+
|
4302
4489
|
# Returns a Duration instance matching the number of minutes provided.
|
4303
4490
|
#
|
4304
4491
|
# 2.minutes # => 2 minutes
|
4305
4492
|
def minutes: () -> untyped
|
4306
4493
|
|
4494
|
+
alias minute minutes
|
4495
|
+
|
4307
4496
|
# Returns a Duration instance matching the number of hours provided.
|
4308
4497
|
#
|
4309
4498
|
# 2.hours # => 2 hours
|
4310
4499
|
def hours: () -> untyped
|
4311
4500
|
|
4501
|
+
alias hour hours
|
4502
|
+
|
4312
4503
|
# Returns a Duration instance matching the number of days provided.
|
4313
4504
|
#
|
4314
4505
|
# 2.days # => 2 days
|
4315
4506
|
def days: () -> untyped
|
4316
4507
|
|
4508
|
+
alias day days
|
4509
|
+
|
4317
4510
|
# Returns a Duration instance matching the number of weeks provided.
|
4318
4511
|
#
|
4319
4512
|
# 2.weeks # => 2 weeks
|
4320
4513
|
def weeks: () -> untyped
|
4321
4514
|
|
4515
|
+
alias week weeks
|
4516
|
+
|
4322
4517
|
# Returns a Duration instance matching the number of fortnights provided.
|
4323
4518
|
#
|
4324
4519
|
# 2.fortnights # => 4 weeks
|
4325
4520
|
def fortnights: () -> untyped
|
4326
4521
|
|
4522
|
+
alias fortnight fortnights
|
4523
|
+
|
4327
4524
|
# Returns the number of milliseconds equivalent to the seconds provided.
|
4328
4525
|
# Used with the standard time durations.
|
4329
4526
|
#
|
@@ -4408,9 +4605,23 @@ class TrueClass
|
|
4408
4605
|
end
|
4409
4606
|
|
4410
4607
|
class Array[unchecked out Elem]
|
4608
|
+
# An array is blank if it's empty:
|
4609
|
+
#
|
4610
|
+
# [].blank? # => true
|
4611
|
+
# [1,2,3].blank? # => false
|
4612
|
+
#
|
4613
|
+
# @return [true, false]
|
4614
|
+
alias blank? empty?
|
4411
4615
|
end
|
4412
4616
|
|
4413
4617
|
class Hash[unchecked out K, unchecked out V]
|
4618
|
+
# A hash is blank if it's empty:
|
4619
|
+
#
|
4620
|
+
# {}.blank? # => true
|
4621
|
+
# { key: 'value' }.blank? # => false
|
4622
|
+
#
|
4623
|
+
# @return [true, false]
|
4624
|
+
alias blank? empty?
|
4414
4625
|
end
|
4415
4626
|
|
4416
4627
|
class String
|
@@ -4640,7 +4851,7 @@ class IO
|
|
4640
4851
|
def as_json: (?untyped? options) -> untyped
|
4641
4852
|
end
|
4642
4853
|
|
4643
|
-
class Range[Elem]
|
4854
|
+
class Range[out Elem]
|
4644
4855
|
def as_json: (?untyped? options) -> untyped
|
4645
4856
|
end
|
4646
4857
|
|
@@ -4736,6 +4947,8 @@ class Hash[unchecked out K, unchecked out V]
|
|
4736
4947
|
#
|
4737
4948
|
# This method is also aliased as +to_param+.
|
4738
4949
|
def to_query: (?untyped? namespace) -> untyped
|
4950
|
+
|
4951
|
+
alias to_param to_query
|
4739
4952
|
end
|
4740
4953
|
|
4741
4954
|
module ActiveSupport
|
@@ -4911,6 +5124,10 @@ module ActiveSupport
|
|
4911
5124
|
# # config/initializers/range_formats.rb
|
4912
5125
|
# Range::RANGE_FORMATS[:short] = ->(start, stop) { "Between #{start.to_s(:db)} and #{stop.to_s(:db)}" }
|
4913
5126
|
def to_s: (?::Symbol format) -> untyped
|
5127
|
+
|
5128
|
+
alias to_default_s to_s
|
5129
|
+
|
5130
|
+
alias to_formatted_s to_s
|
4914
5131
|
end
|
4915
5132
|
end
|
4916
5133
|
|
@@ -4936,7 +5153,7 @@ module ActiveSupport
|
|
4936
5153
|
end
|
4937
5154
|
end
|
4938
5155
|
|
4939
|
-
class Range[Elem]
|
5156
|
+
class Range[out Elem]
|
4940
5157
|
# Compare two ranges and see if they overlap each other
|
4941
5158
|
# (1..5).overlaps?(4..6) # => true
|
4942
5159
|
# (1..5).overlaps?(7..9) # => false
|
@@ -5307,6 +5524,8 @@ class String
|
|
5307
5524
|
# 'active_record/errors'.camelize(:lower) # => "activeRecord::Errors"
|
5308
5525
|
def camelize: (?::Symbol first_letter) -> untyped
|
5309
5526
|
|
5527
|
+
alias camelcase camelize
|
5528
|
+
|
5310
5529
|
# Capitalizes all the words and replaces some characters in the string to create
|
5311
5530
|
# a nicer looking title. +titleize+ is meant for creating pretty output. It is not
|
5312
5531
|
# used in the Rails internals.
|
@@ -5322,6 +5541,8 @@ class String
|
|
5322
5541
|
# 'string_ending_with_id'.titleize(keep_id_suffix: true) # => "String Ending With Id"
|
5323
5542
|
def titleize: (?keep_id_suffix: bool keep_id_suffix) -> untyped
|
5324
5543
|
|
5544
|
+
alias titlecase titleize
|
5545
|
+
|
5325
5546
|
# The reverse of +camelize+. Makes an underscored, lowercase form from the expression in the string.
|
5326
5547
|
#
|
5327
5548
|
# +underscore+ will also change '::' to '/' to convert namespaces to paths.
|
@@ -5388,7 +5609,7 @@ class String
|
|
5388
5609
|
#
|
5389
5610
|
# <%= link_to(@person.name, person_path) %>
|
5390
5611
|
# # => <a href="/person/1-Donald-E-Knuth">Donald E. Knuth</a>
|
5391
|
-
def parameterize: (?
|
5612
|
+
def parameterize: (?separator: ::String separator, ?preserve_case: bool preserve_case, ?locale: untyped? locale) -> untyped
|
5392
5613
|
|
5393
5614
|
# Creates the name of a table like Rails does for models to table names. This method
|
5394
5615
|
# uses the +pluralize+ method on the last word in the string.
|
@@ -5423,7 +5644,7 @@ class String
|
|
5423
5644
|
# 'author_id'.humanize(capitalize: false) # => "author"
|
5424
5645
|
# '_id'.humanize # => "Id"
|
5425
5646
|
# 'author_id'.humanize(keep_id_suffix: true) # => "Author Id"
|
5426
|
-
def humanize: (?
|
5647
|
+
def humanize: (?capitalize: bool capitalize, ?keep_id_suffix: bool keep_id_suffix) -> untyped
|
5427
5648
|
|
5428
5649
|
# Converts just the first character to uppercase.
|
5429
5650
|
#
|
@@ -5513,6 +5734,8 @@ class ERB
|
|
5513
5734
|
# # => is a > 0 & a < 10?
|
5514
5735
|
def html_escape: (untyped s) -> untyped
|
5515
5736
|
|
5737
|
+
alias h html_escape
|
5738
|
+
|
5516
5739
|
def unwrapped_html_escape: (untyped s) -> untyped
|
5517
5740
|
|
5518
5741
|
# A utility method for escaping HTML without affecting existing escaped entities.
|
@@ -5598,6 +5821,8 @@ module ActiveSupport
|
|
5598
5821
|
|
5599
5822
|
UNSAFE_STRING_METHODS_WITH_BACKREF: ::Array[untyped]
|
5600
5823
|
|
5824
|
+
alias original_concat concat
|
5825
|
+
|
5601
5826
|
# Raised when <tt>ActiveSupport::SafeBuffer#safe_concat</tt> is called on unsafe buffers.
|
5602
5827
|
class SafeConcatError < StandardError
|
5603
5828
|
def initialize: () -> untyped
|
@@ -5615,6 +5840,8 @@ module ActiveSupport
|
|
5615
5840
|
|
5616
5841
|
def concat: (untyped value) -> untyped
|
5617
5842
|
|
5843
|
+
alias << concat
|
5844
|
+
|
5618
5845
|
def insert: (untyped index, untyped value) -> untyped
|
5619
5846
|
|
5620
5847
|
def `prepend`: (untyped value) -> untyped
|
@@ -5653,6 +5880,9 @@ class String
|
|
5653
5880
|
end
|
5654
5881
|
|
5655
5882
|
class String
|
5883
|
+
alias starts_with? start_with?
|
5884
|
+
|
5885
|
+
alias ends_with? end_with?
|
5656
5886
|
end
|
5657
5887
|
|
5658
5888
|
class String
|
@@ -5711,6 +5941,8 @@ class Time
|
|
5711
5941
|
# instances can be used when called with a single argument
|
5712
5942
|
def self.at_with_coercion: (*untyped args) -> untyped
|
5713
5943
|
|
5944
|
+
alias self.at_without_coercion self.at
|
5945
|
+
|
5714
5946
|
# Creates a +Time+ instance from an RFC 3339 string.
|
5715
5947
|
#
|
5716
5948
|
# Time.rfc3339('1999-12-31T14:00:00-10:00') # => 2000-01-01 00:00:00 -1000
|
@@ -5772,44 +6004,82 @@ class Time
|
|
5772
6004
|
# Returns a new Time representing the time a number of seconds since the instance time
|
5773
6005
|
def since: (untyped seconds) -> untyped
|
5774
6006
|
|
6007
|
+
alias in since
|
6008
|
+
|
5775
6009
|
# Returns a new Time representing the start of the day (0:00)
|
5776
6010
|
def beginning_of_day: () -> untyped
|
5777
6011
|
|
6012
|
+
alias midnight beginning_of_day
|
6013
|
+
|
6014
|
+
alias at_midnight beginning_of_day
|
6015
|
+
|
6016
|
+
alias at_beginning_of_day beginning_of_day
|
6017
|
+
|
5778
6018
|
# Returns a new Time representing the middle of the day (12:00)
|
5779
6019
|
def middle_of_day: () -> untyped
|
5780
6020
|
|
6021
|
+
alias midday middle_of_day
|
6022
|
+
|
6023
|
+
alias noon middle_of_day
|
6024
|
+
|
6025
|
+
alias at_midday middle_of_day
|
6026
|
+
|
6027
|
+
alias at_noon middle_of_day
|
6028
|
+
|
6029
|
+
alias at_middle_of_day middle_of_day
|
6030
|
+
|
5781
6031
|
# Returns a new Time representing the end of the day, 23:59:59.999999
|
5782
6032
|
def end_of_day: () -> untyped
|
5783
6033
|
|
6034
|
+
alias at_end_of_day end_of_day
|
6035
|
+
|
5784
6036
|
# Returns a new Time representing the start of the hour (x:00)
|
5785
6037
|
def beginning_of_hour: () -> untyped
|
5786
6038
|
|
6039
|
+
alias at_beginning_of_hour beginning_of_hour
|
6040
|
+
|
5787
6041
|
# Returns a new Time representing the end of the hour, x:59:59.999999
|
5788
6042
|
def end_of_hour: () -> untyped
|
5789
6043
|
|
6044
|
+
alias at_end_of_hour end_of_hour
|
6045
|
+
|
5790
6046
|
# Returns a new Time representing the start of the minute (x:xx:00)
|
5791
6047
|
def beginning_of_minute: () -> untyped
|
5792
6048
|
|
6049
|
+
alias at_beginning_of_minute beginning_of_minute
|
6050
|
+
|
5793
6051
|
# Returns a new Time representing the end of the minute, x:xx:59.999999
|
5794
6052
|
def end_of_minute: () -> untyped
|
5795
6053
|
|
6054
|
+
alias at_end_of_minute end_of_minute
|
6055
|
+
|
5796
6056
|
def plus_with_duration: (untyped other) -> untyped
|
5797
6057
|
|
6058
|
+
alias plus_without_duration +
|
6059
|
+
|
5798
6060
|
def minus_with_duration: (untyped other) -> untyped
|
5799
6061
|
|
6062
|
+
alias minus_without_duration -
|
6063
|
+
|
5800
6064
|
# Time#- can also be used to determine the number of seconds between two Time instances.
|
5801
6065
|
# We're layering on additional behavior so that ActiveSupport::TimeWithZone instances
|
5802
6066
|
# are coerced into values that Time#- will recognize
|
5803
6067
|
def minus_with_coercion: (untyped other) -> untyped
|
5804
6068
|
|
6069
|
+
alias minus_without_coercion -
|
6070
|
+
|
5805
6071
|
# Layers additional behavior on Time#<=> so that DateTime and ActiveSupport::TimeWithZone instances
|
5806
6072
|
# can be chronologically compared with a Time
|
5807
6073
|
def compare_with_coercion: (untyped other) -> untyped
|
5808
6074
|
|
6075
|
+
alias compare_without_coercion <=>
|
6076
|
+
|
5809
6077
|
# Layers additional behavior on Time#eql? so that ActiveSupport::TimeWithZone instances
|
5810
6078
|
# can be eql? to an equivalent Time
|
5811
6079
|
def eql_with_coercion: (untyped other) -> untyped
|
5812
6080
|
|
6081
|
+
alias eql_without_coercion eql?
|
6082
|
+
|
5813
6083
|
# Returns a new time the specified number of days ago.
|
5814
6084
|
def prev_day: (?::Integer days) -> untyped
|
5815
6085
|
|
@@ -5867,12 +6137,17 @@ class Time
|
|
5867
6137
|
# Time::DATE_FORMATS[:short_ordinal] = ->(time) { time.strftime("%B #{time.day.ordinalize}") }
|
5868
6138
|
def to_formatted_s: (?::Symbol format) -> untyped
|
5869
6139
|
|
6140
|
+
alias to_default_s to_s
|
6141
|
+
|
5870
6142
|
# Returns a formatted string of the offset from UTC, or an alternative
|
5871
6143
|
# string if the time zone is already UTC.
|
5872
6144
|
#
|
5873
6145
|
# Time.local(2000).formatted_offset # => "-06:00"
|
5874
6146
|
# Time.local(2000).formatted_offset(false) # => "-0600"
|
5875
6147
|
def formatted_offset: (?bool colon, ?untyped? alternate_utc_string) -> untyped
|
6148
|
+
|
6149
|
+
# Aliased to +xmlschema+ for compatibility with +DateTime+
|
6150
|
+
alias rfc3339 xmlschema
|
5876
6151
|
end
|
5877
6152
|
|
5878
6153
|
class Time
|
@@ -6052,6 +6327,8 @@ module ActiveSupport
|
|
6052
6327
|
# Calls this block after #reset is called on the instance. Used for resetting external collaborators, like Time.zone.
|
6053
6328
|
def self.resets: () { () -> untyped } -> untyped
|
6054
6329
|
|
6330
|
+
alias self.after_reset self.resets
|
6331
|
+
|
6055
6332
|
def self.reset_all: () -> untyped
|
6056
6333
|
|
6057
6334
|
def self.clear_all: () -> untyped
|
@@ -6126,30 +6403,75 @@ module ActiveSupport
|
|
6126
6403
|
end
|
6127
6404
|
end
|
6128
6405
|
|
6129
|
-
module ActiveSupport
|
6130
|
-
module Dependencies
|
6131
|
-
# nodoc:
|
6132
|
-
# nodoc:
|
6133
|
-
class Interlock
|
6134
|
-
def initialize: () -> untyped
|
6406
|
+
module ActiveSupport
|
6407
|
+
module Dependencies
|
6408
|
+
# nodoc:
|
6409
|
+
# nodoc:
|
6410
|
+
class Interlock
|
6411
|
+
def initialize: () -> untyped
|
6412
|
+
|
6413
|
+
def loading: () { () -> untyped } -> untyped
|
6414
|
+
|
6415
|
+
def unloading: () { () -> untyped } -> untyped
|
6416
|
+
|
6417
|
+
def start_unloading: () -> untyped
|
6418
|
+
|
6419
|
+
def done_unloading: () -> untyped
|
6420
|
+
|
6421
|
+
def start_running: () -> untyped
|
6422
|
+
|
6423
|
+
def done_running: () -> untyped
|
6424
|
+
|
6425
|
+
def running: () { () -> untyped } -> untyped
|
6426
|
+
|
6427
|
+
def permit_concurrent_loads: () { () -> untyped } -> untyped
|
6428
|
+
|
6429
|
+
def raw_state: () { () -> untyped } -> untyped
|
6430
|
+
end
|
6431
|
+
end
|
6432
|
+
end
|
6433
|
+
|
6434
|
+
module ActiveSupport
|
6435
|
+
module Dependencies
|
6436
|
+
module ZeitwerkIntegration
|
6437
|
+
# :nodoc: all
|
6438
|
+
module Decorations
|
6439
|
+
def clear: () -> untyped
|
6440
|
+
|
6441
|
+
def constantize: (untyped cpath) -> untyped
|
6442
|
+
|
6443
|
+
def safe_constantize: (untyped cpath) -> untyped
|
6444
|
+
|
6445
|
+
def autoloaded_constants: () -> untyped
|
6446
|
+
|
6447
|
+
def autoloaded?: (untyped object) -> untyped
|
6448
|
+
|
6449
|
+
def verbose=: (untyped verbose) -> untyped
|
6450
|
+
|
6451
|
+
def unhook!: () -> :no_op
|
6452
|
+
end
|
6135
6453
|
|
6136
|
-
|
6454
|
+
module RequireDependency
|
6455
|
+
def require_dependency: (untyped filename) -> untyped
|
6456
|
+
end
|
6137
6457
|
|
6138
|
-
|
6458
|
+
module Inflector
|
6459
|
+
def self.camelize: (untyped basename, untyped _abspath) -> untyped
|
6139
6460
|
|
6140
|
-
|
6461
|
+
def self.inflect: (untyped overrides) -> untyped
|
6462
|
+
end
|
6141
6463
|
|
6142
|
-
def
|
6464
|
+
def self.take_over: (enable_reloading: untyped enable_reloading) -> untyped
|
6143
6465
|
|
6144
|
-
def
|
6466
|
+
def self.setup_autoloaders: (untyped enable_reloading) -> untyped
|
6145
6467
|
|
6146
|
-
def
|
6468
|
+
def self.autoload_once?: (untyped autoload_path) -> untyped
|
6147
6469
|
|
6148
|
-
def
|
6470
|
+
def self.eager_load?: (untyped autoload_path) -> untyped
|
6149
6471
|
|
6150
|
-
def
|
6472
|
+
def self.freeze_paths: () -> untyped
|
6151
6473
|
|
6152
|
-
def
|
6474
|
+
def self.decorate_dependencies: () -> untyped
|
6153
6475
|
end
|
6154
6476
|
end
|
6155
6477
|
end
|
@@ -6352,6 +6674,8 @@ module ActiveSupport
|
|
6352
6674
|
|
6353
6675
|
def get: (untyped key) -> untyped
|
6354
6676
|
|
6677
|
+
alias [] get
|
6678
|
+
|
6355
6679
|
def safe_get: (untyped key) -> untyped
|
6356
6680
|
|
6357
6681
|
def store: (untyped klass) -> untyped
|
@@ -6404,51 +6728,6 @@ module ActiveSupport
|
|
6404
6728
|
end
|
6405
6729
|
end
|
6406
6730
|
|
6407
|
-
module ActiveSupport
|
6408
|
-
module Dependencies
|
6409
|
-
module ZeitwerkIntegration
|
6410
|
-
# :nodoc: all
|
6411
|
-
module Decorations
|
6412
|
-
def clear: () -> untyped
|
6413
|
-
|
6414
|
-
def constantize: (untyped cpath) -> untyped
|
6415
|
-
|
6416
|
-
def safe_constantize: (untyped cpath) -> untyped
|
6417
|
-
|
6418
|
-
def autoloaded_constants: () -> untyped
|
6419
|
-
|
6420
|
-
def autoloaded?: (untyped object) -> untyped
|
6421
|
-
|
6422
|
-
def verbose=: (untyped verbose) -> untyped
|
6423
|
-
|
6424
|
-
def unhook!: () -> :no_op
|
6425
|
-
end
|
6426
|
-
|
6427
|
-
module RequireDependency
|
6428
|
-
def require_dependency: (untyped filename) -> untyped
|
6429
|
-
end
|
6430
|
-
|
6431
|
-
module Inflector
|
6432
|
-
def self.camelize: (untyped basename, untyped _abspath) -> untyped
|
6433
|
-
|
6434
|
-
def self.inflect: (untyped overrides) -> untyped
|
6435
|
-
end
|
6436
|
-
|
6437
|
-
def self.take_over: (enable_reloading: untyped enable_reloading) -> untyped
|
6438
|
-
|
6439
|
-
def self.setup_autoloaders: (untyped enable_reloading) -> untyped
|
6440
|
-
|
6441
|
-
def self.autoload_once?: (untyped autoload_path) -> untyped
|
6442
|
-
|
6443
|
-
def self.eager_load?: (untyped autoload_path) -> untyped
|
6444
|
-
|
6445
|
-
def self.freeze_paths: () -> untyped
|
6446
|
-
|
6447
|
-
def self.decorate_dependencies: () -> untyped
|
6448
|
-
end
|
6449
|
-
end
|
6450
|
-
end
|
6451
|
-
|
6452
6731
|
module ActiveSupport
|
6453
6732
|
# Raised when <tt>ActiveSupport::Deprecation::Behavior#behavior</tt> is set with <tt>:raise</tt>.
|
6454
6733
|
# You would set <tt>:raise</tt>, as a behavior to raise errors and proactively report exceptions from deprecations.
|
@@ -6725,31 +7004,6 @@ module ActiveSupport
|
|
6725
7004
|
end
|
6726
7005
|
end
|
6727
7006
|
|
6728
|
-
module ActiveSupport
|
6729
|
-
# \Deprecation specifies the API used by Rails to deprecate methods, instance
|
6730
|
-
# variables, objects and constants.
|
6731
|
-
class Deprecation
|
6732
|
-
include Singleton
|
6733
|
-
|
6734
|
-
include InstanceDelegator
|
6735
|
-
|
6736
|
-
include Behavior
|
6737
|
-
|
6738
|
-
include Reporting
|
6739
|
-
|
6740
|
-
include MethodWrapper
|
6741
|
-
|
6742
|
-
# The version number in which the deprecated behavior will be removed, by default.
|
6743
|
-
attr_accessor deprecation_horizon: untyped
|
6744
|
-
|
6745
|
-
# It accepts two parameters on initialization. The first is a version of library
|
6746
|
-
# and the second is a library name.
|
6747
|
-
#
|
6748
|
-
# ActiveSupport::Deprecation.new('2.0', 'MyLibrary')
|
6749
|
-
def initialize: (?::String deprecation_horizon, ?::String gem_name) -> untyped
|
6750
|
-
end
|
6751
|
-
end
|
6752
|
-
|
6753
7007
|
module ActiveSupport
|
6754
7008
|
class Deprecation
|
6755
7009
|
module Reporting
|
@@ -6804,6 +7058,31 @@ module ActiveSupport
|
|
6804
7058
|
end
|
6805
7059
|
end
|
6806
7060
|
|
7061
|
+
module ActiveSupport
|
7062
|
+
# \Deprecation specifies the API used by Rails to deprecate methods, instance
|
7063
|
+
# variables, objects and constants.
|
7064
|
+
class Deprecation
|
7065
|
+
include Singleton
|
7066
|
+
|
7067
|
+
include InstanceDelegator
|
7068
|
+
|
7069
|
+
include Behavior
|
7070
|
+
|
7071
|
+
include Reporting
|
7072
|
+
|
7073
|
+
include MethodWrapper
|
7074
|
+
|
7075
|
+
# The version number in which the deprecated behavior will be removed, by default.
|
7076
|
+
attr_accessor deprecation_horizon: untyped
|
7077
|
+
|
7078
|
+
# It accepts two parameters on initialization. The first is a version of library
|
7079
|
+
# and the second is a library name.
|
7080
|
+
#
|
7081
|
+
# ActiveSupport::Deprecation.new('2.0', 'MyLibrary')
|
7082
|
+
def initialize: (?::String deprecation_horizon, ?::String gem_name) -> untyped
|
7083
|
+
end
|
7084
|
+
end
|
7085
|
+
|
6807
7086
|
module ActiveSupport
|
6808
7087
|
# This module provides an internal implementation to track descendants
|
6809
7088
|
# which is faster than iterating through ObjectSpace.
|
@@ -7056,6 +7335,8 @@ module ActiveSupport
|
|
7056
7335
|
|
7057
7336
|
def is_a?: (untyped klass) -> untyped
|
7058
7337
|
|
7338
|
+
alias kind_of? is_a?
|
7339
|
+
|
7059
7340
|
def instance_of?: (untyped klass) -> untyped
|
7060
7341
|
|
7061
7342
|
# Returns +true+ if +other+ is also a Duration instance with the
|
@@ -7100,10 +7381,18 @@ module ActiveSupport
|
|
7100
7381
|
# as this Duration represents.
|
7101
7382
|
def since: (?untyped time) -> untyped
|
7102
7383
|
|
7384
|
+
alias from_now since
|
7385
|
+
|
7386
|
+
alias after since
|
7387
|
+
|
7103
7388
|
# Calculates a new Time or Date that is as far in the past
|
7104
7389
|
# as this Duration represents.
|
7105
7390
|
def ago: (?untyped time) -> untyped
|
7106
7391
|
|
7392
|
+
alias until ago
|
7393
|
+
|
7394
|
+
alias before ago
|
7395
|
+
|
7107
7396
|
def inspect: () -> (::String | untyped)
|
7108
7397
|
|
7109
7398
|
def as_json: (?untyped? options) -> untyped
|
@@ -7128,7 +7417,7 @@ end
|
|
7128
7417
|
|
7129
7418
|
module ActiveSupport
|
7130
7419
|
class EncryptedConfiguration < EncryptedFile
|
7131
|
-
def initialize: (
|
7420
|
+
def initialize: (config_path: untyped config_path, key_path: untyped key_path, env_key: untyped env_key, raise_if_missing_key: untyped raise_if_missing_key) -> untyped
|
7132
7421
|
|
7133
7422
|
# Allow a config to be started without a file present
|
7134
7423
|
def read: () -> untyped
|
@@ -7150,7 +7439,7 @@ module ActiveSupport
|
|
7150
7439
|
end
|
7151
7440
|
|
7152
7441
|
class MissingKeyError < RuntimeError
|
7153
|
-
def initialize: (
|
7442
|
+
def initialize: (key_path: untyped key_path, env_key: untyped env_key) -> untyped
|
7154
7443
|
end
|
7155
7444
|
|
7156
7445
|
CIPHER: ::String
|
@@ -7165,7 +7454,7 @@ module ActiveSupport
|
|
7165
7454
|
|
7166
7455
|
attr_reader raise_if_missing_key: untyped
|
7167
7456
|
|
7168
|
-
def initialize: (
|
7457
|
+
def initialize: (content_path: untyped content_path, key_path: untyped key_path, env_key: untyped env_key, raise_if_missing_key: untyped raise_if_missing_key) -> untyped
|
7169
7458
|
|
7170
7459
|
def key: () -> untyped
|
7171
7460
|
|
@@ -7275,18 +7564,20 @@ module ActiveSupport
|
|
7275
7564
|
|
7276
7565
|
def self.to_complete: (*untyped args) { () -> untyped } -> untyped
|
7277
7566
|
|
7278
|
-
class RunHook < ::Struct[
|
7567
|
+
class RunHook[T] < ::Struct[T]
|
7279
7568
|
attr_accessor hook(): untyped
|
7280
7569
|
|
7281
7570
|
# :nodoc:
|
7282
7571
|
def before: (untyped target) -> untyped
|
7283
7572
|
end
|
7284
7573
|
|
7285
|
-
class CompleteHook < ::Struct[
|
7574
|
+
class CompleteHook[T] < ::Struct[T]
|
7286
7575
|
attr_accessor hook(): untyped
|
7287
7576
|
|
7288
7577
|
# :nodoc:
|
7289
7578
|
def before: (untyped target) -> untyped
|
7579
|
+
|
7580
|
+
alias after before
|
7290
7581
|
end
|
7291
7582
|
|
7292
7583
|
# Register an object to be invoked during both the +run+ and
|
@@ -7505,6 +7796,10 @@ module ActiveSupport
|
|
7505
7796
|
|
7506
7797
|
def self.[]: (*untyped args) -> untyped
|
7507
7798
|
|
7799
|
+
alias regular_writer []=
|
7800
|
+
|
7801
|
+
alias regular_update update
|
7802
|
+
|
7508
7803
|
# Assigns a new value to the hash:
|
7509
7804
|
#
|
7510
7805
|
# hash = ActiveSupport::HashWithIndifferentAccess.new
|
@@ -7513,6 +7808,8 @@ module ActiveSupport
|
|
7513
7808
|
# This value can be later fetched using either +:key+ or <tt>'key'</tt>.
|
7514
7809
|
def []=: (untyped key, untyped value) -> untyped
|
7515
7810
|
|
7811
|
+
alias store []=
|
7812
|
+
|
7516
7813
|
# Updates the receiver in-place, merging in the hash passed as argument:
|
7517
7814
|
#
|
7518
7815
|
# hash_1 = ActiveSupport::HashWithIndifferentAccess.new
|
@@ -7540,6 +7837,8 @@ module ActiveSupport
|
|
7540
7837
|
# hash_1.update(hash_2) { |key, old, new| old + new } # => {"key"=>22}
|
7541
7838
|
def update: (untyped other_hash) { (untyped, untyped, untyped) -> untyped } -> untyped
|
7542
7839
|
|
7840
|
+
alias merge! update
|
7841
|
+
|
7543
7842
|
# Checks the hash for a key matching the argument passed in:
|
7544
7843
|
#
|
7545
7844
|
# hash = ActiveSupport::HashWithIndifferentAccess.new
|
@@ -7548,6 +7847,12 @@ module ActiveSupport
|
|
7548
7847
|
# hash.key?('key') # => true
|
7549
7848
|
def key?: (untyped key) -> untyped
|
7550
7849
|
|
7850
|
+
alias include? key?
|
7851
|
+
|
7852
|
+
alias has_key? key?
|
7853
|
+
|
7854
|
+
alias member? key?
|
7855
|
+
|
7551
7856
|
# Same as <tt>Hash#[]</tt> where the key passed as argument can be
|
7552
7857
|
# either a string or a symbol:
|
7553
7858
|
#
|
@@ -7647,9 +7952,13 @@ module ActiveSupport
|
|
7647
7952
|
# hash.reverse_merge(a: 0, b: 1) # => {"a"=>nil, "b"=>1}
|
7648
7953
|
def reverse_merge: (untyped other_hash) -> untyped
|
7649
7954
|
|
7955
|
+
alias with_defaults reverse_merge
|
7956
|
+
|
7650
7957
|
# Same semantics as +reverse_merge+ but modifies the receiver in-place.
|
7651
7958
|
def reverse_merge!: (untyped other_hash) -> untyped
|
7652
7959
|
|
7960
|
+
alias with_defaults! reverse_merge!
|
7961
|
+
|
7653
7962
|
# Replaces the contents of this hash with other_hash.
|
7654
7963
|
#
|
7655
7964
|
# h = { "a" => 100, "b" => 200 }
|
@@ -7661,6 +7970,8 @@ module ActiveSupport
|
|
7661
7970
|
|
7662
7971
|
def except: (*untyped keys) -> untyped
|
7663
7972
|
|
7973
|
+
alias without except
|
7974
|
+
|
7664
7975
|
def stringify_keys!: () -> untyped
|
7665
7976
|
|
7666
7977
|
def deep_stringify_keys!: () -> untyped
|
@@ -7671,6 +7982,8 @@ module ActiveSupport
|
|
7671
7982
|
|
7672
7983
|
def symbolize_keys: () -> untyped
|
7673
7984
|
|
7985
|
+
alias to_options symbolize_keys
|
7986
|
+
|
7674
7987
|
def deep_symbolize_keys: () -> untyped
|
7675
7988
|
|
7676
7989
|
def to_options!: () -> untyped
|
@@ -7702,7 +8015,7 @@ module ActiveSupport
|
|
7702
8015
|
end
|
7703
8016
|
end
|
7704
8017
|
|
7705
|
-
# NOTE: HashWithIndifferentAccess and ActiveSupport::HashWithIndifferentAccess are the same object
|
8018
|
+
# NOTE: HashWithIndifferentAccess and ActiveSupport::HashWithIndifferentAccess are the same object
|
7706
8019
|
# but RBS doesn't have class alias syntax
|
7707
8020
|
class HashWithIndifferentAccess[T, U] < ActiveSupport::HashWithIndifferentAccess[T, U]
|
7708
8021
|
end
|
@@ -7997,7 +8310,7 @@ module ActiveSupport
|
|
7997
8310
|
#
|
7998
8311
|
# humanize('ssl_error') # => "SSL error"
|
7999
8312
|
#
|
8000
|
-
def humanize: (untyped lower_case_and_underscored_word, ?
|
8313
|
+
def humanize: (untyped lower_case_and_underscored_word, ?capitalize: bool capitalize, ?keep_id_suffix: bool keep_id_suffix) -> untyped
|
8001
8314
|
|
8002
8315
|
# Converts just the first character to uppercase.
|
8003
8316
|
#
|
@@ -8246,7 +8559,7 @@ module ActiveSupport
|
|
8246
8559
|
# the word will be parameterized as a word of that language.
|
8247
8560
|
# By default, this parameter is set to <tt>nil</tt> and it will use
|
8248
8561
|
# the configured <tt>I18n.locale<tt>.
|
8249
|
-
def parameterize: (untyped string, ?
|
8562
|
+
def parameterize: (untyped string, ?separator: ::String separator, ?preserve_case: bool preserve_case, ?locale: untyped? locale) -> untyped
|
8250
8563
|
end
|
8251
8564
|
end
|
8252
8565
|
|
@@ -8425,61 +8738,66 @@ module ActiveSupport
|
|
8425
8738
|
end
|
8426
8739
|
|
8427
8740
|
module ActiveSupport
|
8428
|
-
class
|
8429
|
-
|
8430
|
-
|
8431
|
-
# Returns true if the logger destination matches one of the sources
|
8741
|
+
class LogSubscriber
|
8742
|
+
# Provides some helpers to deal with testing log subscribers by setting up
|
8743
|
+
# notifications. Take for instance Active Record subscriber tests:
|
8432
8744
|
#
|
8433
|
-
#
|
8434
|
-
#
|
8435
|
-
#
|
8436
|
-
|
8437
|
-
|
8438
|
-
|
8439
|
-
|
8440
|
-
def
|
8441
|
-
|
8442
|
-
#
|
8443
|
-
|
8444
|
-
|
8445
|
-
|
8446
|
-
end
|
8447
|
-
|
8448
|
-
|
8449
|
-
|
8450
|
-
|
8451
|
-
|
8452
|
-
|
8453
|
-
|
8454
|
-
|
8745
|
+
# class SyncLogSubscriberTest < ActiveSupport::TestCase
|
8746
|
+
# include ActiveSupport::LogSubscriber::TestHelper
|
8747
|
+
#
|
8748
|
+
# setup do
|
8749
|
+
# ActiveRecord::LogSubscriber.attach_to(:active_record)
|
8750
|
+
# end
|
8751
|
+
#
|
8752
|
+
# def test_basic_query_logging
|
8753
|
+
# Developer.all.to_a
|
8754
|
+
# wait
|
8755
|
+
# assert_equal 1, @logger.logged(:debug).size
|
8756
|
+
# assert_match(/Developer Load/, @logger.logged(:debug).last)
|
8757
|
+
# assert_match(/SELECT \* FROM "developers"/, @logger.logged(:debug).last)
|
8758
|
+
# end
|
8759
|
+
# end
|
8760
|
+
#
|
8761
|
+
# All you need to do is to ensure that your log subscriber is added to
|
8762
|
+
# Rails::Subscriber, as in the second line of the code above. The test
|
8763
|
+
# helpers are responsible for setting up the queue, subscriptions and
|
8764
|
+
# turning colors in logs off.
|
8765
|
+
#
|
8766
|
+
# The messages are available in the @logger instance, which is a logger with
|
8767
|
+
# limited powers (it actually does not send anything to your output), and
|
8768
|
+
# you can collect them doing @logger.logged(level), where level is the level
|
8769
|
+
# used in logging, like info, debug, warn and so on.
|
8770
|
+
module TestHelper
|
8771
|
+
def setup: () -> untyped
|
8455
8772
|
|
8456
|
-
|
8457
|
-
module LoggerSilence
|
8458
|
-
extend ActiveSupport::Concern
|
8773
|
+
def teardown: () -> untyped
|
8459
8774
|
|
8460
|
-
|
8775
|
+
class MockLogger
|
8776
|
+
include ::Logger::Severity
|
8461
8777
|
|
8462
|
-
|
8463
|
-
def silence: (?untyped temporary_level) { (untyped) -> untyped } -> untyped
|
8464
|
-
end
|
8465
|
-
end
|
8778
|
+
attr_reader flush_count: untyped
|
8466
8779
|
|
8467
|
-
|
8468
|
-
module LoggerThreadSafeLevel
|
8469
|
-
# :nodoc:
|
8470
|
-
extend ActiveSupport::Concern
|
8780
|
+
attr_accessor level: untyped
|
8471
8781
|
|
8472
|
-
|
8782
|
+
def initialize: (?untyped level) -> untyped
|
8473
8783
|
|
8474
|
-
|
8784
|
+
def method_missing: (untyped level, ?untyped? message) { () -> untyped } -> untyped
|
8475
8785
|
|
8476
|
-
|
8786
|
+
def logged: (untyped level) -> untyped
|
8477
8787
|
|
8478
|
-
|
8788
|
+
def flush: () -> untyped
|
8789
|
+
end
|
8479
8790
|
|
8480
|
-
|
8791
|
+
# Wait notifications to be published.
|
8792
|
+
def wait: () -> untyped
|
8481
8793
|
|
8482
|
-
|
8794
|
+
# Overwrite if you use another logger in your log subscriber.
|
8795
|
+
#
|
8796
|
+
# def logger
|
8797
|
+
# ActiveRecord::Base.logger = @logger
|
8798
|
+
# end
|
8799
|
+
def set_logger: (untyped logger) -> untyped
|
8800
|
+
end
|
8483
8801
|
end
|
8484
8802
|
end
|
8485
8803
|
|
@@ -8572,75 +8890,70 @@ module ActiveSupport
|
|
8572
8890
|
|
8573
8891
|
def logger: () -> untyped
|
8574
8892
|
|
8575
|
-
def start: (untyped name, untyped id, untyped payload) -> untyped
|
8893
|
+
def start: (untyped name, untyped id, untyped payload) -> untyped
|
8894
|
+
|
8895
|
+
def finish: (untyped name, untyped id, untyped payload) -> untyped
|
8896
|
+
|
8897
|
+
def color: (untyped text, untyped color, ?bool bold) -> (untyped | ::String)
|
8898
|
+
end
|
8899
|
+
end
|
8900
|
+
|
8901
|
+
module ActiveSupport
|
8902
|
+
class Logger < ::Logger
|
8903
|
+
include LoggerSilence
|
8904
|
+
|
8905
|
+
# Returns true if the logger destination matches one of the sources
|
8906
|
+
#
|
8907
|
+
# logger = Logger.new(STDOUT)
|
8908
|
+
# ActiveSupport::Logger.logger_outputs_to?(logger, STDOUT)
|
8909
|
+
# # => true
|
8910
|
+
def self.logger_outputs_to?: (untyped logger, *untyped sources) -> untyped
|
8911
|
+
|
8912
|
+
def self.broadcast: (untyped logger) -> untyped
|
8576
8913
|
|
8577
|
-
def
|
8914
|
+
def initialize: (*untyped args, **untyped kwargs) -> untyped
|
8578
8915
|
|
8579
|
-
|
8916
|
+
# Simple formatter which only displays the message.
|
8917
|
+
class SimpleFormatter < ::Logger::Formatter
|
8918
|
+
# This method is invoked when a log event occurs
|
8919
|
+
def call: (untyped severity, untyped timestamp, untyped progname, untyped msg) -> ::String
|
8920
|
+
end
|
8580
8921
|
end
|
8581
8922
|
end
|
8582
8923
|
|
8583
|
-
module
|
8584
|
-
|
8585
|
-
# Provides some helpers to deal with testing log subscribers by setting up
|
8586
|
-
# notifications. Take for instance Active Record subscriber tests:
|
8587
|
-
#
|
8588
|
-
# class SyncLogSubscriberTest < ActiveSupport::TestCase
|
8589
|
-
# include ActiveSupport::LogSubscriber::TestHelper
|
8590
|
-
#
|
8591
|
-
# setup do
|
8592
|
-
# ActiveRecord::LogSubscriber.attach_to(:active_record)
|
8593
|
-
# end
|
8594
|
-
#
|
8595
|
-
# def test_basic_query_logging
|
8596
|
-
# Developer.all.to_a
|
8597
|
-
# wait
|
8598
|
-
# assert_equal 1, @logger.logged(:debug).size
|
8599
|
-
# assert_match(/Developer Load/, @logger.logged(:debug).last)
|
8600
|
-
# assert_match(/SELECT \* FROM "developers"/, @logger.logged(:debug).last)
|
8601
|
-
# end
|
8602
|
-
# end
|
8603
|
-
#
|
8604
|
-
# All you need to do is to ensure that your log subscriber is added to
|
8605
|
-
# Rails::Subscriber, as in the second line of the code above. The test
|
8606
|
-
# helpers are responsible for setting up the queue, subscriptions and
|
8607
|
-
# turning colors in logs off.
|
8608
|
-
#
|
8609
|
-
# The messages are available in the @logger instance, which is a logger with
|
8610
|
-
# limited powers (it actually does not send anything to your output), and
|
8611
|
-
# you can collect them doing @logger.logged(level), where level is the level
|
8612
|
-
# used in logging, like info, debug, warn and so on.
|
8613
|
-
module TestHelper
|
8614
|
-
def setup: () -> untyped
|
8924
|
+
module LoggerSilence
|
8925
|
+
extend ActiveSupport::Concern
|
8615
8926
|
|
8616
|
-
|
8927
|
+
include ActiveSupport::LoggerSilence
|
8928
|
+
end
|
8617
8929
|
|
8618
|
-
|
8619
|
-
|
8930
|
+
module ActiveSupport
|
8931
|
+
module LoggerSilence
|
8932
|
+
extend ActiveSupport::Concern
|
8620
8933
|
|
8621
|
-
|
8934
|
+
include ActiveSupport::LoggerThreadSafeLevel
|
8622
8935
|
|
8623
|
-
|
8936
|
+
# Silences the logger for the duration of the block.
|
8937
|
+
def silence: (?untyped temporary_level) { (untyped) -> untyped } -> untyped
|
8938
|
+
end
|
8939
|
+
end
|
8624
8940
|
|
8625
|
-
|
8941
|
+
module ActiveSupport
|
8942
|
+
module LoggerThreadSafeLevel
|
8943
|
+
# :nodoc:
|
8944
|
+
extend ActiveSupport::Concern
|
8626
8945
|
|
8627
|
-
|
8946
|
+
def after_initialize: () -> untyped
|
8628
8947
|
|
8629
|
-
|
8948
|
+
def local_log_id: () -> untyped
|
8630
8949
|
|
8631
|
-
|
8632
|
-
end
|
8950
|
+
def local_level: () -> untyped
|
8633
8951
|
|
8634
|
-
|
8635
|
-
def wait: () -> untyped
|
8952
|
+
def local_level=: (untyped level) -> untyped
|
8636
8953
|
|
8637
|
-
|
8638
|
-
|
8639
|
-
|
8640
|
-
# ActiveRecord::Base.logger = @logger
|
8641
|
-
# end
|
8642
|
-
def set_logger: (untyped logger) -> untyped
|
8643
|
-
end
|
8954
|
+
def level: () -> untyped
|
8955
|
+
|
8956
|
+
def add: (untyped severity, ?untyped? message, ?untyped? progname) { () -> untyped } -> (::TrueClass | untyped)
|
8644
8957
|
end
|
8645
8958
|
end
|
8646
8959
|
|
@@ -8759,7 +9072,7 @@ module ActiveSupport
|
|
8759
9072
|
|
8760
9073
|
# Encrypt and sign a message. We need to sign the message in order to avoid
|
8761
9074
|
# padding attacks. Reference: https://www.limited-entropy.com/padding-oracle-attacks/.
|
8762
|
-
def encrypt_and_sign: (untyped value, ?
|
9075
|
+
def encrypt_and_sign: (untyped value, ?expires_at: untyped? expires_at, ?expires_in: untyped? expires_in, ?purpose: untyped? purpose) -> untyped
|
8763
9076
|
|
8764
9077
|
# Decrypt and verify a message. We need to verify the message in order to
|
8765
9078
|
# avoid padding attacks. Reference: https://www.limited-entropy.com/padding-oracle-attacks/.
|
@@ -8782,81 +9095,6 @@ module ActiveSupport
|
|
8782
9095
|
end
|
8783
9096
|
end
|
8784
9097
|
|
8785
|
-
module ActiveSupport
|
8786
|
-
module Messages
|
8787
|
-
class Metadata
|
8788
|
-
# nodoc:
|
8789
|
-
# nodoc:
|
8790
|
-
def initialize: (untyped message, ?untyped? expires_at, ?untyped? purpose) -> untyped
|
8791
|
-
|
8792
|
-
def as_json: (?::Hash[untyped, untyped] options) -> { _rails: { message: untyped, exp: untyped, pur: untyped } }
|
8793
|
-
|
8794
|
-
def self.wrap: (untyped message, ?purpose: untyped? purpose, ?expires_in: untyped? expires_in, ?expires_at: untyped? expires_at) -> untyped
|
8795
|
-
|
8796
|
-
def self.verify: (untyped message, untyped purpose) -> untyped
|
8797
|
-
|
8798
|
-
def self.pick_expiry: (untyped expires_at, untyped expires_in) -> untyped
|
8799
|
-
|
8800
|
-
def self.extract_metadata: (untyped message) -> untyped
|
8801
|
-
|
8802
|
-
def self.encode: (untyped message) -> untyped
|
8803
|
-
|
8804
|
-
def self.decode: (untyped message) -> untyped
|
8805
|
-
|
8806
|
-
def verify: (untyped purpose) -> untyped
|
8807
|
-
|
8808
|
-
def match?: (untyped purpose) -> untyped
|
8809
|
-
|
8810
|
-
def fresh?: () -> untyped
|
8811
|
-
end
|
8812
|
-
end
|
8813
|
-
end
|
8814
|
-
|
8815
|
-
module ActiveSupport
|
8816
|
-
module Messages
|
8817
|
-
class RotationConfiguration
|
8818
|
-
# :nodoc:
|
8819
|
-
attr_reader signed: untyped
|
8820
|
-
|
8821
|
-
# :nodoc:
|
8822
|
-
attr_reader encrypted: untyped
|
8823
|
-
|
8824
|
-
def initialize: () -> untyped
|
8825
|
-
|
8826
|
-
def rotate: (untyped kind, *untyped args) -> untyped
|
8827
|
-
end
|
8828
|
-
end
|
8829
|
-
end
|
8830
|
-
|
8831
|
-
module ActiveSupport
|
8832
|
-
module Messages
|
8833
|
-
module Rotator
|
8834
|
-
# :nodoc:
|
8835
|
-
def initialize: (**untyped options) -> untyped
|
8836
|
-
|
8837
|
-
def rotate: (*untyped secrets, **untyped options) -> untyped
|
8838
|
-
|
8839
|
-
module Encryptor
|
8840
|
-
include Rotator
|
8841
|
-
|
8842
|
-
def decrypt_and_verify: (*untyped args, ?on_rotation: untyped? on_rotation, **untyped options) -> untyped
|
8843
|
-
|
8844
|
-
def build_rotation: (?untyped secret, ?untyped sign_secret, untyped options) -> untyped
|
8845
|
-
end
|
8846
|
-
|
8847
|
-
module Verifier
|
8848
|
-
include Rotator
|
8849
|
-
|
8850
|
-
def verified: (*untyped args, ?on_rotation: untyped? on_rotation, **untyped options) -> untyped
|
8851
|
-
|
8852
|
-
def build_rotation: (?untyped secret, untyped options) -> untyped
|
8853
|
-
end
|
8854
|
-
|
8855
|
-
def run_rotations: (untyped on_rotation) { (untyped) -> untyped } -> untyped
|
8856
|
-
end
|
8857
|
-
end
|
8858
|
-
end
|
8859
|
-
|
8860
9098
|
module ActiveSupport
|
8861
9099
|
# +MessageVerifier+ makes it easy to generate and verify messages which are
|
8862
9100
|
# signed to prevent tampering.
|
@@ -9010,7 +9248,7 @@ module ActiveSupport
|
|
9010
9248
|
#
|
9011
9249
|
# verifier = ActiveSupport::MessageVerifier.new 's3Krit'
|
9012
9250
|
# verifier.generate 'a private message' # => "BAhJIhRwcml2YXRlLW1lc3NhZ2UGOgZFVA==--e2d724331ebdee96a10fb99b089508d1c72bd772"
|
9013
|
-
def generate: (untyped value, ?
|
9251
|
+
def generate: (untyped value, ?expires_at: untyped? expires_at, ?expires_in: untyped? expires_in, ?purpose: untyped? purpose) -> ::String
|
9014
9252
|
|
9015
9253
|
def encode: (untyped data) -> untyped
|
9016
9254
|
|
@@ -9020,6 +9258,81 @@ module ActiveSupport
|
|
9020
9258
|
end
|
9021
9259
|
end
|
9022
9260
|
|
9261
|
+
module ActiveSupport
|
9262
|
+
module Messages
|
9263
|
+
class Metadata
|
9264
|
+
# nodoc:
|
9265
|
+
# nodoc:
|
9266
|
+
def initialize: (untyped message, ?untyped? expires_at, ?untyped? purpose) -> untyped
|
9267
|
+
|
9268
|
+
def as_json: (?::Hash[untyped, untyped] options) -> { _rails: { message: untyped, exp: untyped, pur: untyped } }
|
9269
|
+
|
9270
|
+
def self.wrap: (untyped message, ?expires_at: untyped? expires_at, ?expires_in: untyped? expires_in, ?purpose: untyped? purpose) -> untyped
|
9271
|
+
|
9272
|
+
def self.verify: (untyped message, untyped purpose) -> untyped
|
9273
|
+
|
9274
|
+
def self.pick_expiry: (untyped expires_at, untyped expires_in) -> untyped
|
9275
|
+
|
9276
|
+
def self.extract_metadata: (untyped message) -> untyped
|
9277
|
+
|
9278
|
+
def self.encode: (untyped message) -> untyped
|
9279
|
+
|
9280
|
+
def self.decode: (untyped message) -> untyped
|
9281
|
+
|
9282
|
+
def verify: (untyped purpose) -> untyped
|
9283
|
+
|
9284
|
+
def match?: (untyped purpose) -> untyped
|
9285
|
+
|
9286
|
+
def fresh?: () -> untyped
|
9287
|
+
end
|
9288
|
+
end
|
9289
|
+
end
|
9290
|
+
|
9291
|
+
module ActiveSupport
|
9292
|
+
module Messages
|
9293
|
+
class RotationConfiguration
|
9294
|
+
# :nodoc:
|
9295
|
+
attr_reader signed: untyped
|
9296
|
+
|
9297
|
+
# :nodoc:
|
9298
|
+
attr_reader encrypted: untyped
|
9299
|
+
|
9300
|
+
def initialize: () -> untyped
|
9301
|
+
|
9302
|
+
def rotate: (untyped kind, *untyped args) -> untyped
|
9303
|
+
end
|
9304
|
+
end
|
9305
|
+
end
|
9306
|
+
|
9307
|
+
module ActiveSupport
|
9308
|
+
module Messages
|
9309
|
+
module Rotator
|
9310
|
+
# :nodoc:
|
9311
|
+
def initialize: (**untyped options) -> untyped
|
9312
|
+
|
9313
|
+
def rotate: (*untyped secrets, **untyped options) -> untyped
|
9314
|
+
|
9315
|
+
module Encryptor
|
9316
|
+
include Rotator
|
9317
|
+
|
9318
|
+
def decrypt_and_verify: (*untyped args, ?on_rotation: untyped? on_rotation, **untyped options) -> untyped
|
9319
|
+
|
9320
|
+
def build_rotation: (?untyped secret, ?untyped sign_secret, untyped options) -> untyped
|
9321
|
+
end
|
9322
|
+
|
9323
|
+
module Verifier
|
9324
|
+
include Rotator
|
9325
|
+
|
9326
|
+
def verified: (*untyped args, ?on_rotation: untyped? on_rotation, **untyped options) -> untyped
|
9327
|
+
|
9328
|
+
def build_rotation: (?untyped secret, untyped options) -> untyped
|
9329
|
+
end
|
9330
|
+
|
9331
|
+
def run_rotations: (untyped on_rotation) { (untyped) -> untyped } -> untyped
|
9332
|
+
end
|
9333
|
+
end
|
9334
|
+
end
|
9335
|
+
|
9023
9336
|
module ActiveSupport
|
9024
9337
|
module Multibyte
|
9025
9338
|
# nodoc:
|
@@ -9064,6 +9377,10 @@ module ActiveSupport
|
|
9064
9377
|
|
9065
9378
|
attr_reader wrapped_string: untyped
|
9066
9379
|
|
9380
|
+
alias to_s wrapped_string
|
9381
|
+
|
9382
|
+
alias to_str wrapped_string
|
9383
|
+
|
9067
9384
|
# Creates a new Chars instance by wrapping _string_.
|
9068
9385
|
def initialize: (untyped string) -> untyped
|
9069
9386
|
|
@@ -9115,6 +9432,8 @@ module ActiveSupport
|
|
9115
9432
|
# "(trim non-ascii characters)".mb_chars.titleize.to_s # => "(trim non-ascii characters)"
|
9116
9433
|
def titleize: () -> untyped
|
9117
9434
|
|
9435
|
+
alias titlecase titleize
|
9436
|
+
|
9118
9437
|
# Returns the KC normalization of the string by default. NFKC is
|
9119
9438
|
# considered the best normalization form for passing strings to databases
|
9120
9439
|
# and validations.
|
@@ -9145,30 +9464,14 @@ module ActiveSupport
|
|
9145
9464
|
# Replaces all ISO-8859-1 or CP1252 characters by their UTF-8 equivalent
|
9146
9465
|
# resulting in a valid UTF-8 string.
|
9147
9466
|
#
|
9148
|
-
# Passing +true+ will forcibly tidy all bytes, assuming that the string's
|
9149
|
-
# encoding is entirely CP1252 or ISO-8859-1.
|
9150
|
-
def tidy_bytes: (?bool force) -> untyped
|
9151
|
-
|
9152
|
-
def as_json: (?untyped? options) -> untyped
|
9153
|
-
|
9154
|
-
def chars: (untyped string) -> untyped
|
9155
|
-
end
|
9156
|
-
end
|
9157
|
-
end
|
9158
|
-
|
9159
|
-
module ActiveSupport
|
9160
|
-
# nodoc:
|
9161
|
-
module Multibyte
|
9162
|
-
# The proxy class returned when calling mb_chars. You can use this accessor
|
9163
|
-
# to configure your own proxy class so you can support other encodings. See
|
9164
|
-
# the ActiveSupport::Multibyte::Chars implementation for an example how to
|
9165
|
-
# do this.
|
9166
|
-
#
|
9167
|
-
# ActiveSupport::Multibyte.proxy_class = CharsForUTF32
|
9168
|
-
def self.proxy_class=: (untyped klass) -> untyped
|
9467
|
+
# Passing +true+ will forcibly tidy all bytes, assuming that the string's
|
9468
|
+
# encoding is entirely CP1252 or ISO-8859-1.
|
9469
|
+
def tidy_bytes: (?bool force) -> untyped
|
9169
9470
|
|
9170
|
-
|
9171
|
-
|
9471
|
+
def as_json: (?untyped? options) -> untyped
|
9472
|
+
|
9473
|
+
def chars: (untyped string) -> untyped
|
9474
|
+
end
|
9172
9475
|
end
|
9173
9476
|
end
|
9174
9477
|
|
@@ -9232,6 +9535,22 @@ module ActiveSupport
|
|
9232
9535
|
end
|
9233
9536
|
end
|
9234
9537
|
|
9538
|
+
module ActiveSupport
|
9539
|
+
# nodoc:
|
9540
|
+
module Multibyte
|
9541
|
+
# The proxy class returned when calling mb_chars. You can use this accessor
|
9542
|
+
# to configure your own proxy class so you can support other encodings. See
|
9543
|
+
# the ActiveSupport::Multibyte::Chars implementation for an example how to
|
9544
|
+
# do this.
|
9545
|
+
#
|
9546
|
+
# ActiveSupport::Multibyte.proxy_class = CharsForUTF32
|
9547
|
+
def self.proxy_class=: (untyped klass) -> untyped
|
9548
|
+
|
9549
|
+
# Returns the current proxy class.
|
9550
|
+
def self.proxy_class: () -> untyped
|
9551
|
+
end
|
9552
|
+
end
|
9553
|
+
|
9235
9554
|
module ActiveSupport
|
9236
9555
|
module Notifications
|
9237
9556
|
# This is a default queue implementation that ships with Notifications.
|
@@ -9333,6 +9652,8 @@ module ActiveSupport
|
|
9333
9652
|
def subscribed_to?: (untyped name) -> ::TrueClass
|
9334
9653
|
|
9335
9654
|
def unsubscribe!: () -> ::FalseClass
|
9655
|
+
|
9656
|
+
alias matches? ===
|
9336
9657
|
end
|
9337
9658
|
end
|
9338
9659
|
end
|
@@ -9421,9 +9742,13 @@ module ActiveSupport
|
|
9421
9742
|
|
9422
9743
|
def now: () -> untyped
|
9423
9744
|
|
9424
|
-
def now_cpu: () ->
|
9745
|
+
def now_cpu: () -> untyped
|
9746
|
+
|
9747
|
+
def now_cpu: () -> 0
|
9748
|
+
|
9749
|
+
def now_allocations: () -> 0
|
9425
9750
|
|
9426
|
-
def now_allocations: () ->
|
9751
|
+
def now_allocations: () -> untyped
|
9427
9752
|
end
|
9428
9753
|
end
|
9429
9754
|
end
|
@@ -9799,6 +10124,33 @@ module ActiveSupport
|
|
9799
10124
|
end
|
9800
10125
|
end
|
9801
10126
|
|
10127
|
+
module ActiveSupport
|
10128
|
+
module NumberHelper
|
10129
|
+
class RoundingHelper
|
10130
|
+
# :nodoc:
|
10131
|
+
attr_reader options: untyped
|
10132
|
+
|
10133
|
+
def initialize: (untyped options) -> untyped
|
10134
|
+
|
10135
|
+
def round: (untyped number) -> untyped
|
10136
|
+
|
10137
|
+
def digit_count: (untyped number) -> (1 | untyped)
|
10138
|
+
|
10139
|
+
def round_without_significant: (untyped number) -> untyped
|
10140
|
+
|
10141
|
+
def round_significant: (untyped number) -> (0 | untyped)
|
10142
|
+
|
10143
|
+
def convert_to_decimal: (untyped number) -> untyped
|
10144
|
+
|
10145
|
+
def precision: () -> untyped
|
10146
|
+
|
10147
|
+
def significant: () -> untyped
|
10148
|
+
|
10149
|
+
def absolute_number: (untyped number) -> untyped
|
10150
|
+
end
|
10151
|
+
end
|
10152
|
+
end
|
10153
|
+
|
9802
10154
|
module ActiveSupport
|
9803
10155
|
module NumberHelper
|
9804
10156
|
extend ActiveSupport::Autoload
|
@@ -10150,33 +10502,6 @@ module ActiveSupport
|
|
10150
10502
|
end
|
10151
10503
|
end
|
10152
10504
|
|
10153
|
-
module ActiveSupport
|
10154
|
-
module NumberHelper
|
10155
|
-
class RoundingHelper
|
10156
|
-
# :nodoc:
|
10157
|
-
attr_reader options: untyped
|
10158
|
-
|
10159
|
-
def initialize: (untyped options) -> untyped
|
10160
|
-
|
10161
|
-
def round: (untyped number) -> untyped
|
10162
|
-
|
10163
|
-
def digit_count: (untyped number) -> (1 | untyped)
|
10164
|
-
|
10165
|
-
def round_without_significant: (untyped number) -> untyped
|
10166
|
-
|
10167
|
-
def round_significant: (untyped number) -> (0 | untyped)
|
10168
|
-
|
10169
|
-
def convert_to_decimal: (untyped number) -> untyped
|
10170
|
-
|
10171
|
-
def precision: () -> untyped
|
10172
|
-
|
10173
|
-
def significant: () -> untyped
|
10174
|
-
|
10175
|
-
def absolute_number: (untyped number) -> untyped
|
10176
|
-
end
|
10177
|
-
end
|
10178
|
-
end
|
10179
|
-
|
10180
10505
|
module ActiveSupport
|
10181
10506
|
class OptionMerger
|
10182
10507
|
def initialize: (untyped context, untyped options) -> untyped
|
@@ -10243,6 +10568,8 @@ module ActiveSupport
|
|
10243
10568
|
# h.dog! # => raises KeyError: :dog is blank
|
10244
10569
|
#
|
10245
10570
|
class OrderedOptions[T, U] < Hash[T, U]
|
10571
|
+
alias _get []
|
10572
|
+
|
10246
10573
|
def []=: (untyped key, untyped value) -> untyped
|
10247
10574
|
|
10248
10575
|
def []: (untyped key) -> untyped
|
@@ -10389,16 +10716,6 @@ module ActiveSupport
|
|
10389
10716
|
end
|
10390
10717
|
end
|
10391
10718
|
|
10392
|
-
module ActiveSupport
|
10393
|
-
extend ActiveSupport::Autoload
|
10394
|
-
|
10395
|
-
def self.eager_load!: () -> untyped
|
10396
|
-
|
10397
|
-
def self.to_time_preserves_timezone: () -> untyped
|
10398
|
-
|
10399
|
-
def self.to_time_preserves_timezone=: (untyped value) -> untyped
|
10400
|
-
end
|
10401
|
-
|
10402
10719
|
module ActiveSupport
|
10403
10720
|
# -
|
10404
10721
|
# This class defines several callbacks:
|
@@ -10517,7 +10834,7 @@ module ActiveSupport
|
|
10517
10834
|
# end
|
10518
10835
|
#
|
10519
10836
|
# Returns the exception if it was handled and +nil+ if it was not.
|
10520
|
-
def rescue_with_handler: (untyped exception, ?
|
10837
|
+
def rescue_with_handler: (untyped exception, ?object: untyped object, ?visited_exceptions: untyped visited_exceptions) -> untyped
|
10521
10838
|
|
10522
10839
|
def handler_for_rescue: (untyped exception, ?object: untyped object) -> untyped
|
10523
10840
|
|
@@ -10743,7 +11060,7 @@ module ActiveSupport
|
|
10743
11060
|
#
|
10744
11061
|
# The threaded parallelization uses minitest's parallel executor directly.
|
10745
11062
|
# The processes parallelization uses a Ruby DRb server.
|
10746
|
-
def self.parallelize: (?
|
11063
|
+
def self.parallelize: (?workers: ::Symbol workers, ?with: ::Symbol with) -> (nil | untyped)
|
10747
11064
|
|
10748
11065
|
# Set up hook for parallel testing. This can be used if you have multiple
|
10749
11066
|
# databases or any behavior that needs to be run after the process is forked
|
@@ -10775,6 +11092,8 @@ module ActiveSupport
|
|
10775
11092
|
# end
|
10776
11093
|
def self.parallelize_teardown: () { (untyped) -> untyped } -> untyped
|
10777
11094
|
|
11095
|
+
alias method_name name
|
11096
|
+
|
10778
11097
|
include ActiveSupport::Testing::TaggedLogging
|
10779
11098
|
|
10780
11099
|
include ActiveSupport::Testing::Assertions
|
@@ -10786,6 +11105,35 @@ module ActiveSupport
|
|
10786
11105
|
include ActiveSupport::Testing::FileFixtures
|
10787
11106
|
|
10788
11107
|
extend ActiveSupport::Testing::Declarative
|
11108
|
+
|
11109
|
+
# test/unit backwards compatibility methods
|
11110
|
+
alias assert_raise assert_raises
|
11111
|
+
|
11112
|
+
alias assert_not_empty refute_empty
|
11113
|
+
|
11114
|
+
alias assert_not_equal refute_equal
|
11115
|
+
|
11116
|
+
alias assert_not_in_delta refute_in_delta
|
11117
|
+
|
11118
|
+
alias assert_not_in_epsilon refute_in_epsilon
|
11119
|
+
|
11120
|
+
alias assert_not_includes refute_includes
|
11121
|
+
|
11122
|
+
alias assert_not_instance_of refute_instance_of
|
11123
|
+
|
11124
|
+
alias assert_not_kind_of refute_kind_of
|
11125
|
+
|
11126
|
+
alias assert_no_match refute_match
|
11127
|
+
|
11128
|
+
alias assert_not_nil refute_nil
|
11129
|
+
|
11130
|
+
alias assert_not_operator refute_operator
|
11131
|
+
|
11132
|
+
alias assert_not_predicate refute_predicate
|
11133
|
+
|
11134
|
+
alias assert_not_respond_to refute_respond_to
|
11135
|
+
|
11136
|
+
alias assert_not_same refute_same
|
10789
11137
|
end
|
10790
11138
|
end
|
10791
11139
|
|
@@ -10925,7 +11273,7 @@ module ActiveSupport
|
|
10925
11273
|
# assert_changes -> { Status.all_good? }, 'Expected the status to be bad' do
|
10926
11274
|
# post :create, params: { status: { incident: true } }
|
10927
11275
|
# end
|
10928
|
-
def assert_changes: (untyped expression, ?untyped? message, ?
|
11276
|
+
def assert_changes: (untyped expression, ?untyped? message, ?from: untyped from, ?to: untyped to) { () -> untyped } -> untyped
|
10929
11277
|
|
10930
11278
|
# Assertion that the result of evaluating an expression is not changed before
|
10931
11279
|
# and after invoking the passed in block.
|
@@ -11057,13 +11405,13 @@ end
|
|
11057
11405
|
module ActiveSupport
|
11058
11406
|
module Testing
|
11059
11407
|
module MethodCallAssertions
|
11060
|
-
def assert_called: (untyped object, untyped method_name, ?untyped? message, ?
|
11408
|
+
def assert_called: (untyped object, untyped method_name, ?untyped? message, ?times: ::Integer times, ?returns: untyped? returns) { () -> untyped } -> untyped
|
11061
11409
|
|
11062
11410
|
def assert_called_with: (untyped object, untyped method_name, untyped args, ?returns: untyped? returns) { () -> untyped } -> untyped
|
11063
11411
|
|
11064
11412
|
def assert_not_called: (untyped object, untyped method_name, ?untyped? message) { () -> untyped } -> untyped
|
11065
11413
|
|
11066
|
-
def assert_called_on_instance_of: (untyped klass, untyped method_name, ?untyped? message, ?
|
11414
|
+
def assert_called_on_instance_of: (untyped klass, untyped method_name, ?untyped? message, ?times: ::Integer times, ?returns: untyped? returns) { () -> untyped } -> untyped
|
11067
11415
|
|
11068
11416
|
def assert_not_called_on_instance_of: (untyped klass, untyped method_name, ?untyped? message) { () -> untyped } -> untyped
|
11069
11417
|
|
@@ -11175,7 +11523,7 @@ module ActiveSupport
|
|
11175
11523
|
module Testing
|
11176
11524
|
class SimpleStubs
|
11177
11525
|
# :nodoc:
|
11178
|
-
class Stub < ::Struct[
|
11526
|
+
class Stub[T] < ::Struct[T]
|
11179
11527
|
attr_accessor object(): untyped
|
11180
11528
|
|
11181
11529
|
attr_accessor method_name(): untyped
|
@@ -11261,6 +11609,8 @@ module ActiveSupport
|
|
11261
11609
|
# Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
|
11262
11610
|
def travel_back: () -> untyped
|
11263
11611
|
|
11612
|
+
alias unfreeze_time travel_back
|
11613
|
+
|
11264
11614
|
# Calls +travel_to+ with +Time.now+.
|
11265
11615
|
#
|
11266
11616
|
# Time.current # => Sun, 09 Jul 2017 15:34:49 EST -05:00
|
@@ -11339,6 +11689,14 @@ module ActiveSupport
|
|
11339
11689
|
# Returns a <tt>Time</tt> instance of the simultaneous time in the UTC timezone.
|
11340
11690
|
def utc: () -> untyped
|
11341
11691
|
|
11692
|
+
alias comparable_time utc
|
11693
|
+
|
11694
|
+
alias getgm utc
|
11695
|
+
|
11696
|
+
alias getutc utc
|
11697
|
+
|
11698
|
+
alias gmtime utc
|
11699
|
+
|
11342
11700
|
# Returns the underlying TZInfo::TimezonePeriod.
|
11343
11701
|
def period: () -> untyped
|
11344
11702
|
|
@@ -11348,6 +11706,8 @@ module ActiveSupport
|
|
11348
11706
|
# Returns a <tt>Time</tt> instance of the simultaneous time in the system timezone.
|
11349
11707
|
def localtime: (?untyped? utc_offset) -> untyped
|
11350
11708
|
|
11709
|
+
alias getlocal localtime
|
11710
|
+
|
11351
11711
|
# Returns true if the current time is within Daylight Savings Time for the
|
11352
11712
|
# specified time zone.
|
11353
11713
|
#
|
@@ -11356,6 +11716,8 @@ module ActiveSupport
|
|
11356
11716
|
# Time.zone.parse("2012-11-30").dst? # => false
|
11357
11717
|
def dst?: () -> untyped
|
11358
11718
|
|
11719
|
+
alias isdst dst?
|
11720
|
+
|
11359
11721
|
# Returns true if the current time zone is set to UTC.
|
11360
11722
|
#
|
11361
11723
|
# Time.zone = 'UTC' # => 'UTC'
|
@@ -11364,9 +11726,15 @@ module ActiveSupport
|
|
11364
11726
|
# Time.zone.now.utc? # => false
|
11365
11727
|
def utc?: () -> untyped
|
11366
11728
|
|
11729
|
+
alias gmt? utc?
|
11730
|
+
|
11367
11731
|
# Returns the offset from current time to UTC time in seconds.
|
11368
11732
|
def utc_offset: () -> untyped
|
11369
11733
|
|
11734
|
+
alias gmt_offset utc_offset
|
11735
|
+
|
11736
|
+
alias gmtoff utc_offset
|
11737
|
+
|
11370
11738
|
# Returns a formatted string of the offset from UTC, or an alternative
|
11371
11739
|
# string if the time zone is already UTC.
|
11372
11740
|
#
|
@@ -11394,6 +11762,10 @@ module ActiveSupport
|
|
11394
11762
|
# Time.zone.now.xmlschema # => "2014-12-04T11:02:37-05:00"
|
11395
11763
|
def xmlschema: (?::Integer fraction_digits) -> ::String
|
11396
11764
|
|
11765
|
+
alias iso8601 xmlschema
|
11766
|
+
|
11767
|
+
alias rfc3339 xmlschema
|
11768
|
+
|
11397
11769
|
# Coerces time to a string for JSON encoding. The default format is ISO 8601.
|
11398
11770
|
# You can get %Y/%m/%d %H:%M:%S +offset style by setting
|
11399
11771
|
# <tt>ActiveSupport::JSON::Encoding.use_standard_json_time_format</tt>
|
@@ -11424,6 +11796,8 @@ module ActiveSupport
|
|
11424
11796
|
# Time.zone.now.rfc2822 # => "Tue, 01 Jan 2013 04:51:39 +0000"
|
11425
11797
|
def rfc2822: () -> untyped
|
11426
11798
|
|
11799
|
+
alias rfc822 rfc2822
|
11800
|
+
|
11427
11801
|
# Returns a string of the object's date and time.
|
11428
11802
|
# Accepts an optional <tt>format</tt>:
|
11429
11803
|
# * <tt>:default</tt> - default value, mimics Ruby Time#to_s format.
|
@@ -11431,6 +11805,8 @@ module ActiveSupport
|
|
11431
11805
|
# * Any key in <tt>Time::DATE_FORMATS</tt> can be used. See active_support/core_ext/time/conversions.rb.
|
11432
11806
|
def to_s: (?::Symbol format) -> untyped
|
11433
11807
|
|
11808
|
+
alias to_formatted_s to_s
|
11809
|
+
|
11434
11810
|
# Replaces <tt>%Z</tt> directive with +zone before passing to Time#strftime,
|
11435
11811
|
# so that zone information is correct.
|
11436
11812
|
def strftime: (untyped format) -> untyped
|
@@ -11438,6 +11814,10 @@ module ActiveSupport
|
|
11438
11814
|
# Use the time in UTC for comparisons.
|
11439
11815
|
def <=>: (untyped other) -> untyped
|
11440
11816
|
|
11817
|
+
alias before? <
|
11818
|
+
|
11819
|
+
alias after? >
|
11820
|
+
|
11441
11821
|
# Returns true if the current object's time is within the specified
|
11442
11822
|
# +min+ and +max+ time.
|
11443
11823
|
def between?: (untyped min, untyped max) -> untyped
|
@@ -11475,6 +11855,10 @@ module ActiveSupport
|
|
11475
11855
|
# now + 1.day # => Mon, 03 Nov 2014 01:26:28 EST -05:00
|
11476
11856
|
def +: (untyped other) -> untyped
|
11477
11857
|
|
11858
|
+
alias since +
|
11859
|
+
|
11860
|
+
alias in +
|
11861
|
+
|
11478
11862
|
# Subtracts an interval of time and returns a new TimeWithZone object unless
|
11479
11863
|
# the other value `acts_like?` time. Then it will return a Float of the difference
|
11480
11864
|
# between the two times that represents the difference between the current
|
@@ -11581,6 +11965,8 @@ module ActiveSupport
|
|
11581
11965
|
# Time.zone.now.to_i # => 1417709320
|
11582
11966
|
def to_i: () -> untyped
|
11583
11967
|
|
11968
|
+
alias tv_sec to_i
|
11969
|
+
|
11584
11970
|
# Returns the object's date and time as a rational number of seconds
|
11585
11971
|
# since the Epoch (January 1, 1970 00:00 UTC).
|
11586
11972
|
#
|
@@ -11604,6 +11990,8 @@ module ActiveSupport
|
|
11604
11990
|
# Say we're a Time to thwart type checking.
|
11605
11991
|
def is_a?: (untyped klass) -> untyped
|
11606
11992
|
|
11993
|
+
alias kind_of? is_a?
|
11994
|
+
|
11607
11995
|
# An instance of ActiveSupport::TimeWithZone is never blank
|
11608
11996
|
def blank?: () -> ::FalseClass
|
11609
11997
|
|
@@ -11674,6 +12062,8 @@ module ActiveSupport
|
|
11674
12062
|
|
11675
12063
|
def self.find_tzinfo: (untyped name) -> TZInfo::Timezone
|
11676
12064
|
|
12065
|
+
alias self.create self.new
|
12066
|
+
|
11677
12067
|
# Returns a TimeZone instance with the given name, or +nil+ if no
|
11678
12068
|
# such TimeZone instance exists. (This exists to support the use of
|
11679
12069
|
# this class with the +composed_of+ macro.)
|
@@ -12004,6 +12394,8 @@ module ActiveSupport
|
|
12004
12394
|
def on_end_element: (untyped name) -> untyped
|
12005
12395
|
|
12006
12396
|
def on_characters: (untyped string) -> untyped
|
12397
|
+
|
12398
|
+
alias on_cdata_block on_characters
|
12007
12399
|
end
|
12008
12400
|
|
12009
12401
|
attr_accessor document_class: untyped
|
@@ -12064,6 +12456,8 @@ module ActiveSupport
|
|
12064
12456
|
def end_element: (untyped name) -> untyped
|
12065
12457
|
|
12066
12458
|
def characters: (untyped string) -> untyped
|
12459
|
+
|
12460
|
+
alias cdata_block characters
|
12067
12461
|
end
|
12068
12462
|
|
12069
12463
|
attr_accessor document_class: untyped
|
@@ -12072,6 +12466,69 @@ module ActiveSupport
|
|
12072
12466
|
end
|
12073
12467
|
end
|
12074
12468
|
|
12469
|
+
module ActiveSupport
|
12470
|
+
module XmlMini_REXML
|
12471
|
+
CONTENT_KEY: ::String
|
12472
|
+
|
12473
|
+
# Parse an XML Document string or IO into a simple hash.
|
12474
|
+
#
|
12475
|
+
# Same as XmlSimple::xml_in but doesn't shoot itself in the foot,
|
12476
|
+
# and uses the defaults from Active Support.
|
12477
|
+
#
|
12478
|
+
# data::
|
12479
|
+
# XML Document string or IO to parse
|
12480
|
+
def parse: (untyped data) -> untyped
|
12481
|
+
|
12482
|
+
# Convert an XML element and merge into the hash
|
12483
|
+
#
|
12484
|
+
# hash::
|
12485
|
+
# Hash to merge the converted element into.
|
12486
|
+
# element::
|
12487
|
+
# XML element to merge into hash
|
12488
|
+
def merge_element!: (untyped hash, untyped element, untyped depth) -> untyped
|
12489
|
+
|
12490
|
+
# Actually converts an XML document element into a data structure.
|
12491
|
+
#
|
12492
|
+
# element::
|
12493
|
+
# The document element to be collapsed.
|
12494
|
+
def collapse: (untyped element, untyped depth) -> untyped
|
12495
|
+
|
12496
|
+
# Merge all the texts of an element into the hash
|
12497
|
+
#
|
12498
|
+
# hash::
|
12499
|
+
# Hash to add the converted element to.
|
12500
|
+
# element::
|
12501
|
+
# XML element whose texts are to me merged into the hash
|
12502
|
+
def merge_texts!: (untyped hash, untyped element) -> untyped
|
12503
|
+
|
12504
|
+
# Adds a new key/value pair to an existing Hash. If the key to be added
|
12505
|
+
# already exists and the existing value associated with key is not
|
12506
|
+
# an Array, it will be wrapped in an Array. Then the new value is
|
12507
|
+
# appended to that Array.
|
12508
|
+
#
|
12509
|
+
# hash::
|
12510
|
+
# Hash to add key/value pair to.
|
12511
|
+
# key::
|
12512
|
+
# Key to be added.
|
12513
|
+
# value::
|
12514
|
+
# Value to be associated with key.
|
12515
|
+
def merge!: (untyped hash, untyped key, untyped value) -> untyped
|
12516
|
+
|
12517
|
+
# Converts the attributes array of an XML element into a hash.
|
12518
|
+
# Returns an empty Hash if node has no attributes.
|
12519
|
+
#
|
12520
|
+
# element::
|
12521
|
+
# XML element to extract attributes from.
|
12522
|
+
def get_attributes: (untyped element) -> untyped
|
12523
|
+
|
12524
|
+
# Determines if a document element has text content
|
12525
|
+
#
|
12526
|
+
# element::
|
12527
|
+
# XML element to be checked.
|
12528
|
+
def empty_content?: (untyped element) -> untyped
|
12529
|
+
end
|
12530
|
+
end
|
12531
|
+
|
12075
12532
|
module ActiveSupport
|
12076
12533
|
# = XmlMini
|
12077
12534
|
#
|
@@ -12131,66 +12588,13 @@ module ActiveSupport
|
|
12131
12588
|
end
|
12132
12589
|
|
12133
12590
|
module ActiveSupport
|
12134
|
-
|
12135
|
-
CONTENT_KEY: ::String
|
12136
|
-
|
12137
|
-
# Parse an XML Document string or IO into a simple hash.
|
12138
|
-
#
|
12139
|
-
# Same as XmlSimple::xml_in but doesn't shoot itself in the foot,
|
12140
|
-
# and uses the defaults from Active Support.
|
12141
|
-
#
|
12142
|
-
# data::
|
12143
|
-
# XML Document string or IO to parse
|
12144
|
-
def parse: (untyped data) -> untyped
|
12145
|
-
|
12146
|
-
# Convert an XML element and merge into the hash
|
12147
|
-
#
|
12148
|
-
# hash::
|
12149
|
-
# Hash to merge the converted element into.
|
12150
|
-
# element::
|
12151
|
-
# XML element to merge into hash
|
12152
|
-
def merge_element!: (untyped hash, untyped element, untyped depth) -> untyped
|
12153
|
-
|
12154
|
-
# Actually converts an XML document element into a data structure.
|
12155
|
-
#
|
12156
|
-
# element::
|
12157
|
-
# The document element to be collapsed.
|
12158
|
-
def collapse: (untyped element, untyped depth) -> untyped
|
12159
|
-
|
12160
|
-
# Merge all the texts of an element into the hash
|
12161
|
-
#
|
12162
|
-
# hash::
|
12163
|
-
# Hash to add the converted element to.
|
12164
|
-
# element::
|
12165
|
-
# XML element whose texts are to me merged into the hash
|
12166
|
-
def merge_texts!: (untyped hash, untyped element) -> untyped
|
12591
|
+
extend ActiveSupport::Autoload
|
12167
12592
|
|
12168
|
-
|
12169
|
-
# already exists and the existing value associated with key is not
|
12170
|
-
# an Array, it will be wrapped in an Array. Then the new value is
|
12171
|
-
# appended to that Array.
|
12172
|
-
#
|
12173
|
-
# hash::
|
12174
|
-
# Hash to add key/value pair to.
|
12175
|
-
# key::
|
12176
|
-
# Key to be added.
|
12177
|
-
# value::
|
12178
|
-
# Value to be associated with key.
|
12179
|
-
def merge!: (untyped hash, untyped key, untyped value) -> untyped
|
12593
|
+
def self.eager_load!: () -> untyped
|
12180
12594
|
|
12181
|
-
|
12182
|
-
# Returns an empty Hash if node has no attributes.
|
12183
|
-
#
|
12184
|
-
# element::
|
12185
|
-
# XML element to extract attributes from.
|
12186
|
-
def get_attributes: (untyped element) -> untyped
|
12595
|
+
def self.to_time_preserves_timezone: () -> untyped
|
12187
12596
|
|
12188
|
-
|
12189
|
-
#
|
12190
|
-
# element::
|
12191
|
-
# XML element to be checked.
|
12192
|
-
def empty_content?: (untyped element) -> untyped
|
12193
|
-
end
|
12597
|
+
def self.to_time_preserves_timezone=: (untyped value) -> untyped
|
12194
12598
|
end
|
12195
12599
|
|
12196
12600
|
class Object
|
@@ -12203,5 +12607,7 @@ class Object
|
|
12203
12607
|
# # => 0.074
|
12204
12608
|
def self.ms: () { () -> untyped } -> untyped
|
12205
12609
|
|
12610
|
+
alias orig_sum sum
|
12611
|
+
|
12206
12612
|
def unescape: (untyped str, ?untyped escaped) -> untyped
|
12207
12613
|
end
|