Dataset Viewer
Auto-converted to Parquet Duplicate
id
string
repo
string
path
string
func_name
string
url
string
split
string
language
string
docstring
string
code
string
text
string
token_count
int32
doc_chars
int32
code_chars
int32
license_basis
string
source
string
added
string
record_sha256
string
license
string
license_class
string
license_source
string
2ffbe4a3e5d6983fad6a010b
rails/rails
activesupport/lib/active_support/current_attributes.rb
ActiveSupport.CurrentAttributes.set
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/current_attributes.rb#L179-L185
train
ruby
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(per...
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(per...
122
446
197
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
bea34488c91caf48b1a40442be185e314e60b6ee2d4c6d888a7dd18286cd6417
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
0aad2c8da8b42ec68ba3dcf3
rails/rails
actionpack/lib/action_controller/renderer.rb
ActionController.Renderer.render
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/actionpack/lib/action_controller/renderer.rb#L87-L97
train
ruby
Accepts a custom Rack environment to render templates in. It will be merged with the default Rack environment defined by +ActionController::Renderer::DEFAULTS+. Render templates with any options from ActionController::Base#render_to_string. The primary options are: * <tt>:partial</tt> - See <tt>ActionView::Partia...
def render(*args) raise "missing controller" unless controller request = ActionDispatch::Request.new @env request.routes = controller._routes instance = controller.new instance.set_request! request instance.set_response! controller.make_response!(request) instance.render_to_s...
Accepts a custom Rack environment to render templates in. It will be merged with the default Rack environment defined by +ActionController::Renderer::DEFAULTS+. Render templates with any options from ActionController::Base#render_to_string. The primary options are: * <tt>:partial</tt> - See <tt>ActionView::Partia...
383
1,237
340
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
8356bd910bfe1d403b712515342bc2f0ae368b57fb4693ab028f08b90150f5da
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
2cf3b1ffa88da20b1d84f961
rails/rails
actionview/lib/action_view/renderer/renderer.rb
ActionView.Renderer.render_body
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/actionview/lib/action_view/renderer/renderer.rb#L38-L44
train
ruby
Render but returns a valid Rack body. If fibers are defined, we return a streaming body that renders the template piece by piece. Note that partials are not supported to be rendered with streaming, so in such cases, we just wrap them in an array.
def render_body(context, options) if options.key?(:partial) [render_partial(context, options)] else StreamingTemplateRenderer.new(@lookup_context).render(context, options) end end
Render but returns a valid Rack body. If fibers are defined, we return a streaming body that renders the template piece by piece. Note that partials are not supported to be rendered with streaming, so in such cases, we just wrap them in an array. def render_body(context, options) if options.key?(:partial) ...
97
250
217
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
ebcb70248fa70eddd6ec40429f070bc732c1c6db646a8431e1d46599a4358669
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
667281283c37065a4bf169b2
rails/rails
actionpack/lib/action_controller/metal/head.rb
ActionController.Head.head
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/actionpack/lib/action_controller/metal/head.rb#L21-L46
train
ruby
Returns a response that has no content (merely headers). The options argument is interpreted to be a hash of header names and values. This allows you to easily return a response that consists only of significant headers: head :created, location: person_path(@person) head :created, location: @person It can ...
def head(status, options = {}) if status.is_a?(Hash) raise ArgumentError, "#{status.inspect} is not a valid value for `status`." end status ||= :ok location = options.delete(:location) content_type = options.delete(:content_type) options.each do |key, value| header...
Returns a response that has no content (merely headers). The options argument is interpreted to be a hash of header names and values. This allows you to easily return a response that consists only of significant headers: head :created, location: person_path(@person) head :created, location: @person It can ...
300
569
729
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
57e5a75ad265a929bf1565e6f1be5fc53df9df0354b4ca5ae90f018d732316d1
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
320ccdbffb3593733704b41c
rails/rails
actionpack/lib/action_controller/metal/redirecting.rb
ActionController.Redirecting.redirect_to
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/actionpack/lib/action_controller/metal/redirecting.rb#L58-L65
train
ruby
Redirects the browser to the target specified in +options+. This parameter can be any one of: * <tt>Hash</tt> - The URL will be generated by calling url_for with the +options+. * <tt>Record</tt> - The URL will be generated by calling url_for with the +options+, which will reference a named URL for that record. * <t...
def redirect_to(options = {}, response_options = {}) raise ActionControllerError.new("Cannot redirect to nil!") unless options raise AbstractController::DoubleRenderError if response_body self.status = _extract_redirect_to_status(options, response_options) self.location = _compute_r...
Redirects the browser to the target specified in +options+. This parameter can be any one of: * <tt>Hash</tt> - The URL will be generated by calling url_for with the +options+. * <tt>Record</tt> - The URL will be generated by calling url_for with the +options+, which will reference a named URL for that record. * <t...
782
2,782
516
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
ef9cc3636434a8052a85cc5663673c1c3fe814ca383b60788ed36ea096bad63f
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
602238223f82f8f2e1b74609
rails/rails
actionpack/lib/action_controller/metal/redirecting.rb
ActionController.Redirecting.redirect_back
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/actionpack/lib/action_controller/metal/redirecting.rb#L90-L94
train
ruby
Redirects the browser to the page that issued the request (the referrer) if possible, otherwise redirects to the provided default fallback location. The referrer information is pulled from the HTTP +Referer+ (sic) header on the request. This is an optional header and its presence on the request is subject to brow...
def redirect_back(fallback_location:, allow_other_host: true, **args) referer = request.headers["Referer"] redirect_to_referer = referer && (allow_other_host || _url_host_allowed?(referer)) redirect_to redirect_to_referer ? referer : fallback_location, **args end
Redirects the browser to the page that issued the request (the referrer) if possible, otherwise redirects to the provided default fallback location. The referrer information is pulled from the HTTP +Referer+ (sic) header on the request. This is an optional header and its presence on the request is subject to brow...
339
1,231
285
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
f443bb9c2a64a1fc3c2c0e83fc36c55fb0d64a23de2b4e198a500f197d58d448
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
5548a92dc37ba5c7cfbae559
rails/rails
activemodel/lib/active_model/attribute_methods.rb
ActiveModel.AttributeMethods.method_missing
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activemodel/lib/active_model/attribute_methods.rb#L426-L433
train
ruby
Allows access to the object attributes, which are held in the hash returned by <tt>attributes</tt>, as though they were first-class methods. So a +Person+ class with a +name+ attribute can for example use <tt>Person#name</tt> and <tt>Person#name=</tt> and never directly use the attributes hash -- except for multipl...
def method_missing(method, *args, &block) if respond_to_without_attributes?(method, true) super else match = matched_attribute_method(method.to_s) match ? attribute_missing(match, *args, &block) : super end end
Allows access to the object attributes, which are held in the hash returned by <tt>attributes</tt>, as though they were first-class methods. So a +Person+ class with a +name+ attribute can for example use <tt>Person#name</tt> and <tt>Person#name=</tt> and never directly use the attributes hash -- except for multipl...
204
581
256
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
edc7ce8fff1750a22f82d717fcd2e6130c35b050e047ee5ad7bf0b697bc6590c
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
d4f30e19c5afd0efa5726ed5
rails/rails
activemodel/lib/active_model/attribute_methods.rb
ActiveModel.AttributeMethods.attribute_missing
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activemodel/lib/active_model/attribute_methods.rb#L439-L441
train
ruby
+attribute_missing+ is like +method_missing+, but for attributes. When +method_missing+ is called we check to see if there is a matching attribute method. If so, we tell +attribute_missing+ to dispatch the attribute. This method can be overloaded to customize the behavior.
def attribute_missing(match, *args, &block) __send__(match.target, match.attr_name, *args, &block) end
+attribute_missing+ is like +method_missing+, but for attributes. When +method_missing+ is called we check to see if there is a matching attribute method. If so, we tell +attribute_missing+ to dispatch the attribute. This method can be overloaded to customize the behavior. def attribute_missing(match, *args, &block...
90
276
112
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
44fa2f4b0ca0ec99bd4ebc2549e169e9a4638a8767d8937ee84c72bb7a06b98a
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
5a3296c3e12fec4ccd680203
rails/rails
activemodel/lib/active_model/attribute_methods.rb
ActiveModel.AttributeMethods.matched_attribute_method
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activemodel/lib/active_model/attribute_methods.rb#L466-L469
train
ruby
Returns a struct representing the matching attribute method. The struct's attributes are prefix, base and suffix.
def matched_attribute_method(method_name) matches = self.class.send(:attribute_method_matchers_matching, method_name) matches.detect { |match| attribute_method?(match.attr_name) } end
Returns a struct representing the matching attribute method. The struct's attributes are prefix, base and suffix. def matched_attribute_method(method_name) matches = self.class.send(:attribute_method_matchers_matching, method_name) matches.detect { |match| attribute_method?(match.attr_name) } en...
60
114
205
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
683db6777678b43ace2fc4a349c790c18151a2c706487517ee886176ae621079
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
3a57f701d73ae990f87a65ea
rails/rails
activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
ActiveRecord.ConnectionHandling.mysql2_connection
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb#L12-L30
train
ruby
:nodoc: Establishes a connection to the database that's used by all Active Record objects.
def mysql2_connection(config) config = config.symbolize_keys config[:flags] ||= 0 if config[:flags].kind_of? Array config[:flags].push "FOUND_ROWS" else config[:flags] |= Mysql2::Client::FOUND_ROWS end client = Mysql2::Client.new(config) ConnectionAdapters::My...
:nodoc: Establishes a connection to the database that's used by all Active Record objects. def mysql2_connection(config) config = config.symbolize_keys config[:flags] ||= 0 if config[:flags].kind_of? Array config[:flags].push "FOUND_ROWS" else config[:flags] |= Mysql2::Client:...
152
91
537
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
fab03fd4c6984fae61e3a51abff1877fd0f590c2d8bd6af6532acfc8a9f30450
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
e0f15a23cb57123d65dd1597
rails/rails
activerecord/lib/active_record/relation/calculations.rb
ActiveRecord.Calculations.calculate
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/relation/calculations.rb#L127-L144
train
ruby
This calculates aggregate values in the given column. Methods for #count, #sum, #average, #minimum, and #maximum have been added as shortcuts. Person.calculate(:count, :all) # The same as Person.count Person.average(:age) # SELECT AVG(age) FROM people... # Selects the minimum age for any family without any ...
def calculate(operation, column_name) if has_include?(column_name) relation = apply_join_dependency if operation.to_s.downcase == "count" unless distinct_value || distinct_select?(column_name || select_for_count) relation.distinct! relation.select_values = [ klas...
This calculates aggregate values in the given column. Methods for #count, #sum, #average, #minimum, and #maximum have been added as shortcuts. Person.calculate(:count, :all) # The same as Person.count Person.average(:age) # SELECT AVG(age) FROM people... # Selects the minimum age for any family without any ...
388
1,087
643
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
eb8c0b75f627c7b9a7a5106ffea476897097a20259577b67e1181db0f25ed42d
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
1a5980d331fcc63232c9b34c
rails/rails
activerecord/lib/active_record/relation/calculations.rb
ActiveRecord.Calculations.pluck
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/relation/calculations.rb#L181-L196
train
ruby
Use #pluck as a shortcut to select one or more attributes without loading a bunch of records just to grab the attributes you want. Person.pluck(:name) instead of Person.all.map(&:name) Pluck returns an Array of attribute values type-casted to match the plucked column names, if they can be deduced. Pluckin...
def pluck(*column_names) if loaded? && (column_names.map(&:to_s) - @klass.attribute_names - @klass.attribute_aliases.keys).empty? return records.pluck(*column_names) end if has_include?(column_names.first) relation = apply_join_dependency relation.pluck(*column_names) el...
Use #pluck as a shortcut to select one or more attributes without loading a bunch of records just to grab the attributes you want. Person.pluck(:name) instead of Person.all.map(&:name) Pluck returns an Array of attribute values type-casted to match the plucked column names, if they can be deduced. Pluckin...
401
985
606
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
361de402dc2afea204e3eeb82174608752c74d570c0c24e57355512f3fcfa596
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
b8c6e5175236732bbc042825
rails/rails
activerecord/lib/active_record/relation/calculations.rb
ActiveRecord.Calculations.column_alias_for
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/relation/calculations.rb#L376-L386
train
ruby
Converts the given field to the value that the database adapter returns as a usable column name: column_alias_for("users.id") # => "users_id" column_alias_for("sum(id)") # => "sum_id" column_alias_for("count(distinct users.id)") # => "count_distinct_users_id" column_alias_...
def column_alias_for(field) return field if field.match?(/\A\w{,#{connection.table_alias_length}}\z/) column_alias = +field column_alias.gsub!(/\*/, "all") column_alias.gsub!(/\W+/, " ") column_alias.strip! column_alias.gsub!(/ +/, "_") connection.table_alias_fo...
Converts the given field to the value that the database adapter returns as a usable column name: column_alias_for("users.id") # => "users_id" column_alias_for("sum(id)") # => "sum_id" column_alias_for("count(distinct users.id)") # => "count_distinct_users_id" column_alias_...
167
368
345
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
53963246d8d0f0e561baf68627c992a8ff1dfaa9635301e2ecb64641ad8624cb
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
513f9802a23a8dc928eca8c1
rails/rails
activerecord/lib/active_record/nested_attributes.rb
ActiveRecord.NestedAttributes.assign_nested_attributes_for_one_to_one_association
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/nested_attributes.rb#L407-L437
train
ruby
Assigns the given attributes to the association. If an associated record does not yet exist, one will be instantiated. If an associated record already exists, the method's behavior depends on the value of the update_only option. If update_only is +false+ and the given attributes include an <tt>:id</tt> that matche...
def assign_nested_attributes_for_one_to_one_association(association_name, attributes) options = nested_attributes_options[association_name] if attributes.respond_to?(:permitted?) attributes = attributes.to_h end attributes = attributes.with_indifferent_access existing_r...
Assigns the given attributes to the association. If an associated record does not yet exist, one will be instantiated. If an associated record already exists, the method's behavior depends on the value of the update_only option. If update_only is +false+ and the given attributes include an <tt>:id</tt> that matche...
462
780
1,517
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
5518451b8db2cd6e72f5c0a7b3403e2d7847a9aeda491584e8bb2aa79207bbfd
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
be7bf30c023bd9b7557f3dc6
rails/rails
activerecord/lib/active_record/nested_attributes.rb
ActiveRecord.NestedAttributes.assign_nested_attributes_for_collection_association
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/nested_attributes.rb#L466-L524
train
ruby
Assigns the given attributes to the collection association. Hashes with an <tt>:id</tt> value matching an existing associated record will update that record. Hashes without an <tt>:id</tt> value will build a new record for the association. Hashes with a matching <tt>:id</tt> value and a <tt>:_destroy</tt> key set ...
def assign_nested_attributes_for_collection_association(association_name, attributes_collection) options = nested_attributes_options[association_name] if attributes_collection.respond_to?(:permitted?) attributes_collection = attributes_collection.to_h end unless attributes_col...
Assigns the given attributes to the collection association. Hashes with an <tt>:id</tt> value matching an existing associated record will update that record. Hashes without an <tt>:id</tt> value will build a new record for the association. Hashes with a matching <tt>:id</tt> value and a <tt>:_destroy</tt> key set ...
737
949
2,685
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
a6cffbbdcc837915dbeda63184970c2cb7b9e5443bcf80b66bd240b32d431ccf
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
17e64920577240c998c803d4
rails/rails
activerecord/lib/active_record/nested_attributes.rb
ActiveRecord.NestedAttributes.check_record_limit!
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/nested_attributes.rb#L532-L548
train
ruby
Takes in a limit and checks if the attributes_collection has too many records. It accepts limit in the form of symbol, proc, or number-like object (anything that can be compared with an integer). Raises TooManyRecords error if the attributes_collection is larger than the limit.
def check_record_limit!(limit, attributes_collection) if limit limit = \ case limit when Symbol send(limit) when Proc limit.call else limit end if limit && attributes_collection.size > limi...
Takes in a limit and checks if the attributes_collection has too many records. It accepts limit in the form of symbol, proc, or number-like object (anything that can be compared with an integer). Raises TooManyRecords error if the attributes_collection is larger than the limit. def check_record_limit!(limit, attr...
148
283
482
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
600678f3ba5e60fc0b39cf23cb0ff5ba3fcdaa874bb127c2241eb7dc1e2514f3
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
21e32d71870eb535fddb8d6e
rails/rails
activerecord/lib/active_record/nested_attributes.rb
ActiveRecord.NestedAttributes.assign_to_or_mark_for_destruction
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/nested_attributes.rb#L552-L555
train
ruby
Updates a record with the +attributes+ or marks it for destruction if +allow_destroy+ is +true+ and has_destroy_flag? returns +true+.
def assign_to_or_mark_for_destruction(record, attributes, allow_destroy) record.assign_attributes(attributes.except(*UNASSIGNABLE_KEYS)) record.mark_for_destruction if has_destroy_flag?(attributes) && allow_destroy end
Updates a record with the +attributes+ or marks it for destruction if +allow_destroy+ is +true+ and has_destroy_flag? returns +true+. def assign_to_or_mark_for_destruction(record, attributes, allow_destroy) record.assign_attributes(attributes.except(*UNASSIGNABLE_KEYS)) record.mark_for_destruction if ...
81
134
240
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
13a14be2414e8e4a12d1a7aca849368219ea58d9319a8a07b3465fcfad47f054
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
150a4261b6392370d9f59cf2
rails/rails
activerecord/lib/active_record/translation.rb
ActiveRecord.Translation.lookup_ancestors
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/translation.rb#L8-L17
train
ruby
Set the lookup ancestors for ActiveModel.
def lookup_ancestors #:nodoc: klass = self classes = [klass] return classes if klass == ActiveRecord::Base while !klass.base_class? classes << klass = klass.superclass end classes end
Set the lookup ancestors for ActiveModel. def lookup_ancestors #:nodoc: klass = self classes = [klass] return classes if klass == ActiveRecord::Base while !klass.base_class? classes << klass = klass.superclass end classes end
62
41
232
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
2142902ebf346b53c0c23f176d1b1e1f8e6712ba7b327e2dd9e506e3ad10b3ef
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
725c66461bd1b83fa59357f6
rails/rails
activesupport/lib/active_support/inflector/methods.rb
ActiveSupport.Inflector.camelize
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/inflector/methods.rb#L68-L78
train
ruby
Converts strings to UpperCamelCase. If the +uppercase_first_letter+ parameter is set to false, then produces lowerCamelCase. Also converts '/' to '::' which is useful for converting paths to namespaces. camelize('active_model') # => "ActiveModel" camelize('active_model', false) # => "...
def camelize(term, uppercase_first_letter = true) string = term.to_s if uppercase_first_letter string = string.sub(/^[a-z\d]*/) { |match| inflections.acronyms[match] || match.capitalize } else string = string.sub(inflections.acronyms_camelize_regex) { |match| match.downcase } end...
Converts strings to UpperCamelCase. If the +uppercase_first_letter+ parameter is set to false, then produces lowerCamelCase. Also converts '/' to '::' which is useful for converting paths to namespaces. camelize('active_model') # => "ActiveModel" camelize('active_model', false) # => "...
290
662
471
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
220793215540adf21ee2ece13796d840f926607928e3f3366a517ff35d013d4a
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
1be59eeacd9090f0f0f0de04
rails/rails
activesupport/lib/active_support/inflector/methods.rb
ActiveSupport.Inflector.humanize
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/inflector/methods.rb#L128-L148
train
ruby
Tweaks an attribute name for display to end users. Specifically, performs these transformations: * Applies human inflection rules to the argument. * Deletes leading underscores, if any. * Removes a "_id" suffix if present. * Replaces underscores with spaces, if any. * Downcases all words except acronyms. * Cap...
def humanize(lower_case_and_underscored_word, capitalize: true, keep_id_suffix: false) result = lower_case_and_underscored_word.to_s.dup inflections.humans.each { |(rule, replacement)| break if result.sub!(rule, replacement) } result.sub!(/\A_+/, "") unless keep_id_suffix result.sub!(/...
Tweaks an attribute name for display to end users. Specifically, performs these transformations: * Applies human inflection rules to the argument. * Deletes leading underscores, if any. * Removes a "_id" suffix if present. * Replaces underscores with spaces, if any. * Downcases all words except acronyms. * Cap...
389
997
598
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
e5ac262293ece29100ac99dd884aa3351c619ba012e8265a55e25bfd589ed603
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
13de6671ef5f4e1948e3b9e5
rails/rails
activesupport/lib/active_support/inflector/methods.rb
ActiveSupport.Inflector.demodulize
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/inflector/methods.rb#L220-L227
train
ruby
Removes the module part from the expression in the string. demodulize('ActiveSupport::Inflector::Inflections') # => "Inflections" demodulize('Inflections') # => "Inflections" demodulize('::Inflections') # => "Inflections" demodulize('') ...
def demodulize(path) path = path.to_s if i = path.rindex("::") path[(i + 2)..-1] else path end end
Removes the module part from the expression in the string. demodulize('ActiveSupport::Inflector::Inflections') # => "Inflections" demodulize('Inflections') # => "Inflections" demodulize('::Inflections') # => "Inflections" demodulize('') ...
130
371
142
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
dbfed9dda2e097d9d495d11cb5184293651a732049af16b803e585373df63851
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
80fbccb4e502820466b188de
rails/rails
activesupport/lib/active_support/inflector/methods.rb
ActiveSupport.Inflector.constantize
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/inflector/methods.rb#L271-L300
train
ruby
Tries to find a constant with the name specified in the argument string. constantize('Module') # => Module constantize('Foo::Bar') # => Foo::Bar The name is assumed to be the one of a top-level constant, no matter whether it starts with "::" or not. No lexical context is taken into account: C = 'outsid...
def constantize(camel_cased_word) names = camel_cased_word.split("::") # Trigger a built-in NameError exception including the ill-formed constant in the message. Object.const_get(camel_cased_word) if names.empty? # Remove the first blank element in case of '::ClassName' notation. names.s...
Tries to find a constant with the name specified in the argument string. constantize('Module') # => Module constantize('Foo::Bar') # => Foo::Bar The name is assumed to be the one of a top-level constant, no matter whether it starts with "::" or not. No lexical context is taken into account: C = 'outsid...
376
530
1,150
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
2e6b5da7e2b9e46dda19354c43382f8e267113685a666948c45f8685f869b6c5
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
55938c4948174462861db4f4
rails/rails
activesupport/lib/active_support/inflector/methods.rb
ActiveSupport.Inflector.const_regexp
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/inflector/methods.rb#L368-L378
train
ruby
Mounts a regular expression, returned as a string to ease interpolation, that will match part by part the given constant. const_regexp("Foo::Bar::Baz") # => "Foo(::Bar(::Baz)?)?" const_regexp("::") # => "::"
def const_regexp(camel_cased_word) parts = camel_cased_word.split("::") return Regexp.escape(camel_cased_word) if parts.blank? last = parts.pop parts.reverse.inject(last) do |acc, part| part.empty? ? acc : "#{part}(::#{acc})?" end end
Mounts a regular expression, returned as a string to ease interpolation, that will match part by part the given constant. const_regexp("Foo::Bar::Baz") # => "Foo(::Bar(::Baz)?)?" const_regexp("::") # => "::" def const_regexp(camel_cased_word) parts = camel_cased_word.split("::") ret...
134
226
293
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
47fdf8b557072d2cfc9ea70d40b0d15b821a54f01ea230e668dc2263cbd09561
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
bc595624f2d20596508442f2
rails/rails
activesupport/lib/active_support/inflector/methods.rb
ActiveSupport.Inflector.apply_inflections
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/inflector/methods.rb#L387-L396
train
ruby
Applies inflection rules for +singularize+ and +pluralize+. If passed an optional +locale+ parameter, the uncountables will be found for that locale. apply_inflections('post', inflections.plurals, :en) # => "posts" apply_inflections('posts', inflections.singulars, :en) # => "post"
def apply_inflections(word, rules, locale = :en) result = word.to_s.dup if word.empty? || inflections(locale).uncountables.uncountable?(result) result else rules.each { |(rule, replacement)| break if result.sub!(rule, replacement) } result end end
Applies inflection rules for +singularize+ and +pluralize+. If passed an optional +locale+ parameter, the uncountables will be found for that locale. apply_inflections('post', inflections.plurals, :en) # => "posts" apply_inflections('posts', inflections.singulars, :en) # => "post" def apply_inflections(word...
155
292
316
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
10701e03c6488f98f6a1e8afe863fa51a7456945f1b33f0c0f2f4842a904232b
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
45a8e8841c2af6f3e7fe80ae
rails/rails
activerecord/lib/active_record/associations.rb
ActiveRecord.Associations.association
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/associations.rb#L230-L242
train
ruby
Returns the association instance for the given name, instantiating it if it doesn't already exist
def association(name) #:nodoc: association = association_instance_get(name) if association.nil? unless reflection = self.class._reflect_on_association(name) raise AssociationNotFoundError.new(self, name) end association = reflection.association_class.new(self, reflection) ...
Returns the association instance for the given name, instantiating it if it doesn't already exist def association(name) #:nodoc: association = association_instance_get(name) if association.nil? unless reflection = self.class._reflect_on_association(name) raise AssociationNotFoundError.ne...
92
97
408
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
b38064712b114e60a4e1a9141c36399c48e3d334df8bc7b502518e3f786cd93b
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
33563bd4c08322120e65ec51
rails/rails
actionpack/lib/action_dispatch/middleware/request_id.rb
ActionDispatch.RequestId.call
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/actionpack/lib/action_dispatch/middleware/request_id.rb#L24-L28
train
ruby
:nodoc:
def call(env) req = ActionDispatch::Request.new env req.request_id = make_request_id(req.x_request_id) @app.call(env).tap { |_status, headers, _body| headers[X_REQUEST_ID] = req.request_id } end
:nodoc: def call(env) req = ActionDispatch::Request.new env req.request_id = make_request_id(req.x_request_id) @app.call(env).tap { |_status, headers, _body| headers[X_REQUEST_ID] = req.request_id } end
59
7
216
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
9e3fada8da275225ca84d9a3825db2fe2eb19478385630088596a46d74ffb24e
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
4360d0f662a31963db98cea6
rails/rails
activesupport/lib/active_support/dependencies.rb
ActiveSupport.Dependencies.loadable_constants_for_path
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/dependencies.rb#L412-L430
train
ruby
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.
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...
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. def loadable_constants_for_path(path, bases = autoload_paths) path = path.chomp(".rb") expanded_path = File.expand_path(path) paths = [] bases.each d...
149
144
536
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
f847aee56caa7e5fcafb1b9230b8454d262462c9f304403aa458bbae772533a5
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
1b123cf1773a3ecd0745c5ef
rails/rails
activesupport/lib/active_support/dependencies.rb
ActiveSupport.Dependencies.autoloadable_module?
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/dependencies.rb#L446-L451
train
ruby
Does the provided path_suffix correspond to an autoloadable module? Instead of returning a boolean, the autoload base for this module is returned.
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. def autoloadable_module?(path_suffix) autoload_paths.each do |load_path| return load_path if File.directory? File.join(load_path, path_suffix) end ...
69
148
184
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
357c1abf35295c9123687a0a3aee296db22ed17fbd0eec200794b225ab5c24a7
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
d62d01b0093a3bc1cf31d5c4
rails/rails
activesupport/lib/active_support/dependencies.rb
ActiveSupport.Dependencies.autoload_module!
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/dependencies.rb#L464-L472
train
ruby
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...
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)})") a...
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...
170
336
455
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
394cc1d3a05daab9e8703c79dd66849c426b7a7e944af5bd6867ff41a8cbc82d
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
fb471e963fa6d23c99ac9a58
rails/rails
activesupport/lib/active_support/dependencies.rb
ActiveSupport.Dependencies.load_file
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/dependencies.rb#L482-L494
train
ruby
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 ...
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 ...
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 ...
213
462
499
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
754fb4af3f6e56bc185f68137ee037ac2bf5b06aa71c031d9a2b7e57b7801f6f
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
61ef30e198fc78fe4f5c9977
rails/rails
activesupport/lib/active_support/dependencies.rb
ActiveSupport.Dependencies.load_missing_constant
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/dependencies.rb#L505-L568
train
ruby
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+.
def load_missing_constant(from_mod, const_name) 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_f...
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+. def load_missing_constant(from_mod, const_name) unless qualified_const_defined?(from_mod.name) && Inflector.constantize(from_mod.name).eq...
643
175
2,712
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
2e1dc8e69e05686b7d7859dd5ad335c25da2c5656947628538ab18021897c6da
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
0ba960aa5c9f0460734a9062
rails/rails
activesupport/lib/active_support/dependencies.rb
ActiveSupport.Dependencies.remove_unloadable_constants!
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/dependencies.rb#L577-L583
train
ruby
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...
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...
137
413
282
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
347a2455dba4a917fa1da2aaac82aeec3f605be7dd024c207ec5e6b5234c63dd
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
a7c353730284db2464ce30f3
rails/rails
activesupport/lib/active_support/dependencies.rb
ActiveSupport.Dependencies.new_constants_in
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/dependencies.rb#L674-L689
train
ruby
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 complet...
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 succes...
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 complet...
183
455
439
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
1e4e6e2459ed7d94ca90155bba540a4150535036e189555302616ceb4b7093f5
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
04b506f9be9860e10ead97ef
rails/rails
activesupport/lib/active_support/dependencies.rb
ActiveSupport.Dependencies.to_constant_name
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/dependencies.rb#L693-L702
train
ruby
Convert the provided const desc to a qualified constant name (as a string). A module, class, symbol, or string may be provided.
def to_constant_name(desc) #:nodoc: case desc when String then desc.sub(/^::/, "") when Symbol then desc.to_s when Module desc.name || raise(ArgumentError, "Anonymous modules have no name to be referenced by") else raise TypeError, "Not a valid constant descriptor: #{desc...
Convert the provided const desc to a qualified constant name (as a string). A module, class, symbol, or string may be provided. def to_constant_name(desc) #:nodoc: case desc when String then desc.sub(/^::/, "") when Symbol then desc.to_s when Module desc.name || raise(Argumen...
105
128
348
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
38210e93b0d972d395fbf311923822f747cdb4f4f4464e6d97e2910b76facbff
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
be4363ae361577f25138bcda
rails/rails
activerecord/lib/active_record/relation/query_methods.rb
ActiveRecord.QueryMethods.select
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/relation/query_methods.rb#L254-L265
train
ruby
Works in two unique ways. First: takes a block so it can be used just like <tt>Array#select</tt>. Model.all.select { |m| m.field == value } This will build an array of objects from the database for the scope, converting them into an array and iterating through them using <tt>Array#select</tt>. Second: Modif...
def select(*fields) if block_given? if fields.any? raise ArgumentError, "`select' with block doesn't take arguments." end return super() end raise ArgumentError, "Call `select' with at least one field" if fields.empty? spawn._select!(*fields) end
Works in two unique ways. First: takes a block so it can be used just like <tt>Array#select</tt>. Model.all.select { |m| m.field == value } This will build an array of objects from the database for the scope, converting them into an array and iterating through them using <tt>Array#select</tt>. Second: Modif...
429
1,529
310
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
f767b4e904f8d22f4227dbc6269f212429ee98fc6133cd1488c4eb133b69d89c
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
4fe0d6a56c9f0f61174be5be
rails/rails
activerecord/lib/active_record/relation/query_methods.rb
ActiveRecord.QueryMethods.where
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/relation/query_methods.rb#L632-L640
train
ruby
Returns a new relation, which is the result of filtering the current relation according to the conditions in the arguments. #where accepts conditions in one of several formats. In the examples below, the resulting SQL is given as an illustration; the actual query generated may be different depending on the databas...
def where(opts = :chain, *rest) if :chain == opts WhereChain.new(spawn) elsif opts.blank? self else spawn.where!(opts, *rest) end end
Returns a new relation, which is the result of filtering the current relation according to the conditions in the arguments. #where accepts conditions in one of several formats. In the examples below, the resulting SQL is given as an illustration; the actual query generated may be different depending on the databas...
1,224
5,162
185
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
386645c1013bf7b10e40f8e614f3e8174fcd5ae440854e53d0463803d6611663
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
a833265825512cb6b8cdb5c8
rails/rails
activerecord/lib/active_record/relation/query_methods.rb
ActiveRecord.QueryMethods.extending
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/relation/query_methods.rb#L918-L924
train
ruby
Used to extend a scope with additional methods, either through a module or through a block provided. The object returned is a relation, which can be further extended. === Using a module module Pagination def page(number) # pagination code goes here end end scope = Model.all.extending(Pa...
def extending(*modules, &block) if modules.any? || block spawn.extending!(*modules, &block) else self end end
Used to extend a scope with additional methods, either through a module or through a block provided. The object returned is a relation, which can be further extended. === Using a module module Pagination def page(number) # pagination code goes here end end scope = Model.all.extending(Pa...
218
783
147
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
31ddf10629afc06d185e9960dee6e4af3df05ab0452dbcc9825fe582bfb3b37e
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
92ff8c752c63b7d16958d8cc
rails/rails
activerecord/lib/active_record/relation/query_methods.rb
ActiveRecord.QueryMethods.validate_order_args
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/relation/query_methods.rb#L1243-L1253
train
ruby
:nodoc:
def validate_order_args(args) args.each do |arg| next unless arg.is_a?(Hash) arg.each do |_key, value| unless VALID_DIRECTIONS.include?(value) raise ArgumentError, "Direction \"#{value}\" is invalid. Valid directions are: #{VALID_DIRECTIONS.to_a.insp...
:nodoc: def validate_order_args(args) args.each do |arg| next unless arg.is_a?(Hash) arg.each do |_key, value| unless VALID_DIRECTIONS.include?(value) raise ArgumentError, "Direction \"#{value}\" is invalid. Valid directions are: #{VALID_DIRECTIONS....
83
7
377
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
1190d551a78dd71a568d983dd98dfc476ef363275ac9e37c11b29210574cc4bc
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
b93e689dff4da3c8dc699d1e
rails/rails
activesupport/lib/active_support/xml_mini/rexml.rb
ActiveSupport.XmlMini_REXML.parse
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/xml_mini/rexml.rb#L20-L38
train
ruby
Parse an XML Document string or IO into a simple hash. Same as XmlSimple::xml_in but doesn't shoot itself in the foot, and uses the defaults from Active Support. data:: XML Document string or IO to parse
def parse(data) if !data.respond_to?(:read) data = StringIO.new(data || "") end if data.eof? {} else silence_warnings { require "rexml/document" } unless defined?(REXML::Document) doc = REXML::Document.new(data) if doc.root merge_element!({}, d...
Parse an XML Document string or IO into a simple hash. Same as XmlSimple::xml_in but doesn't shoot itself in the foot, and uses the defaults from Active Support. data:: XML Document string or IO to parse def parse(data) if !data.respond_to?(:read) data = StringIO.new(data || "") end ...
164
211
499
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
fcc8165b180ecdda4ff553a499190ade9886adf054a5f1e644890613f01483bd
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
87d35c667d555349b7e60b80
rails/rails
activesupport/lib/active_support/xml_mini/rexml.rb
ActiveSupport.XmlMini_REXML.merge_element!
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/xml_mini/rexml.rb#L47-L50
train
ruby
Convert an XML element and merge into the hash hash:: Hash to merge the converted element into. element:: XML element to merge into hash
def merge_element!(hash, element, depth) raise REXML::ParseException, "The document is too deep" if depth == 0 merge!(hash, element.name, collapse(element, depth)) end
Convert an XML element and merge into the hash hash:: Hash to merge the converted element into. element:: XML element to merge into hash def merge_element!(hash, element, depth) raise REXML::ParseException, "The document is too deep" if depth == 0 merge!(hash, element.name, collapse(element, d...
77
145
189
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
335cac25de74dd8dc8d6cf1aee0f5b81371bcdf7709a7f57717895695cdac4be
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
977b760d3dc7d6abfa5945d4
rails/rails
activesupport/lib/active_support/xml_mini/rexml.rb
ActiveSupport.XmlMini_REXML.merge_texts!
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/xml_mini/rexml.rb#L74-L83
train
ruby
Merge all the texts of an element into the hash hash:: Hash to add the converted element to. element:: XML element whose texts are to me merged into the hash
def merge_texts!(hash, element) unless element.has_text? hash else # must use value to prevent double-escaping texts = +"" element.texts.each { |t| texts << t.value } merge!(hash, CONTENT_KEY, texts) end end
Merge all the texts of an element into the hash hash:: Hash to add the converted element to. element:: XML element whose texts are to me merged into the hash def merge_texts!(hash, element) unless element.has_text? hash else # must use value to prevent double-escaping ...
102
166
287
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
a7b17422aaef170c4b5f01b660fef1bd54c97703f33b814d26099c98cca972d0
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
9faad080b7cc7c3e0ff60799
rails/rails
activesupport/lib/active_support/xml_mini/rexml.rb
ActiveSupport.XmlMini_REXML.merge!
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/xml_mini/rexml.rb#L96-L109
train
ruby
Adds a new key/value pair to an existing Hash. If the key to be added already exists and the existing value associated with key is not an Array, it will be wrapped in an Array. Then the new value is appended to that Array. hash:: Hash to add key/value pair to. key:: Key to be added. value:: Value to be ...
def merge!(hash, key, value) if hash.has_key?(key) if hash[key].instance_of?(Array) hash[key] << value else hash[key] = [hash[key], value] end elsif value.instance_of?(Array) hash[key] = [value] else hash[key] = value ...
Adds a new key/value pair to an existing Hash. If the key to be added already exists and the existing value associated with key is not an Array, it will be wrapped in an Array. Then the new value is appended to that Array. hash:: Hash to add key/value pair to. key:: Key to be added. value:: Value to be ...
166
340
350
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
30ee7739aeba03a66a09f93345558ec3868fa0fd7b2fdc5976800b8fe45e6854
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
f48cae7aa0ab667b1244c931
rails/rails
activesupport/lib/active_support/xml_mini/rexml.rb
ActiveSupport.XmlMini_REXML.get_attributes
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/xml_mini/rexml.rb#L116-L120
train
ruby
Converts the attributes array of an XML element into a hash. Returns an empty Hash if node has no attributes. element:: XML element to extract attributes from.
def get_attributes(element) attributes = {} element.attributes.each { |n, v| attributes[n] = v } attributes end
Converts the attributes array of an XML element into a hash. Returns an empty Hash if node has no attributes. element:: XML element to extract attributes from. def get_attributes(element) attributes = {} element.attributes.each { |n, v| attributes[n] = v } attributes end
63
165
141
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
56d40db1b305e14b4fa7c55afb5d78abde04f56fae86bb2bedb10211be7c429e
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
60f5c6e9fc5722a8ed1b7844
rails/rails
actionview/lib/action_view/flows.rb
ActionView.StreamingFlow.get
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/actionview/lib/action_view/flows.rb#L43-L60
train
ruby
:nodoc: Try to get stored content. If the content is not available and we're inside the layout fiber, then it will begin waiting for the given key and yield.
def get(key) return super if @content.key?(key) if inside_fiber? view = @view begin @waiting_for = key view.output_buffer, @parent = @child, view.output_buffer Fiber.yield ensure @waiting_for = nil view.output_buffer, @child = @pare...
:nodoc: Try to get stored content. If the content is not available and we're inside the layout fiber, then it will begin waiting for the given key and yield. def get(key) return super if @content.key?(key) if inside_fiber? view = @view begin @waiting_for = key view....
129
160
385
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
f07a6b2710a1fc026f83a7cd737a90f17858fb6445b8d13337591ab976bdb89d
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
a7439a528c1d5cc5d3dade93
rails/rails
activerecord/lib/active_record/connection_handling.rb
ActiveRecord.ConnectionHandling.connects_to
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/connection_handling.rb#L68-L79
train
ruby
Connects a model to the databases specified. The +database+ keyword takes a hash consisting of a +role+ and a +database_key+. This will create a connection handler for switching between connections, look up the config hash using the +database_key+ and finally establishes a connection to that config. class Anim...
def connects_to(database: {}) connections = [] database.each do |role, database_key| config_hash = resolve_config_for_connection(database_key) handler = lookup_connection_handler(role.to_sym) connections << handler.establish_connection(config_hash) end connections ...
Connects a model to the databases specified. The +database+ keyword takes a hash consisting of a +role+ and a +database_key+. This will create a connection handler for switching between connections, look up the config hash using the +database_key+ and finally establishes a connection to that config. class Anim...
164
511
323
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
75b7bc7e9a5d293cec719ef0ce98a4bb5818ac9b90408599be446991b8cdbd3a
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
4fb51c52727307f17cfcc766
rails/rails
activerecord/lib/active_record/connection_handling.rb
ActiveRecord.ConnectionHandling.connected_to
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/connection_handling.rb#L117-L137
train
ruby
Connects to a database or role (ex writing, reading, or another custom role) for the duration of the block. If a role is passed, Active Record will look up the connection based on the requested role: ActiveRecord::Base.connected_to(role: :writing) do Dog.create! # creates dog using dog writing connection ...
def connected_to(database: nil, role: nil, &blk) if database && role raise ArgumentError, "connected_to can only accept a `database` or a `role` argument, but not both arguments." elsif database if database.is_a?(Hash) role, database = database.first role = role.to_sym ...
Connects to a database or role (ex writing, reading, or another custom role) for the duration of the block. If a role is passed, Active Record will look up the connection based on the requested role: ActiveRecord::Base.connected_to(role: :writing) do Dog.create! # creates dog using dog writing connection ...
488
1,510
683
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
818a9b17256244df0b85340216163263fd6f9d0f34bf9809d2fb71db0c7c4676
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
1c99084dca9b69c2d1c0f2a8
rails/rails
activerecord/lib/active_record/connection_handling.rb
ActiveRecord.ConnectionHandling.clear_query_caches_for_current_thread
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/connection_handling.rb#L187-L193
train
ruby
Clears the query cache for all connections associated with the current thread.
def clear_query_caches_for_current_thread ActiveRecord::Base.connection_handlers.each_value do |handler| handler.connection_pool_list.each do |pool| pool.connection.clear_query_cache if pool.active_connection? end end end
Clears the query cache for all connections associated with the current thread. def clear_query_caches_for_current_thread ActiveRecord::Base.connection_handlers.each_value do |handler| handler.connection_pool_list.each do |pool| pool.connection.clear_query_cache if pool.active_connection? ...
64
78
263
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
e9053424bad993fed6b6170a548523ce90692e24f8bfc504c8e891010fb0f371
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
1bfc54c98a9c126f9dbd0ae8
rails/rails
activerecord/lib/active_record/schema_dumper.rb
ActiveRecord.SchemaDumper.formatted_version
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/schema_dumper.rb#L59-L63
train
ruby
turns 20170404131909 into "2017_04_04_131909"
def formatted_version stringified = @version.to_s return stringified unless stringified.length == 14 stringified.insert(4, "_").insert(7, "_").insert(10, "_") end
turns 20170404131909 into "2017_04_04_131909" def formatted_version stringified = @version.to_s return stringified unless stringified.length == 14 stringified.insert(4, "_").insert(7, "_").insert(10, "_") end
68
45
192
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
0bf53547a9f4f94e388af72f777a2bb12043522f672336a5e7a94a8ded5e3e58
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
55a74d505fed93680da60ba9
rails/rails
activerecord/lib/active_record/schema_dumper.rb
ActiveRecord.SchemaDumper.indexes
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/schema_dumper.rb#L171-L181
train
ruby
Keep it for indexing materialized views
def indexes(table, stream) if (indexes = @connection.indexes(table)).any? add_index_statements = indexes.map do |index| table_name = remove_prefix_and_suffix(index.table).inspect " add_index #{([table_name] + index_parts(index)).join(', ')}" end stream.put...
Keep it for indexing materialized views def indexes(table, stream) if (indexes = @connection.indexes(table)).any? add_index_statements = indexes.map do |index| table_name = remove_prefix_and_suffix(index.table).inspect " add_index #{([table_name] + index_parts(index)).join(',...
95
39
402
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
1822813c1c0af7a8d7eadebee5578ae0a139c68eaf87f93c930d10a334012ca6
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
a33fca07425b4de29b7c8af3
rails/rails
activesupport/lib/active_support/core_ext/object/try.rb
ActiveSupport.Tryable.try
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/core_ext/object/try.rb#L7-L17
train
ruby
:nodoc:
def try(method_name = nil, *args, &b) if method_name.nil? && block_given? if b.arity == 0 instance_eval(&b) else yield self end elsif respond_to?(method_name) public_send(method_name, *args, &b) end end
:nodoc: def try(method_name = nil, *args, &b) if method_name.nil? && block_given? if b.arity == 0 instance_eval(&b) else yield self end elsif respond_to?(method_name) public_send(method_name, *args, &b) end end
77
7
276
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
5b2d139983142428dc1d26e2b761780c9c4d68f0d251f668a8fa7c87befc298c
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
6908e7d01a3aeed2a5a6f142
rails/rails
actionview/lib/action_view/routing_url_for.rb
ActionView.RoutingUrlFor.url_for
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/actionview/lib/action_view/routing_url_for.rb#L79-L119
train
ruby
Returns the URL for the set of +options+ provided. This takes the same options as +url_for+ in Action Controller (see the documentation for <tt>ActionController::Base#url_for</tt>). Note that by default <tt>:only_path</tt> is <tt>true</tt> so you'll get the relative "/controller/action" instead of the fully qualifi...
def url_for(options = nil) case options when String options when nil super(only_path: _generate_paths_by_default) when Hash options = options.symbolize_keys ensure_only_path_option(options) super(options) when ActionController::Parameters en...
Returns the URL for the set of +options+ provided. This takes the same options as +url_for+ in Action Controller (see the documentation for <tt>ActionController::Base#url_for</tt>). Note that by default <tt>:only_path</tt> is <tt>true</tt> so you'll get the relative "/controller/action" instead of the fully qualifi...
1,042
3,112
1,121
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
b7b09cee09c2b179f03ce20f8cbeb8c0949d0f0a604743fc30ff7b92de30f2ab
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
43caf44a3f8cb8542b67a13a
rails/rails
activesupport/lib/active_support/time_with_zone.rb
ActiveSupport.TimeWithZone.formatted_offset
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/time_with_zone.rb#L126-L128
train
ruby
Returns a formatted string of the offset from UTC, or an alternative string if the time zone is already UTC. Time.zone = 'Eastern Time (US & Canada)' # => "Eastern Time (US & Canada)" Time.zone.now.formatted_offset(true) # => "-05:00" Time.zone.now.formatted_offset(false) # => "-0500" Time.zo...
def formatted_offset(colon = true, alternate_utc_string = nil) utc? && alternate_utc_string || TimeZone.seconds_to_utc_offset(utc_offset, colon) end
Returns a formatted string of the offset from UTC, or an alternative string if the time zone is already UTC. Time.zone = 'Eastern Time (US & Canada)' # => "Eastern Time (US & Canada)" Time.zone.now.formatted_offset(true) # => "-05:00" Time.zone.now.formatted_offset(false) # => "-0500" Time.zo...
145
421
158
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
00b08a06fdffd0e47b164c220ae8392c51e0218bbfd345878cb9e34bcae9d9af
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
89556e6cb910e52dfb72f64b
rails/rails
activesupport/lib/active_support/time_with_zone.rb
ActiveSupport.TimeWithZone.as_json
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/time_with_zone.rb#L167-L173
train
ruby
Coerces time to a string for JSON encoding. The default format is ISO 8601. You can get %Y/%m/%d %H:%M:%S +offset style by setting <tt>ActiveSupport::JSON::Encoding.use_standard_json_time_format</tt> to +false+. # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = true Time.utc(2005,2,1,15,15,...
def as_json(options = nil) if ActiveSupport::JSON::Encoding.use_standard_json_time_format xmlschema(ActiveSupport::JSON::Encoding.time_precision) else %(#{time.strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}) end end
Coerces time to a string for JSON encoding. The default format is ISO 8601. You can get %Y/%m/%d %H:%M:%S +offset style by setting <tt>ActiveSupport::JSON::Encoding.use_standard_json_time_format</tt> to +false+. # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = true Time.utc(2005,2,1,15,15,...
256
571
264
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
3d6aa57bbc0e7ed67ab2dd48b8fd2c029d774b15976a9e5e5d5d30c7a2ef8a75
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
e4206e32343a5e4685f24b5d
rails/rails
activesupport/lib/active_support/time_with_zone.rb
ActiveSupport.TimeWithZone.to_s
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/time_with_zone.rb#L206-L214
train
ruby
Returns a string of the object's date and time. Accepts an optional <tt>format</tt>: * <tt>:default</tt> - default value, mimics Ruby Time#to_s format. * <tt>:db</tt> - format outputs time in UTC :db time. See Time#to_formatted_s(:db). * Any key in <tt>Time::DATE_FORMATS</tt> can be used. See active_support/core_ex...
def to_s(format = :default) if format == :db utc.to_s(format) elsif formatter = ::Time::DATE_FORMATS[format] formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter) else "#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset(false, 'UTC')}" # mimicking...
Returns a string of the object's date and time. Accepts an optional <tt>format</tt>: * <tt>:default</tt> - default value, mimics Ruby Time#to_s format. * <tt>:db</tt> - format outputs time in UTC :db time. See Time#to_formatted_s(:db). * Any key in <tt>Time::DATE_FORMATS</tt> can be used. See active_support/core_ex...
196
342
360
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
37ea189a90ac90625767fcd2008c921dac9d08db4a1390440524cbf5164b6204
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
a05ed7fd305da26c2b861f47
rails/rails
activesupport/lib/active_support/time_with_zone.rb
ActiveSupport.TimeWithZone.change
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/time_with_zone.rb#L362-L379
train
ruby
Returns a new +ActiveSupport::TimeWithZone+ where one or more of the elements have been changed according to the +options+ parameter. The time options (<tt>:hour</tt>, <tt>:min</tt>, <tt>:sec</tt>, <tt>:usec</tt>, <tt>:nsec</tt>) reset cascadingly, so if only the hour is passed, then minute, sec, usec and nsec is se...
def change(options) if options[:zone] && options[:offset] raise ArgumentError, "Can't change both :offset and :zone at the same time: #{options.inspect}" end new_time = time.change(options) if options[:zone] new_zone = ::Time.find_zone(options[:zone]) elsif options[:offse...
Returns a new +ActiveSupport::TimeWithZone+ where one or more of the elements have been changed according to the +options+ parameter. The time options (<tt>:hour</tt>, <tt>:min</tt>, <tt>:sec</tt>, <tt>:usec</tt>, <tt>:nsec</tt>) reset cascadingly, so if only the hour is passed, then minute, sec, usec and nsec is se...
574
1,183
568
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
fc10bff1bd48b4849bdd2602c77553ae426c99f9a778f19181d2e39f56c69a8b
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
2983f16c5697521218eeeeaf
rails/rails
activesupport/lib/active_support/time_with_zone.rb
ActiveSupport.TimeWithZone.advance
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/time_with_zone.rb#L402-L410
train
ruby
Uses Date to provide precise Time calculations for years, months, and days according to the proleptic Gregorian calendar. The result is returned as a new TimeWithZone object. The +options+ parameter takes a hash with any of these keys: <tt>:years</tt>, <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>, <tt>:hours...
def advance(options) # If we're advancing a value of variable length (i.e., years, weeks, months, days), advance from #time, # otherwise advance from #utc, for accuracy when moving across DST boundaries if options.values_at(:years, :weeks, :months, :days).any? method_missing(:advance, options)...
Uses Date to provide precise Time calculations for years, months, and days according to the proleptic Gregorian calendar. The result is returned as a new TimeWithZone object. The +options+ parameter takes a hash with any of these keys: <tt>:years</tt>, <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>, <tt>:hours...
505
1,181
402
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
2432c56b84189caad795299ebf622a6f5cf98a80959c47476e6102c4b5602388
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
a6cb3578b8ba2f08152d5e40
rails/rails
activesupport/lib/active_support/time_with_zone.rb
ActiveSupport.TimeWithZone.to_a
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/time_with_zone.rb#L425-L427
train
ruby
Returns Array of parts of Time in sequence of [seconds, minutes, hours, day, month, year, weekday, yearday, dst?, zone]. now = Time.zone.now # => Tue, 18 Aug 2015 02:29:27 UTC +00:00 now.to_a # => [27, 29, 2, 18, 8, 2015, 2, 230, false, "UTC"]
def to_a [time.sec, time.min, time.hour, time.day, time.mon, time.year, time.wday, time.yday, dst?, zone] end
Returns Array of parts of Time in sequence of [seconds, minutes, hours, day, month, year, weekday, yearday, dst?, zone]. now = Time.zone.now # => Tue, 18 Aug 2015 02:29:27 UTC +00:00 now.to_a # => [27, 29, 2, 18, 8, 2015, 2, 230, false, "UTC"] def to_a [time.sec, time.min, time.hour, t...
137
270
119
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
cbd32868dc78cdc2a1eb616a3e651bc6d277e4565d03028c114e4f86261e0ee7
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
05a6f4fccae491ea161f2ae6
rails/rails
activesupport/lib/active_support/time_with_zone.rb
ActiveSupport.TimeWithZone.respond_to_missing?
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/time_with_zone.rb#L513-L516
train
ruby
Ensure proxy class responds to all methods that underlying time instance responds to.
def respond_to_missing?(sym, include_priv) return false if sym.to_sym == :acts_like_date? time.respond_to?(sym, include_priv) end
Ensure proxy class responds to all methods that underlying time instance responds to. def respond_to_missing?(sym, include_priv) return false if sym.to_sym == :acts_like_date? time.respond_to?(sym, include_priv) end
50
86
145
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
d8efe13b0088dc6fe0a209c3390387761c96875ac30b04d8ce068415e6cc63b6
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
af27c1fcee2d2b0df01b3e6e
rails/rails
activesupport/lib/active_support/time_with_zone.rb
ActiveSupport.TimeWithZone.method_missing
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/time_with_zone.rb#L520-L524
train
ruby
Send the missing method to +time+ instance, and wrap result in a new TimeWithZone with the existing +time_zone+.
def method_missing(sym, *args, &block) wrap_with_time_zone time.__send__(sym, *args, &block) rescue NoMethodError => e raise e, e.message.sub(time.inspect, inspect), e.backtrace end
Send the missing method to +time+ instance, and wrap result in a new TimeWithZone with the existing +time_zone+. def method_missing(sym, *args, &block) wrap_with_time_zone time.__send__(sym, *args, &block) rescue NoMethodError => e raise e, e.message.sub(time.inspect, inspect), e.backtrace end
82
113
201
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
68c6bc8e0a235db2ba3790ae135415f2d5524ce03be7de9de873117c7bc7cd99
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
80bf55a814d50fb6c861dd99
rails/rails
actionpack/lib/abstract_controller/base.rb
AbstractController.Base.process
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/actionpack/lib/abstract_controller/base.rb#L127-L137
train
ruby
Calls the action going through the entire action dispatch stack. The actual method that is called is determined by calling #method_for_action. If no method can handle the action, then an AbstractController::ActionNotFound error is raised. ==== Returns * <tt>self</tt>
def process(action, *args) @_action_name = action.to_s unless action_name = _find_action_name(@_action_name) raise ActionNotFound, "The action '#{action}' could not be found for #{self.class.name}" end @_response_body = nil process_action(action_name, *args) end
Calls the action going through the entire action dispatch stack. The actual method that is called is determined by calling #method_for_action. If no method can handle the action, then an AbstractController::ActionNotFound error is raised. ==== Returns * <tt>self</tt> def process(action, *args) @_action_na...
130
274
307
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
d96d061ae3dcef0ec7a727557c0e45305194e8f5fdeca4aee5921e932fa4e1d3
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
8ca8fcdf490a9a78c20e1782
rails/rails
activesupport/lib/active_support/array_inquirer.rb
ActiveSupport.ArrayInquirer.any?
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activesupport/lib/active_support/array_inquirer.rb#L25-L33
train
ruby
Passes each element of +candidates+ collection to ArrayInquirer collection. The method returns true if any element from the ArrayInquirer collection is equal to the stringified or symbolized form of any element in the +candidates+ collection. If +candidates+ collection is not given, method returns true. variant...
def any?(*candidates) if candidates.none? super else candidates.any? do |candidate| include?(candidate.to_sym) || include?(candidate.to_s) end end end
Passes each element of +candidates+ collection to ArrayInquirer collection. The method returns true if any element from the ArrayInquirer collection is equal to the stringified or symbolized form of any element in the +candidates+ collection. If +candidates+ collection is not given, method returns true. variant...
176
569
206
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
534bc5e155814925ee93202b9cd859a9ad5ed986e322099eeea0fa87ce249fb3
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
a04bf6d1c7167d44078058f1
rails/rails
activerecord/lib/active_record/integration.rb
ActiveRecord.Integration.cache_key
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/integration.rb#L72-L89
train
ruby
Returns a stable cache key that can be used to identify this record. Product.new.cache_key # => "products/new" Product.find(5).cache_key # => "products/5" If ActiveRecord::Base.cache_versioning is turned off, as it was in Rails 5.1 and earlier, the cache key will also include a version. Product.cache_...
def cache_key if new_record? "#{model_name.cache_key}/new" else if cache_version "#{model_name.cache_key}/#{id}" else timestamp = max_updated_column_timestamp if timestamp timestamp = timestamp.utc.to_s(cache_timestamp_format) "#...
Returns a stable cache key that can be used to identify this record. Product.new.cache_key # => "products/new" Product.find(5).cache_key # => "products/5" If ActiveRecord::Base.cache_versioning is turned off, as it was in Rails 5.1 and earlier, the cache key will also include a version. Product.cache_...
204
424
465
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
267430e63a754a421717c67a4b84e447ee027eb5ea22c69be5ff486551139c3e
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
4e21df07a07a6d0a9cd376a3
rails/rails
activerecord/lib/active_record/integration.rb
ActiveRecord.Integration.cache_version
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/integration.rb#L97-L112
train
ruby
Returns a cache version that can be used together with the cache key to form a recyclable caching scheme. By default, the #updated_at column is used for the cache_version, but this method can be overwritten to return something else. Note, this method will return nil if ActiveRecord::Base.cache_versioning is set to ...
def cache_version return unless cache_versioning if has_attribute?("updated_at") timestamp = updated_at_before_type_cast if can_use_fast_cache_version?(timestamp) raw_timestamp_to_cache_version(timestamp) elsif timestamp = updated_at timestamp.utc.to_s(cache_time...
Returns a cache version that can be used together with the cache key to form a recyclable caching scheme. By default, the #updated_at column is used for the cache_version, but this method can be overwritten to return something else. Note, this method will return nil if ActiveRecord::Base.cache_versioning is set to ...
185
370
521
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
d1aa20781aaf519f772f6cacebf6883893eaad85198c084e69145bb6fc82771a
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
406f38e1a9ba4f369dbe0273
rails/rails
activerecord/lib/active_record/integration.rb
ActiveRecord.Integration.raw_timestamp_to_cache_version
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/activerecord/lib/active_record/integration.rb#L198-L205
train
ruby
Converts a raw database string to `:usec` format. Example: timestamp = "2018-10-15 20:02:15.266505" raw_timestamp_to_cache_version(timestamp) # => "20181015200215266505" PostgreSQL truncates trailing zeros, https://github.com/postgres/postgres/commit/3e1beda2cde3495f41290e1ece5d544525810214 to account ...
def raw_timestamp_to_cache_version(timestamp) key = timestamp.delete("- :.") if key.length < 20 key.ljust(20, "0") else key end end
Converts a raw database string to `:usec` format. Example: timestamp = "2018-10-15 20:02:15.266505" raw_timestamp_to_cache_version(timestamp) # => "20181015200215266505" PostgreSQL truncates trailing zeros, https://github.com/postgres/postgres/commit/3e1beda2cde3495f41290e1ece5d544525810214 to account ...
152
357
189
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
99a2e061e2cb623907eaeee8521c770d33f426890f3bc57fb491b34c3f8f04ad
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
14e5e7b4ff61d47dcd27a3ab
rails/rails
actionmailer/lib/action_mailer/mail_helper.rb
ActionMailer.MailHelper.block_format
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/actionmailer/lib/action_mailer/mail_helper.rb#L20-L30
train
ruby
Take the text and format it, indented two spaces for each line, and wrapped at 72 columns: text = <<-TEXT This is the paragraph. * item1 * item2 TEXT block_format text # => " This is the paragraph.\n\n * item1\n * item2\n"
def block_format(text) formatted = text.split(/\n\r?\n/).collect { |paragraph| format_paragraph(paragraph) }.join("\n\n") # Make list points stand on their own line formatted.gsub!(/[ ]*([*]+) ([^*]*)/) { " #{$1} #{$2.strip}\n" } formatted.gsub!(/[ ]*([#]+) ([^#]*)/) { " #{$1} #...
Take the text and format it, indented two spaces for each line, and wrapped at 72 columns: text = <<-TEXT This is the paragraph. * item1 * item2 TEXT block_format text # => " This is the paragraph.\n\n * item1\n * item2\n" def block_format(text) formatted = text.split(/\n\r...
190
261
360
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
cb42ddaa23745f7d5359fb9a501c1707985815e7eb1a1e446fb49c4639b68cbc
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
2f68ccb23e4ce90d4995b990
rails/rails
actionmailer/lib/action_mailer/mail_helper.rb
ActionMailer.MailHelper.format_paragraph
https://github.com/rails/rails/blob/85a8bc644be69908f05740a5886ec19cd3679df5/actionmailer/lib/action_mailer/mail_helper.rb#L55-L70
train
ruby
Returns +text+ wrapped at +len+ columns and indented +indent+ spaces. By default column length +len+ equals 72 characters and indent +indent+ equal two spaces. my_text = 'Here is a sample text with more than 40 characters' format_paragraph(my_text, 25, 4) # => " Here is a sample text with\n more than...
def format_paragraph(text, len = 72, indent = 2) sentences = [[]] text.split.each do |word| if sentences.first.present? && (sentences.last + [word]).join(" ").length > len sentences << [word] else sentences.last << word end end indentation = " " * in...
Returns +text+ wrapped at +len+ columns and indented +indent+ spaces. By default column length +len+ equals 72 characters and indent +indent+ equal two spaces. my_text = 'Here is a sample text with more than 40 characters' format_paragraph(my_text, 25, 4) # => " Here is a sample text with\n more than...
193
335
430
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
f46f7f36424d3bdeba4c2e83cde9802b9898a5643c233ea5e1d2f889101a86df
MIT
permissive
https://github.com/rails/rails/blob/main/MIT-LICENSE
End of preview. Expand in Data Studio

CodeSearchNet Ruby — permissive licences only

Working copy (2026-12-05). Derived from the official code-search-net/code_search_net ruby configuration, keeping only repositories whose audited SPDX licence is permissive.

  • 47,412 rows, 5,681 repositories
  • 36,477,137 characters, 8,596,026 tokens (tiktoken cl100k_base)
  • parquet 25,139,384 bytes (zstd), 20 columns
  • splits: train 43,430 · validation 1,922 · test 2,060
  • removed 3,362 non-permissive rows and 2,497 rows without a detected licence.

Full datasheet: datasheet.md.

Licences (rows)

SPDX rows %
MIT 40,939 86.3%
Apache-2.0 4,800 10.1%
BSD-3-Clause 841 1.8%
BSD-2-Clause 570 1.2%
ISC 163 0.3%
CC0-1.0 67 0.1%
WTFPL 24 0.1%
Zlib 8 0.0%

Schema

id, repo, path, func_name, url, split, language, docstring, code, text,
token_count, doc_chars, code_chars, license_basis, source, added,
record_sha256, license, license_class, license_source

text = docstring + \n\n + code. id is unique. record_sha256 is the canonical per-row SHA-256.

Rights

  • Every retained row has an audited permissive SPDX licence in license (license_class == "permissive", license_source = GitHub licence URL).
  • No copyleft and no NOASSERTION/unknown.
  • Permissive is not obligation-free: Apache-2.0 requires NOTICE/attribution; MIT/BSD require the copyright notice. This is not legal advice.

Not checked

  • Whether GitHub's LICENSE-file detection matches the repo's actual terms.
  • Notice/attribution preservation for Apache-2.0/BSD rows.
  • Cross-corpus dedup against other code corpora.
  • PII in code/docstrings; no scrubber was run.

Authors

Piotr Styła (SlayerLab / Fabryka AI), 2026. See CITATION.cff.

Citation

If you use this dataset, cite it via CITATION.cff (or the Hugging Face dataset page). Upstream code should be cited/attributed via the repo and url fields.

Dataset licence

Curation, selection and metadata: CC-BY-4.0 (see LICENSE). Code and documentation remain under their upstream licences, recorded per row in license / license_source; see NOTICE, ATTRIBUTION.md and LICENSES/.

Downloads last month
-