|
| 1 | +module ActiveSupport |
| 2 | + module Cache |
| 3 | + module Strategy |
| 4 | + module LocalCache |
| 5 | + module LocalCacheRegistry |
| 6 | + def cache_for: (untyped local_cache_key) -> untyped |
| 7 | + def set_cache_for: (untyped local_cache_key, untyped value) -> untyped |
| 8 | + extend LocalCacheRegistry |
| 9 | + end |
| 10 | + end |
| 11 | + end |
| 12 | + end |
| 13 | + |
| 14 | + module Notifications |
| 15 | + interface _Callable5 |
| 16 | + def call: (String, Time, Time, String, Hash[untyped, untyped]) -> void |
| 17 | + end |
| 18 | + |
| 19 | + interface _Callable1 |
| 20 | + def call: (untyped event) -> void |
| 21 | + end |
| 22 | + |
| 23 | + # Subscribe to a given event name with the passed +block+. |
| 24 | + # |
| 25 | + # You can subscribe to events by passing a String to match exact event |
| 26 | + # names, or by passing a Regexp to match all events that match a pattern. |
| 27 | + # |
| 28 | + # ActiveSupport::Notifications.subscribe(/render/) do |*args| |
| 29 | + # @event = ActiveSupport::Notifications::Event.new(*args) |
| 30 | + # end |
| 31 | + # |
| 32 | + # The +block+ will receive five parameters with information about the event: |
| 33 | + # |
| 34 | + # ActiveSupport::Notifications.subscribe('render') do |name, start, finish, id, payload| |
| 35 | + # name # => String, name of the event (such as 'render' from above) |
| 36 | + # start # => Time, when the instrumented block started execution |
| 37 | + # finish # => Time, when the instrumented block ended execution |
| 38 | + # id # => String, unique ID for the instrumenter that fired the event |
| 39 | + # payload # => Hash, the payload |
| 40 | + # end |
| 41 | + # |
| 42 | + # If the block passed to the method only takes one parameter, |
| 43 | + # it will yield an event object to the block: |
| 44 | + # |
| 45 | + # ActiveSupport::Notifications.subscribe(/render/) do |event| |
| 46 | + # @event = event |
| 47 | + # end |
| 48 | + def self.subscribe: (String | Regexp, _Callable5 | _Callable1) -> Subscriber |
| 49 | + | ... |
| 50 | + end |
| 51 | + |
| 52 | + class TimeWithZone |
| 53 | + # Returns a string of the object's date and time. |
| 54 | + # |
| 55 | + # This method is aliased to <tt>to_formatted_s</tt>. |
| 56 | + # |
| 57 | + # Accepts an optional <tt>format</tt>: |
| 58 | + # * <tt>:default</tt> - default value, mimics Ruby Time#to_s format. |
| 59 | + # * <tt>:db</tt> - format outputs time in UTC :db time. See Time#to_fs(:db). |
| 60 | + # * Any key in +Time::DATE_FORMATS+ can be used. See active_support/core_ext/time/conversions.rb. |
| 61 | + def to_fs: (?Symbol format) -> String |
| 62 | + end |
| 63 | + |
| 64 | + class TimeZone |
| 65 | + # Locate a specific time zone object. If the argument is a string, it |
| 66 | + # is interpreted to mean the name of the timezone to locate. If it is a |
| 67 | + # numeric value it is either the hour offset, or the second offset, of the |
| 68 | + # timezone to find. (The first one with that offset will be returned.) |
| 69 | + # Returns +nil+ if no such time zone is known to the system. |
| 70 | + def self.[]: (instance | TZInfo::Timezone | String | real | Duration) -> instance? |
| 71 | + end |
| 72 | +end |
| 73 | + |
| 74 | +# activesupport/lib/active_support/core_ext/time/zones.rb |
| 75 | +class Time |
| 76 | + # Returns a TimeZone instance matching the time zone provided. |
| 77 | + # Accepts the time zone in any format supported by <tt>Time.zone=</tt>. |
| 78 | + # Raises an +ArgumentError+ for invalid time zones. |
| 79 | + # |
| 80 | + # Time.find_zone! "America/New_York" # => #<ActiveSupport::TimeZone @name="America/New_York" ...> |
| 81 | + # Time.find_zone! "EST" # => #<ActiveSupport::TimeZone @name="EST" ...> |
| 82 | + # Time.find_zone! -5.hours # => #<ActiveSupport::TimeZone @name="Bogota" ...> |
| 83 | + # Time.find_zone! nil # => nil |
| 84 | + # Time.find_zone! false # => false |
| 85 | + # Time.find_zone! "NOT-A-TIMEZONE" # => ArgumentError: Invalid Timezone: NOT-A-TIMEZONE |
| 86 | + def self.find_zone!: (ActiveSupport::TimeZone | TZInfo::Timezone | String | real | ActiveSupport::Duration) -> ActiveSupport::TimeZone |
| 87 | + |
| 88 | + # Returns a TimeZone instance matching the time zone provided. |
| 89 | + # Accepts the time zone in any format supported by <tt>Time.zone=</tt>. |
| 90 | + # Returns +nil+ for invalid time zones. |
| 91 | + # |
| 92 | + # Time.find_zone "America/New_York" # => #<ActiveSupport::TimeZone @name="America/New_York" ...> |
| 93 | + # Time.find_zone "NOT-A-TIMEZONE" # => nil |
| 94 | + def self.find_zone: (ActiveSupport::TimeZone | TZInfo::Timezone | String | real | ActiveSupport::Duration | nil) -> ActiveSupport::TimeZone? |
| 95 | +end |
| 96 | + |
| 97 | +module Enumerable[unchecked out Elem] |
| 98 | + # Returns a new +Array+ without the blank items. |
| 99 | + # Uses Object#blank? for determining if an item is blank. |
| 100 | + # |
| 101 | + # [1, "", nil, 2, " ", [], {}, false, true].compact_blank |
| 102 | + # # => [1, 2, true] |
| 103 | + # |
| 104 | + # Set.new([nil, "", 1, false]).compact_blank |
| 105 | + # # => [1] |
| 106 | + # |
| 107 | + # When called on a +Hash+, returns a new +Hash+ without the blank values. |
| 108 | + # |
| 109 | + # { a: "", b: 1, c: nil, d: [], e: false, f: true }.compact_blank |
| 110 | + # # => { b: 1, f: true } |
| 111 | + def compact_blank: () -> Array[Elem] |
| 112 | +end |
| 113 | + |
| 114 | +class Hash[unchecked out K, unchecked out V] |
| 115 | + # Hash#reject has its own definition, so this needs one too. |
| 116 | + def compact_blank: () -> Hash[K, V] |
| 117 | + |
| 118 | + # Removes all blank values from the +Hash+ in place and returns self. |
| 119 | + # Uses Object#blank? for determining if a value is blank. |
| 120 | + # |
| 121 | + # h = { a: "", b: 1, c: nil, d: [], e: false, f: true } |
| 122 | + # h.compact_blank! |
| 123 | + # # => { b: 1, f: true } |
| 124 | + def compact_blank!: () -> Hash[K, V] |
| 125 | +end |
| 126 | + |
| 127 | +class Array[unchecked out Elem] |
| 128 | + # Removes all blank elements from the +Array+ in place and returns self. |
| 129 | + # Uses Object#blank? for determining if an item is blank. |
| 130 | + # |
| 131 | + # a = [1, "", nil, 2, " ", [], {}, false, true] |
| 132 | + # a.compact_blank! |
| 133 | + # # => [1, 2, true] |
| 134 | + def compact_blank!: () -> Array[Elem] |
| 135 | +end |
| 136 | + |
| 137 | +# active_support/core_ext/string/inflections.rb |
| 138 | +class String |
| 139 | + def downcase_first: () -> String |
| 140 | +end |
0 commit comments