code
stringlengths
26
124k
docstring
stringlengths
23
125k
func_name
stringlengths
1
98
language
stringclasses
1 value
repo
stringlengths
5
53
path
stringlengths
7
151
url
stringlengths
50
211
license
stringclasses
7 values
def read_entry(key, **options) raise NotImplementedError.new end
Reads an entry from the cache implementation. Subclasses must implement this method.
read_entry
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
Apache-2.0
def write_entry(key, entry, **options) raise NotImplementedError.new end
Writes an entry to the cache implementation. Subclasses must implement this method.
write_entry
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
Apache-2.0
def read_multi_entries(names, **options) names.each_with_object({}) do |name, results| key = normalize_key(name, options) entry = read_entry(key, **options) next unless entry version = normalize_version(name, options) if entry.expired? delete_entry(key, **options) elsif !entry.mismatched?(version) results[name] = entry.value end end end
Reads multiple entries from the cache implementation. Subclasses MAY implement this method.
read_multi_entries
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
Apache-2.0
def write_multi_entries(hash, **options) hash.each do |key, entry| write_entry key, entry, **options end end
Writes multiple entries to the cache implementation. Subclasses MAY implement this method.
write_multi_entries
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
Apache-2.0
def delete_entry(key, **options) raise NotImplementedError.new end
Deletes an entry from the cache implementation. Subclasses must implement this method.
delete_entry
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
Apache-2.0
def delete_multi_entries(entries, **options) entries.count { |key| delete_entry(key, **options) } end
Deletes multiples entries in the cache implementation. Subclasses MAY implement this method.
delete_multi_entries
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
Apache-2.0
def merged_options(call_options) if call_options if options.empty? call_options else options.merge(call_options) end else options end end
Merges the default options with ones specific to a method call.
merged_options
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
Apache-2.0
def normalize_key(key, options = nil) namespace_key expanded_key(key), options end
Expands and namespaces the cache key. May be overridden by cache stores to do additional normalization.
normalize_key
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
Apache-2.0
def namespace_key(key, options = nil) options = merged_options(options) namespace = options[:namespace] if namespace.respond_to?(:call) namespace = namespace.call end if key && key.encoding != Encoding::UTF_8 key = key.dup.force_encoding(Encoding::UTF_8) end if namespace "#{namespace}:#{key}" else key end end
Prefix the key with a namespace string: namespace_key 'foo', namespace: 'cache' # => 'cache:foo' With a namespace block: namespace_key 'foo', namespace: -> { 'cache' } # => 'cache:foo'
namespace_key
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
Apache-2.0
def expanded_key(key) return key.cache_key.to_s if key.respond_to?(:cache_key) case key when Array if key.size > 1 key.collect { |element| expanded_key(element) } else expanded_key(key.first) end when Hash key.collect { |k, v| "#{k}=#{v}" }.sort! else key end.to_param end
Expands key to be a consistent string value. Invokes +cache_key+ if object responds to +cache_key+. Otherwise, +to_param+ method will be called. If the key is a Hash, then keys will be sorted alphabetically.
expanded_key
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
Apache-2.0
def initialize(value, compress: true, compress_threshold: DEFAULT_COMPRESS_LIMIT, version: nil, expires_in: nil, **) @value = value @version = version @created_at = Time.now.to_f @expires_in = expires_in && expires_in.to_f compress!(compress_threshold) if compress end
Creates a new cache entry for the specified value. Options supported are +:compress+, +:compress_threshold+, +:version+ and +:expires_in+.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
Apache-2.0
def expired? @expires_in && @created_at + @expires_in <= Time.now.to_f end
Checks if the entry is expired. The +expires_in+ parameter can override the value set when the entry was created.
expired?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
Apache-2.0
def bytesize case value when NilClass 0 when String @value.bytesize else @s ||= Marshal.dump(@value).bytesize end end
Returns the size of the cached value. This could be less than <tt>value.bytesize</tt> if the data is compressed.
bytesize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
Apache-2.0
def dup_value! if @value && !compressed? && !(@value.is_a?(Numeric) || @value == true || @value == false) if @value.is_a?(String) @value = @value.dup else @value = Marshal.load(Marshal.dump(@value)) end end end
Duplicates the value in a class. This is used by cache implementations that don't natively serialize entries to protect against accidental cache modifications.
dup_value!
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/cache.rb
Apache-2.0
def run_callbacks(kind) callbacks = __callbacks[kind.to_sym] if callbacks.empty? yield if block_given? else env = Filters::Environment.new(self, false, nil) next_sequence = callbacks.compile # Common case: no 'around' callbacks defined if next_sequence.final? next_sequence.invoke_before(env) env.value = !env.halted && (!block_given? || yield) next_sequence.invoke_after(env) env.value else invoke_sequence = Proc.new do skipped = nil while true current = next_sequence current.invoke_before(env) if current.final? env.value = !env.halted && (!block_given? || yield) elsif current.skip?(env) (skipped ||= []) << current next_sequence = next_sequence.nested next else next_sequence = next_sequence.nested begin target, block, method, *arguments = current.expand_call_template(env, invoke_sequence) target.send(method, *arguments, &block) ensure next_sequence = current end end current.invoke_after(env) skipped.pop.invoke_after(env) while skipped&.first break env.value end end invoke_sequence.call end end end
Runs the callbacks for the given event. Calls the before and around callbacks in the order they were set, yields the block (if given one), and then runs the after callbacks in reverse order. If the callback chain was halted, returns +false+. Otherwise returns the result of the block, +nil+ if no callbacks have been set, or +true+ if callbacks have been set but no block is given. run_callbacks :save do save end -- As this method is used in many places, and often wraps large portions of user code, it has an additional design goal of minimizing its impact on the visible call stack. An exception from inside a :before or :after callback can be as noisy as it likes -- but when control has passed smoothly through and into the supplied block, we want as little evidence as possible that we were here.
run_callbacks
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
Apache-2.0
def expand(target, value, block) expanded = [@override_target || target, @override_block || block, @method_name] @arguments.each do |arg| case arg when :value then expanded << value when :target then expanded << target when :block then expanded << (block || raise(ArgumentError)) end end expanded end
Return the parts needed to make this call, with the given input values. Returns an array of the form: [target, block, method, *arguments] This array can be used as such: target.send(method, *arguments, &block) The actual invocation is left up to the caller to minimize call stack pollution.
expand
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
Apache-2.0
def make_lambda lambda do |target, value, &block| target, block, method, *arguments = expand(target, value, block) target.send(method, *arguments, &block) end end
Return a lambda that will make this call when given the input values.
make_lambda
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
Apache-2.0
def inverted_lambda lambda do |target, value, &block| target, block, method, *arguments = expand(target, value, block) ! target.send(method, *arguments, &block) end end
Return a lambda that will make this call when given the input values, but then return the boolean inverse of that result.
inverted_lambda
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
Apache-2.0
def __update_callbacks(name) #:nodoc: ([self] + ActiveSupport::DescendantsTracker.descendants(self)).reverse_each do |target| chain = target.get_callbacks name yield target, chain.dup end end
This is used internally to append, prepend and skip callbacks to the CallbackChain.
__update_callbacks
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
Apache-2.0
def skip_callback(name, *filter_list, &block) type, filters, options = normalize_callback_params(filter_list, block) options[:raise] = true unless options.key?(:raise) __update_callbacks(name) do |target, chain| filters.each do |filter| callback = chain.find { |c| c.matches?(type, filter) } if !callback && options[:raise] raise ArgumentError, "#{type.to_s.capitalize} #{name} callback #{filter.inspect} has not been defined" end if callback && (options.key?(:if) || options.key?(:unless)) new_callback = callback.merge_conditional_options(chain, if_option: options[:if], unless_option: options[:unless]) chain.insert(chain.index(callback), new_callback) end chain.delete(callback) end target.set_callbacks name, chain end end
Skip a previously set callback. Like +set_callback+, <tt>:if</tt> or <tt>:unless</tt> options may be passed in order to control when the callback is skipped. class Writer < Person skip_callback :validate, :before, :check_membership, if: -> { age > 18 } end An <tt>ArgumentError</tt> will be raised if the callback has not already been set (unless the <tt>:raise</tt> option is set to <tt>false</tt>).
skip_callback
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
Apache-2.0
def reset_callbacks(name) callbacks = get_callbacks name ActiveSupport::DescendantsTracker.descendants(self).each do |target| chain = target.get_callbacks(name).dup callbacks.each { |c| chain.delete(c) } target.set_callbacks name, chain end set_callbacks(name, callbacks.dup.clear) end
Remove all set callbacks for the given event.
reset_callbacks
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
Apache-2.0
def define_callbacks(*names) options = names.extract_options! names.each do |name| name = name.to_sym ([self] + ActiveSupport::DescendantsTracker.descendants(self)).each do |target| target.set_callbacks name, CallbackChain.new(name, options) end module_eval <<-RUBY, __FILE__, __LINE__ + 1 def _run_#{name}_callbacks(&block) run_callbacks #{name.inspect}, &block end def self._#{name}_callbacks get_callbacks(#{name.inspect}) end def self._#{name}_callbacks=(value) set_callbacks(#{name.inspect}, value) end def _#{name}_callbacks __callbacks[#{name.inspect}] end RUBY end end
Define sets of events in the object life cycle that support callbacks. define_callbacks :validate define_callbacks :initialize, :save, :destroy ===== Options * <tt>:terminator</tt> - Determines when a before filter will halt the callback chain, preventing following before and around callbacks from being called and the event from being triggered. This should be a lambda to be executed. The current object and the result lambda of the callback will be provided to the terminator lambda. define_callbacks :validate, terminator: ->(target, result_lambda) { result_lambda.call == false } In this example, if any before validate callbacks returns +false+, any successive before and around callback is not executed. The default terminator halts the chain when a callback throws +:abort+. * <tt>:skip_after_callbacks_if_terminated</tt> - Determines if after callbacks should be terminated by the <tt>:terminator</tt> option. By default after callbacks are executed no matter if callback chain was terminated or not. This option has no effect if <tt>:terminator</tt> option is set to +nil+. * <tt>:scope</tt> - Indicates which methods should be executed when an object is used as a callback. class Audit def before(caller) puts 'Audit: before is called' end def before_save(caller) puts 'Audit: before_save is called' end end class Account include ActiveSupport::Callbacks define_callbacks :save set_callback :save, :before, Audit.new def save run_callbacks :save do puts 'save in main' end end end In the above case whenever you save an account the method <tt>Audit#before</tt> will be called. On the other hand define_callbacks :save, scope: [:kind, :name] would trigger <tt>Audit#before_save</tt> instead. That's constructed by calling <tt>#{kind}_#{name}</tt> on the given instance. In this case "kind" is "before" and "name" is "save". In this context +:kind+ and +:name+ have special meanings: +:kind+ refers to the kind of callback (before/after/around) and +:name+ refers to the method on which callbacks are being defined. A declaration like define_callbacks :save, scope: [:name] would call <tt>Audit#save</tt>. ===== Notes +names+ passed to +define_callbacks+ must not end with <tt>!</tt>, <tt>?</tt> or <tt>=</tt>. Calling +define_callbacks+ multiple times with the same +names+ will overwrite previous callbacks registered with +set_callback+.
define_callbacks
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb
Apache-2.0
def included(base = nil, &block) if base.nil? if instance_variable_defined?(:@_included_block) if @_included_block.source_location != block.source_location raise MultipleIncludedBlocks end else @_included_block = block end else super end end
Evaluate given block in context of base class, so that you can write class macros here. When you define more than one +included+ block, it raises an exception.
included
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/concern.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/concern.rb
Apache-2.0
def prepended(base = nil, &block) if base.nil? if instance_variable_defined?(:@_prepended_block) if @_prepended_block.source_location != block.source_location raise MultiplePrependBlocks end else @_prepended_block = block end else super end end
Evaluate given block in context of base class, so that you can write class macros here. When you define more than one +prepended+ block, it raises an exception.
prepended
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/concern.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/concern.rb
Apache-2.0
def class_methods(&class_methods_module_definition) mod = const_defined?(:ClassMethods, false) ? const_get(:ClassMethods) : const_set(:ClassMethods, Module.new) mod.module_eval(&class_methods_module_definition) end
Define class methods from given block. You can define private class methods as well. module Example extend ActiveSupport::Concern class_methods do def foo; puts 'foo'; end private def bar; puts 'bar'; end end end class Buzz include Example end Buzz.foo # => "foo" Buzz.bar # => private method 'bar' called for Buzz:Class(NoMethodError)
class_methods
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/concern.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/concern.rb
Apache-2.0
def config @_config ||= self.class.config.inheritable_copy end
Reads and writes attributes from a configuration <tt>OrderedOptions</tt>. require "active_support/configurable" class User include ActiveSupport::Configurable end user = User.new user.config.allowed_access = true user.config.level = 1 user.config.allowed_access # => true user.config.level # => 1
config
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/configurable.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/configurable.rb
Apache-2.0
def instance current_instances[current_instances_key] ||= new end
Returns singleton instance for this class in this thread. If none exists, one is created.
instance
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/current_attributes.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/current_attributes.rb
Apache-2.0
def attribute(*names) generated_attribute_methods.module_eval do names.each do |name| define_method(name) do attributes[name.to_sym] end define_method("#{name}=") do |attribute| attributes[name.to_sym] = attribute end end end names.each do |name| define_singleton_method(name) do instance.public_send(name) end define_singleton_method("#{name}=") do |attribute| instance.public_send("#{name}=", attribute) end end end
Declares one or more attributes that will be given both class and instance accessor methods.
attribute
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/current_attributes.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/current_attributes.rb
Apache-2.0
def before_reset(&block) set_callback :reset, :before, &block end
Calls this block before #reset is called on the instance. Used for resetting external collaborators that depend on current values.
before_reset
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/current_attributes.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/current_attributes.rb
Apache-2.0
def resets(&block) set_callback :reset, :after, &block end
Calls this block after #reset is called on the instance. Used for resetting external collaborators, like Time.zone.
resets
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/current_attributes.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/current_attributes.rb
Apache-2.0
def set(set_attributes) old_attributes = compute_attributes(set_attributes.keys) assign_attributes(set_attributes) yield ensure assign_attributes(old_attributes) end
Expose one or more attributes within a block. Old values are returned after the block concludes. Example demonstrating the common use of needing to set Current attributes outside the request-cycle: class Chat::PublicationJob < ApplicationJob def perform(attributes, room_number, creator) Current.set(person: creator) do Chat::Publisher.publish(attributes: attributes, room_number: room_number) end end end
set
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/current_attributes.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/current_attributes.rb
Apache-2.0
def reset run_callbacks :reset do self.attributes = {} end end
Reset all attributes. Should be called before and after actions, when used as a per-request singleton.
reset
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/current_attributes.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/current_attributes.rb
Apache-2.0
def new_constants constants = [] # Grab the list of namespaces that we're looking for new constants under @watching.last.each do |namespace| # Retrieve the constants that were present under the namespace when watch_namespaces # was originally called original_constants = @stack[namespace].last mod = Inflector.constantize(namespace) if Dependencies.qualified_const_defined?(namespace) next unless mod.is_a?(Module) # Get a list of the constants that were added new_constants = mod.constants(false) - original_constants # @stack[namespace] returns an Array of the constants that are being evaluated # for that namespace. For instance, if parent.rb requires child.rb, the first # element of @stack[Object] will be an Array of the constants that were present # before parent.rb was required. The second element will be an Array of the # constants that were present before child.rb was required. @stack[namespace].each do |namespace_constants| namespace_constants.concat(new_constants) end # Normalize the list of new constants, and add them to the list we will return new_constants.each do |suffix| constants << ([namespace, suffix] - ["Object"]).join("::") end end constants ensure # A call to new_constants is always called after a call to watch_namespaces pop_modules(@watching.pop) end
Returns a list of new constants found since the last call to <tt>watch_namespaces</tt>.
new_constants
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def watch_namespaces(namespaces) @watching << namespaces.map do |namespace| module_name = Dependencies.to_constant_name(namespace) original_constants = Dependencies.qualified_const_defined?(module_name) ? Inflector.constantize(module_name).constants(false) : [] @stack[module_name] << original_constants module_name end end
Add a set of modules to the watch stack, remembering the initial constants.
watch_namespaces
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def guess_for_anonymous(const_name) if Object.const_defined?(const_name) raise NameError.new "#{const_name} cannot be autoloaded from an anonymous class or module", const_name else Object end end
We assume that the name of the module reflects the nesting (unless it can be proven that is not the case) and the path to the file that defines the constant. Anonymous modules cannot follow these conventions and therefore we assume that the user wants to refer to a top-level constant.
guess_for_anonymous
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def require_dependency(file_name, message = "No such file to load -- %s.rb") file_name = file_name.to_path if file_name.respond_to?(:to_path) unless file_name.is_a?(String) raise ArgumentError, "the file name must either be a String or implement #to_path -- you passed #{file_name.inspect}" end Dependencies.depend_on(file_name, message) end
:doc: <b>Warning:</b> This method is obsolete in +:zeitwerk+ mode. In +:zeitwerk+ mode semantics match Ruby's and you do not need to be defensive with load order. Just refer to classes and modules normally. If the constant name is dynamic, camelize if needed, and constantize. In +:classic+ mode, interprets a file using +mechanism+ and marks its defined constants as autoloaded. +file_name+ can be either a string or respond to <tt>to_path</tt>. In +:classic+ mode, use this method in code that absolutely needs a certain constant to be defined at that point. A typical use case is to make constant name resolution deterministic for constants with the same relative name in different namespaces whose evaluation would depend on load order otherwise. Engines that do not control the mode in which their parent application runs should call +require_dependency+ where needed in case the runtime mode is +:classic+.
require_dependency
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def unloadable(const_desc) Dependencies.mark_for_unload const_desc end
Mark the given constant as unloadable. Unloadable constants are removed each time dependencies are cleared. Note that marking a constant for unloading need only be done once. Setup or init scripts may list each unloadable constant that may need unloading; each constant will be removed for every subsequent clear, as opposed to for the first clear. The provided constant descriptor may be a (non-anonymous) module or class, or a qualified constant name as a string or symbol. Returns +true+ if the constant was not previously marked for unloading, +false+ otherwise.
unloadable
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def qualified_const_defined?(path) Object.const_defined?(path, false) end
Is the provided constant path defined?
qualified_const_defined?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def loadable_constants_for_path(path, bases = autoload_paths) path = path.chomp(".rb") expanded_path = File.expand_path(path) paths = [] bases.each do |root| expanded_root = File.expand_path(root) next unless expanded_path.start_with?(expanded_root) root_size = expanded_root.size next if expanded_path[root_size] != ?/ nesting = expanded_path[(root_size + 1)..-1] paths << nesting.camelize unless nesting.blank? end paths.uniq! paths end
Given +path+, a filesystem path to a ruby file, return an array of constant paths which would cause Dependencies to attempt to load this file.
loadable_constants_for_path
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def search_for_file(path_suffix) path_suffix += ".rb" unless path_suffix.end_with?(".rb") autoload_paths.each do |root| path = File.join(root, path_suffix) return path if File.file? path end nil # Gee, I sure wish we had first_match ;-) end
Search for a file in autoload_paths matching the provided suffix.
search_for_file
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def autoloadable_module?(path_suffix) autoload_paths.each do |load_path| return load_path if File.directory? File.join(load_path, path_suffix) end nil end
Does the provided path_suffix correspond to an autoloadable module? Instead of returning a boolean, the autoload base for this module is returned.
autoloadable_module?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def autoload_module!(into, const_name, qualified_name, path_suffix) return nil unless base_path = autoloadable_module?(path_suffix) mod = Module.new into.const_set const_name, mod log("constant #{qualified_name} autoloaded (module autovivified from #{File.join(base_path, path_suffix)})") autoloaded_constants << qualified_name unless autoload_once_paths.include?(base_path) autoloaded_constants.uniq! mod end
Attempt to autoload the provided module name by searching for a directory matching the expected path suffix. If found, the module is created and assigned to +into+'s constants with the name +const_name+. Provided that the directory was loaded from a reloadable base path, it is added to the set of constants that are to be unloaded.
autoload_module!
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def load_file(path, const_paths = loadable_constants_for_path(path)) const_paths = [const_paths].compact unless const_paths.is_a? Array parent_paths = const_paths.collect { |const_path| const_path[/.*(?=::)/] || ::Object } result = nil newly_defined_paths = new_constants_in(*parent_paths) do result = Kernel.load path end autoloaded_constants.concat newly_defined_paths unless load_once_path?(path) autoloaded_constants.uniq! result end
Load the file at the provided path. +const_paths+ is a set of qualified constant names. When loading the file, Dependencies will watch for the addition of these constants. Each that is defined will be marked as autoloaded, and will be removed when Dependencies.clear is next called. If the second parameter is left off, then Dependencies will construct a set of names that the file at +path+ may define. See +loadable_constants_for_path+ for more details.
load_file
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def qualified_name_for(mod, name) mod_name = to_constant_name mod mod_name == "Object" ? name.to_s : "#{mod_name}::#{name}" end
Returns the constant path for the provided parent and constant name.
qualified_name_for
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def load_missing_constant(from_mod, const_name) from_mod_name = real_mod_name(from_mod) unless qualified_const_defined?(from_mod_name) && Inflector.constantize(from_mod_name).equal?(from_mod) raise ArgumentError, "A copy of #{from_mod} has been removed from the module tree but is still active!" end qualified_name = qualified_name_for(from_mod, const_name) path_suffix = qualified_name.underscore file_path = search_for_file(path_suffix) if file_path expanded = File.expand_path(file_path) expanded.delete_suffix!(".rb") if loading.include?(expanded) raise "Circular dependency detected while autoloading constant #{qualified_name}" else require_or_load(expanded, qualified_name) if from_mod.const_defined?(const_name, false) log("constant #{qualified_name} autoloaded from #{expanded}.rb") return from_mod.const_get(const_name) else raise LoadError, "Unable to autoload constant #{qualified_name}, expected #{file_path} to define it" end end elsif mod = autoload_module!(from_mod, const_name, qualified_name, path_suffix) return mod elsif (parent = from_mod.module_parent) && parent != from_mod && ! from_mod.module_parents.any? { |p| p.const_defined?(const_name, false) } # If our parents do not have a constant named +const_name+ then we are free # to attempt to load upwards. If they do have such a constant, then this # const_missing must be due to from_mod::const_name, which should not # return constants from from_mod's parents. begin # Since Ruby does not pass the nesting at the point the unknown # constant triggered the callback we cannot fully emulate constant # name lookup and need to make a trade-off: we are going to assume # that the nesting in the body of Foo::Bar is [Foo::Bar, Foo] even # though it might not be. Counterexamples are # # class Foo::Bar # Module.nesting # => [Foo::Bar] # end # # or # # module M::N # module S::T # Module.nesting # => [S::T, M::N] # end # end # # for example. return parent.const_missing(const_name) rescue NameError => e raise unless e.missing_name? qualified_name_for(parent, const_name) end end name_error = uninitialized_constant(qualified_name, const_name, receiver: from_mod) name_error.set_backtrace(caller.reject { |l| l.start_with? __FILE__ }) raise name_error end
Load the constant named +const_name+ which is missing from +from_mod+. If it is not possible to load the constant into from_mod, try its parent module using +const_missing+.
load_missing_constant
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def remove_unloadable_constants! log("removing unloadable constants") autoloaded_constants.each { |const| remove_constant const } autoloaded_constants.clear Reference.clear! explicitly_unloadable_constants.each { |const| remove_constant const } end
Remove the constants that have been autoloaded, and those that have been marked for unloading. Before each constant is removed a callback is sent to its class/module if it implements +before_remove_const+. The callback implementation should be restricted to cleaning up caches, etc. as the environment will be in an inconsistent state, e.g. other constants may have already been unloaded and not accessible.
remove_unloadable_constants!
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def autoloaded?(desc) return false if desc.is_a?(Module) && real_mod_name(desc).nil? name = to_constant_name desc return false unless qualified_const_defined?(name) autoloaded_constants.include?(name) end
Determine if the given constant has been automatically loaded.
autoloaded?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def will_unload?(const_desc) autoloaded?(const_desc) || explicitly_unloadable_constants.include?(to_constant_name(const_desc)) end
Will the provided constant descriptor be unloaded?
will_unload?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def mark_for_unload(const_desc) name = to_constant_name const_desc if explicitly_unloadable_constants.include? name false else explicitly_unloadable_constants << name true end end
Mark the provided constant name for unloading. This constant will be unloaded on each request, not just the next one.
mark_for_unload
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def new_constants_in(*descs) constant_watch_stack.watch_namespaces(descs) success = false begin yield # Now yield to the code that is to define new constants. success = true ensure new_constants = constant_watch_stack.new_constants return new_constants if success # Remove partially loaded constants. new_constants.each { |c| remove_constant(c) } end end
Run the provided block and detect the new constants that were loaded during its execution. Constants may only be regarded as 'new' once -- so if the block calls +new_constants_in+ again, then the constants defined within the inner call will not be reported in this one. If the provided block does not run to completion, and instead raises an exception, any new constants are regarded as being only partially defined and will be removed immediately.
new_constants_in
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def to_constant_name(desc) #:nodoc: case desc when String then desc.delete_prefix("::") when Symbol then desc.to_s when Module real_mod_name(desc) || raise(ArgumentError, "Anonymous modules have no name to be referenced by") else raise TypeError, "Not a valid constant descriptor: #{desc.inspect}" end end
Convert the provided const desc to a qualified constant name (as a string). A module, class, symbol, or string may be provided.
to_constant_name
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb
Apache-2.0
def initialize(deprecation_horizon = "7.0", gem_name = "Rails") self.gem_name = gem_name self.deprecation_horizon = deprecation_horizon # By default, warnings are not silenced and debugging is off. self.silenced = false self.debug = false @silenced_thread = Concurrent::ThreadLocalVar.new(false) @explicitly_allowed_warnings = Concurrent::ThreadLocalVar.new(nil) end
It accepts two parameters on initialization. The first is a version of library and the second is a library name. ActiveSupport::Deprecation.new('2.0', 'MyLibrary')
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/deprecation.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/deprecation.rb
Apache-2.0
def store_inherited(klass, descendant) (@@direct_descendants[klass] ||= DescendantsArray.new) << descendant end
This is the only method that is not thread safe, but is only ever called during the eager loading phase.
store_inherited
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/descendants_tracker.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/descendants_tracker.rb
Apache-2.0
def parse(iso8601duration) parts = ISO8601Parser.new(iso8601duration).parse! new(calculate_total_seconds(parts), parts) end
Creates a new Duration from string formatted according to ISO 8601 Duration. See {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601#Durations] for more information. This method allows negative parts to be present in pattern. If invalid string is provided, it will raise +ActiveSupport::Duration::ISO8601Parser::ParsingError+.
parse
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
Apache-2.0
def build(value) unless value.is_a?(::Numeric) raise TypeError, "can't build an #{self.name} from a #{value.class.name}" end parts = {} remainder_sign = value <=> 0 remainder = value.round(9).abs PARTS.each do |part| unless part == :seconds part_in_seconds = PARTS_IN_SECONDS[part] parts[part] = remainder.div(part_in_seconds) * remainder_sign remainder %= part_in_seconds end end unless value == 0 parts[:seconds] = remainder * remainder_sign new(value, parts) end
Creates a new Duration from a seconds value that is converted to the individual parts: ActiveSupport::Duration.build(31556952).parts # => {:years=>1} ActiveSupport::Duration.build(2716146).parts # => {:months=>1, :days=>1}
build
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
Apache-2.0
def in_minutes in_seconds / SECONDS_PER_MINUTE.to_f end
Returns the amount of minutes a duration covers as a float 1.day.in_minutes # => 1440.0
in_minutes
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
Apache-2.0
def in_hours in_seconds / SECONDS_PER_HOUR.to_f end
Returns the amount of hours a duration covers as a float 1.day.in_hours # => 24.0
in_hours
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
Apache-2.0
def in_days in_seconds / SECONDS_PER_DAY.to_f end
Returns the amount of days a duration covers as a float 12.hours.in_days # => 0.5
in_days
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
Apache-2.0
def in_weeks in_seconds / SECONDS_PER_WEEK.to_f end
Returns the amount of weeks a duration covers as a float 2.months.in_weeks # => 8.696
in_weeks
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
Apache-2.0
def in_months in_seconds / SECONDS_PER_MONTH.to_f end
Returns the amount of months a duration covers as a float 9.weeks.in_months # => 2.07
in_months
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
Apache-2.0
def in_years in_seconds / SECONDS_PER_YEAR.to_f end
Returns the amount of years a duration covers as a float 30.days.in_years # => 0.082
in_years
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
Apache-2.0
def eql?(other) Duration === other && other.value.eql?(value) end
Returns +true+ if +other+ is also a Duration instance, which has the same parts as this one.
eql?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
Apache-2.0
def since(time = ::Time.current) sum(1, time) end
Calculates a new Time or Date that is as far in the future as this Duration represents.
since
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
Apache-2.0
def ago(time = ::Time.current) sum(-1, time) end
Calculates a new Time or Date that is as far in the past as this Duration represents.
ago
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/duration.rb
Apache-2.0
def read super rescue ActiveSupport::EncryptedFile::MissingContentError "" end
Allow a config to be started without a file present
read
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/encrypted_configuration.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/encrypted_configuration.rb
Apache-2.0
def complete! run_callbacks(:complete) ensure self.class.active.delete Thread.current end
Complete this in-flight execution. This method *must* be called exactly once on the result of any call to +run!+. Where possible, prefer +wrap+.
complete!
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/execution_wrapper.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/execution_wrapper.rb
Apache-2.0
def initialize(files, dirs = {}, &block) unless block raise ArgumentError, "A block is required to initialize a FileUpdateChecker" end @files = files.freeze @glob = compile_glob(dirs) @block = block @watched = nil @updated_at = nil @last_watched = watched @last_update_at = updated_at(@last_watched) end
It accepts two parameters on initialization. The first is an array of files and the second is an optional hash of directories. The hash must have directories as keys and the value is an array of extensions to be watched under that directory. This method must also receive a block that will be called once a path changes. The array of files and list of directories cannot be changed after FileUpdateChecker has been initialized.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/file_update_checker.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/file_update_checker.rb
Apache-2.0
def updated? current_watched = watched if @last_watched.size != current_watched.size @watched = current_watched true else current_updated_at = updated_at(current_watched) if @last_update_at < current_updated_at @watched = current_watched @updated_at = current_updated_at true else false end end end
Check if any of the entries were updated. If so, the watched and/or updated_at values are cached until the block is executed via +execute+ or +execute_if_updated+.
updated?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/file_update_checker.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/file_update_checker.rb
Apache-2.0
def execute @last_watched = watched @last_update_at = updated_at(@last_watched) @block.call ensure @watched = nil @updated_at = nil end
Executes the given block and updates the latest watched files and timestamp.
execute
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/file_update_checker.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/file_update_checker.rb
Apache-2.0
def execute_if_updated if updated? yield if block_given? execute true else false end end
Execute the block given if updated.
execute_if_updated
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/file_update_checker.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/file_update_checker.rb
Apache-2.0
def max_mtime(paths) time_now = Time.now max_mtime = nil # Time comparisons are performed with #compare_without_coercion because # AS redefines these operators in a way that is much slower and does not # bring any benefit in this particular code. # # Read t1.compare_without_coercion(t2) < 0 as t1 < t2. paths.each do |path| mtime = File.mtime(path) next if time_now.compare_without_coercion(mtime) < 0 if max_mtime.nil? || max_mtime.compare_without_coercion(mtime) < 0 max_mtime = mtime end end max_mtime end
This method returns the maximum mtime of the files in +paths+, or +nil+ if the array is empty. Files with a mtime in the future are ignored. Such abnormal situation can happen for example if the user changes the clock by hand. It is healthy to consider this edge case because with mtimes in the future reloading is not triggered.
max_mtime
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/file_update_checker.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/file_update_checker.rb
Apache-2.0
def update(*other_hashes, &block) if other_hashes.size == 1 update_with_single_argument(other_hashes.first, block) else other_hashes.each do |other_hash| update_with_single_argument(other_hash, block) end end self end
Updates the receiver in-place, merging in the hashes passed as arguments: hash_1 = ActiveSupport::HashWithIndifferentAccess.new hash_1[:key] = 'value' hash_2 = ActiveSupport::HashWithIndifferentAccess.new hash_2[:key] = 'New Value!' hash_1.update(hash_2) # => {"key"=>"New Value!"} hash = ActiveSupport::HashWithIndifferentAccess.new hash.update({ "a" => 1 }, { "b" => 2 }) # => { "a" => 1, "b" => 2 } The arguments can be either an <tt>ActiveSupport::HashWithIndifferentAccess</tt> or a regular +Hash+. In either case the merge respects the semantics of indifferent access. If the argument is a regular hash with keys +:key+ and <tt>"key"</tt> only one of the values end up in the receiver, but which one is unspecified. When given a block, the value for duplicated keys will be determined by the result of invoking the block with the duplicated key, the value in the receiver, and the value in +other_hash+. The rules for duplicated keys follow the semantics of indifferent access: hash_1[:key] = 10 hash_2['key'] = 12 hash_1.update(hash_2) { |key, old, new| old + new } # => {"key"=>22}
update
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
Apache-2.0
def fetch(key, *extras) super(convert_key(key), *extras) end
Same as <tt>Hash#fetch</tt> where the key passed as argument can be either a string or a symbol: counters = ActiveSupport::HashWithIndifferentAccess.new counters[:foo] = 1 counters.fetch('foo') # => 1 counters.fetch(:bar, 0) # => 0 counters.fetch(:bar) { |key| 0 } # => 0 counters.fetch(:zoo) # => KeyError: key not found: "zoo"
fetch
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
Apache-2.0
def dig(*args) args[0] = convert_key(args[0]) if args.size > 0 super(*args) end
Same as <tt>Hash#dig</tt> where the key passed as argument can be either a string or a symbol: counters = ActiveSupport::HashWithIndifferentAccess.new counters[:foo] = { bar: 1 } counters.dig('foo', 'bar') # => 1 counters.dig(:foo, :bar) # => 1 counters.dig(:zoo) # => nil
dig
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
Apache-2.0
def default(*args) super(*args.map { |arg| convert_key(arg) }) end
Same as <tt>Hash#default</tt> where the key passed as argument can be either a string or a symbol: hash = ActiveSupport::HashWithIndifferentAccess.new(1) hash.default # => 1 hash = ActiveSupport::HashWithIndifferentAccess.new { |hash, key| key } hash.default # => nil hash.default('foo') # => 'foo' hash.default(:foo) # => 'foo'
default
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
Apache-2.0
def values_at(*keys) super(*keys.map { |key| convert_key(key) }) end
Returns an array of the values at the specified indices: hash = ActiveSupport::HashWithIndifferentAccess.new hash[:a] = 'x' hash[:b] = 'y' hash.values_at('a', 'b') # => ["x", "y"]
values_at
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
Apache-2.0
def fetch_values(*indices, &block) super(*indices.map { |key| convert_key(key) }, &block) end
Returns an array of the values at the specified indices, but also raises an exception when one of the keys can't be found. hash = ActiveSupport::HashWithIndifferentAccess.new hash[:a] = 'x' hash[:b] = 'y' hash.fetch_values('a', 'b') # => ["x", "y"] hash.fetch_values('a', 'c') { |key| 'z' } # => ["x", "z"] hash.fetch_values('a', 'c') # => KeyError: key not found: "c"
fetch_values
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
Apache-2.0
def dup self.class.new(self).tap do |new_hash| set_defaults(new_hash) end end
Returns a shallow copy of the hash. hash = ActiveSupport::HashWithIndifferentAccess.new({ a: { b: 'b' } }) dup = hash.dup dup[:a][:c] = 'c' hash[:a][:c] # => "c" dup[:a][:c] # => "c"
dup
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
Apache-2.0
def merge(*hashes, &block) dup.update(*hashes, &block) end
This method has the same semantics of +update+, except it does not modify the receiver but rather returns a new hash with indifferent access with the result of the merge.
merge
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
Apache-2.0
def except(*keys) slice(*self.keys - keys.map { |key| convert_key(key) }) end
Returns a hash with indifferent access that includes everything except given keys. hash = { a: "x", b: "y", c: 10 }.with_indifferent_access hash.except(:a, "b") # => {c: 10}.with_indifferent_access hash # => { a: "x", b: "y", c: 10 }.with_indifferent_access
except
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
Apache-2.0
def to_hash _new_hash = Hash.new set_defaults(_new_hash) each do |key, value| _new_hash[key] = convert_value(value, conversion: :to_hash) end _new_hash end
Convert to a regular hash with string keys.
to_hash
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/hash_with_indifferent_access.rb
Apache-2.0
def generate_key(salt, key_size = 64) OpenSSL::PKCS5.pbkdf2_hmac_sha1(@secret, salt, @iterations, key_size) end
Returns a derived key suitable for use. The default key_size is chosen to be compatible with the default settings of ActiveSupport::MessageVerifier. i.e. OpenSSL::Digest::SHA1#block_length
generate_key
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/key_generator.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/key_generator.rb
Apache-2.0
def generate_key(*args) @cache_keys[args.join("|")] ||= @key_generator.generate_key(*args) end
Returns a derived key suitable for use.
generate_key
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/key_generator.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/key_generator.rb
Apache-2.0
def on_load(name, options = {}, &block) @loaded[name].each do |base| execute_hook(name, base, options, block) end @load_hooks[name] << [block, options] end
Declares a block that will be executed when a Rails component is fully loaded. Options: * <tt>:yield</tt> - Yields the object that run_load_hooks to +block+. * <tt>:run_once</tt> - Given +block+ will run only once.
on_load
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/lazy_load_hooks.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/lazy_load_hooks.rb
Apache-2.0
def call(severity, timestamp, progname, msg) "#{String === msg ? msg : msg.inspect}\n" end
This method is invoked when a log event occurs
call
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/logger.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/logger.rb
Apache-2.0
def silence(severity = Logger::ERROR) silencer ? log_at(severity) { yield self } : yield(self) end
Silences the logger for the duration of the block.
silence
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/logger_silence.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/logger_silence.rb
Apache-2.0
def log_at(level) old_local_level, self.local_level = local_level, level yield ensure self.local_level = old_local_level end
Change the thread-local level for the duration of the given block.
log_at
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/logger_thread_safe_level.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/logger_thread_safe_level.rb
Apache-2.0
def add(severity, message = nil, progname = nil, &block) #:nodoc: severity ||= UNKNOWN progname ||= @progname return true if @logdev.nil? || severity < level if message.nil? if block_given? message = yield else message = progname progname = @progname end end @logdev.write \ format_message(format_severity(severity), Time.now, progname, message) end
Redefined to check severity against #level, and thus the thread-local level, rather than +@level+. FIXME: Remove when the minimum Ruby version supports overriding Logger#level.
add
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/logger_thread_safe_level.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/logger_thread_safe_level.rb
Apache-2.0
def color(text, color, bold = false) # :doc: return text unless colorize_logging color = self.class.const_get(color.upcase) if color.is_a?(Symbol) bold = bold ? BOLD : "" "#{bold}#{color}#{text}#{CLEAR}" end
Set color by using a symbol or one of the defined constants. If a third option is set to +true+, it also adds bold to the string. This is based on the Highline implementation and will automatically append CLEAR to the end of the returned String.
color
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/log_subscriber.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/log_subscriber.rb
Apache-2.0
def initialize(secret, sign_secret = nil, cipher: nil, digest: nil, serializer: nil) @secret = secret @sign_secret = sign_secret @cipher = cipher || self.class.default_cipher @digest = digest || "SHA1" unless aead_mode? @verifier = resolve_verifier @serializer = serializer || Marshal end
Initialize a new MessageEncryptor. +secret+ must be at least as long as the cipher key size. For the default 'aes-256-gcm' cipher, this is 256 bits. If you are using a user-entered secret, you can generate a suitable key by using <tt>ActiveSupport::KeyGenerator</tt> or a similar key derivation function. First additional parameter is used as the signature key for +MessageVerifier+. This allows you to specify keys to encrypt and sign data. ActiveSupport::MessageEncryptor.new('secret', 'signature_secret') Options: * <tt>:cipher</tt> - Cipher to use. Can be any cipher returned by <tt>OpenSSL::Cipher.ciphers</tt>. Default is 'aes-256-gcm'. * <tt>:digest</tt> - String of digest to use for signing. Default is +SHA1+. Ignored when using an AEAD cipher like 'aes-256-gcm'. * <tt>:serializer</tt> - Object serializer to use. Default is +Marshal+.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/message_encryptor.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/message_encryptor.rb
Apache-2.0
def valid_message?(signed_message) return if signed_message.nil? || !signed_message.valid_encoding? || signed_message.blank? data, digest = signed_message.split("--") data.present? && digest.present? && ActiveSupport::SecurityUtils.secure_compare(digest, generate_digest(data)) end
Checks if a signed message could have been generated by signing an object with the +MessageVerifier+'s secret. verifier = ActiveSupport::MessageVerifier.new 's3Krit' signed_message = verifier.generate 'a private message' verifier.valid_message?(signed_message) # => true tampered_message = signed_message.chop # editing the message invalidates the signature verifier.valid_message?(tampered_message) # => false
valid_message?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/message_verifier.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/message_verifier.rb
Apache-2.0
def verified(signed_message, purpose: nil, **) if valid_message?(signed_message) begin data = signed_message.split("--")[0] message = Messages::Metadata.verify(decode(data), purpose) @serializer.load(message) if message rescue ArgumentError => argument_error return if argument_error.message.include?("invalid base64") raise end end end
Decodes the signed message using the +MessageVerifier+'s secret. verifier = ActiveSupport::MessageVerifier.new 's3Krit' signed_message = verifier.generate 'a private message' verifier.verified(signed_message) # => 'a private message' Returns +nil+ if the message was not signed with the same secret. other_verifier = ActiveSupport::MessageVerifier.new 'd1ff3r3nt-s3Krit' other_verifier.verified(signed_message) # => nil Returns +nil+ if the message is not Base64-encoded. invalid_message = "f--46a0120593880c733a53b6dad75b42ddc1c8996d" verifier.verified(invalid_message) # => nil Raises any error raised while decoding the signed message. incompatible_message = "test--dad7b06c94abba8d46a15fafaef56c327665d5ff" verifier.verified(incompatible_message) # => TypeError: incompatible marshal file format
verified
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/message_verifier.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/message_verifier.rb
Apache-2.0
def verify(*args, **options) verified(*args, **options) || raise(InvalidSignature) end
Decodes the signed message using the +MessageVerifier+'s secret. verifier = ActiveSupport::MessageVerifier.new 's3Krit' signed_message = verifier.generate 'a private message' verifier.verify(signed_message) # => 'a private message' Raises +InvalidSignature+ if the message was not signed with the same secret or was not Base64-encoded. other_verifier = ActiveSupport::MessageVerifier.new 'd1ff3r3nt-s3Krit' other_verifier.verify(signed_message) # => ActiveSupport::MessageVerifier::InvalidSignature
verify
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/message_verifier.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/message_verifier.rb
Apache-2.0
def generate(value, expires_at: nil, expires_in: nil, purpose: nil) data = encode(Messages::Metadata.wrap(@serializer.dump(value), expires_at: expires_at, expires_in: expires_in, purpose: purpose)) "#{data}--#{generate_digest(data)}" end
Generates a signed message for the provided value. The message is signed with the +MessageVerifier+'s secret. Returns Base64-encoded message joined with the generated signature. verifier = ActiveSupport::MessageVerifier.new 's3Krit' verifier.generate 'a private message' # => "BAhJIhRwcml2YXRlLW1lc3NhZ2UGOgZFVA==--e2d724331ebdee96a10fb99b089508d1c72bd772"
generate
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/message_verifier.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/message_verifier.rb
Apache-2.0
def subscribe(pattern = nil, callback = nil, &block) notifier.subscribe(pattern, callback, monotonic: false, &block) end
Subscribe to a given event name with the passed +block+. You can subscribe to events by passing a String to match exact event names, or by passing a Regexp to match all events that match a pattern. ActiveSupport::Notifications.subscribe(/render/) do |*args| @event = ActiveSupport::Notifications::Event.new(*args) end The +block+ will receive five parameters with information about the event: ActiveSupport::Notifications.subscribe('render') do |name, start, finish, id, payload| name # => String, name of the event (such as 'render' from above) start # => Time, when the instrumented block started execution finish # => Time, when the instrumented block ended execution id # => String, unique ID for the instrumenter that fired the event payload # => Hash, the payload end If the block passed to the method only takes one parameter, it will yield an event object to the block: ActiveSupport::Notifications.subscribe(/render/) do |event| @event = event end
subscribe
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb
Apache-2.0
def initialize(filters = [], mask: FILTERED) @filters = filters @mask = mask end
Create instance with given filters. Supported type of filters are +String+, +Regexp+, and +Proc+. Other types of filters are treated as +String+ using +to_s+. For +Proc+ filters, key, value, and optional original hash is passed to block arguments. ==== Options * <tt>:mask</tt> - A replaced object when filtered. Defaults to <tt>"[FILTERED]"</tt>.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/parameter_filter.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/parameter_filter.rb
Apache-2.0
def filter_param(key, value) @filters.empty? ? value : compiled_filter.value_for_key(key, value) end
Returns filtered value for given key. For +Proc+ filters, third block argument is not populated.
filter_param
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/parameter_filter.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/parameter_filter.rb
Apache-2.0
def raise(*args) ::Object.send(:raise, *args) end
Let ActiveSupport::ProxyObject at least raise exceptions.
raise
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/proxy_object.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/proxy_object.rb
Apache-2.0
def require_unload_lock! unless @locked ActiveSupport::Dependencies.interlock.start_unloading @locked = true end end
Acquire the ActiveSupport::Dependencies::Interlock unload lock, ensuring it will be released automatically
require_unload_lock!
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/reloader.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/reloader.rb
Apache-2.0
def release_unload_lock! if @locked @locked = false ActiveSupport::Dependencies.interlock.done_unloading end end
Release the unload lock if it has been previously obtained
release_unload_lock!
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/reloader.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/activesupport-6.1.7.3/lib/active_support/reloader.rb
Apache-2.0