{"added": "2026-12-05", "author": "ThoughtWorksStudios/oauth2_provider", "created": "2019", "id": "03c3078910d0b30c2e552272", "license": "MIT", "source": "code_search_net", "text": "List nesting is implicit given the level of\n Make it explicit, just to make life a tad\n easier for the output processors\n\ndef add_list_start_and_ends\n level = 0\n res = []\n type_stack = []\n\n @fragments.each do |fragment|\n # $stderr.puts \"#{level} : #{fragment.class.name} : #{fragment.level}\"\n new_level = fragment.level\n while (level < new_level)\n level += 1\n type = fragment.type\n res << ListStart.new(level, fragment.param, type) if type\n type_stack.push type\n # $stderr.puts \"Start: #{level}\"\n end\n\n while level > new_level\n type = type_stack.pop\n res << ListEnd.new(level, type) if type\n level -= 1\n # $stderr.puts \"End: #{level}, #{type}\"\n end\n\n res << fragment\n level = fragment.level\n end\n level.downto(1) do |i|\n type = type_stack.pop\n res << ListEnd.new(i, type) if type\n end\n\n @fragments = res\n end", "token_count": 247} {"added": "2026-12-05", "author": "voltrb/volt", "created": "2019", "id": "770ccbf6f699d3e5bf9667b3", "license": "MIT", "source": "code_search_net", "text": "Assign multiple attributes as a hash, directly.\n\ndef assign_attributes(attrs, initial_setup = false, skip_changes = false)\n attrs = wrap_values(attrs)\n\n if attrs\n # When doing a mass-assign, we don't validate or save until the end.\n if initial_setup || skip_changes\n Model.no_change_tracking do\n assign_all_attributes(attrs, skip_changes)\n end\n else\n assign_all_attributes(attrs)\n end\n else\n # Assign to empty\n @attributes = {}\n end\n\n # Trigger and change all\n @deps.changed_all!\n @deps = HashDependency.new\n\n run_initial_setup(initial_setup)\n end", "token_count": 140} {"added": "2026-12-05", "author": "Azure/azure-sdk-for-ruby", "created": "2019", "id": "ef16966be5d04aebb77d721d", "license": "MIT", "source": "code_search_net", "text": "Gets all deployments for a remediation at subscription scope.\n\n @param remediation_name [String] The name of the remediation.\n @param query_options [QueryOptions] Additional parameters for the operation\n @param custom_headers [Hash{String => String}] A hash of custom headers that\n will be added to the HTTP request.\n\n @return [Array] operation results.\n\ndef list_deployments_at_subscription(remediation_name, query_options:nil, custom_headers:nil)\n first_page = list_deployments_at_subscription_as_lazy(remediation_name, query_options:query_options, custom_headers:custom_headers)\n first_page.get_all_items\n end", "token_count": 137} {"added": "2026-12-05", "author": "rails/rails", "created": "2019", "id": "2ffbe4a3e5d6983fad6a010b", "license": "MIT", "source": "code_search_net", "text": "Expose one or more attributes within a block. Old values are returned after the block concludes.\n Example demonstrating the common use of needing to set Current attributes outside the request-cycle:\n\n class Chat::PublicationJob < ApplicationJob\n def perform(attributes, room_number, creator)\n Current.set(person: creator) do\n Chat::Publisher.publish(attributes: attributes, room_number: room_number)\n end\n end\n end\n\ndef set(set_attributes)\n old_attributes = compute_attributes(set_attributes.keys)\n assign_attributes(set_attributes)\n yield\n ensure\n assign_attributes(old_attributes)\n end", "token_count": 122} {"added": "2026-12-05", "author": "jomalley2112/controller_scaffolding", "created": "2019", "id": "51fe1a6e82f75d62be766b34", "license": "MIT", "source": "code_search_net", "text": "This method seems to always get run first\n\ndef copy_view_files #do NOT change the name of this method \n # it must be overriding an existing one in a parent class\n base_path = File.join(\"app/views\", class_path, file_name)\n #binding.pry\n empty_directory base_path\n @actions = actions.nil? || actions.empty? ? %w(index new create edit update destroy) : actions\n @attr_cols = GeneratorUtils::attr_cols(table_name)\n @col_count = @attr_cols.count\n @col_count += 1 if @actions.include?(\"edit\")\n @col_count += 1 if @actions.include?(\"destroy\")\n @search_sort = options.search_sort?\n (@actions - %w(create update destroy)).each do |action|\n @action = action\n formats.each do |format|\n @path = File.join(base_path, filename_with_extensions(action, format))\n set_template(@action, @path)\n end\n end\n end", "token_count": 210} {"added": "2026-12-05", "author": "mitchellh/virtualbox", "created": "2019", "id": "0083d953dfef5166d7addf47", "license": "MIT", "source": "code_search_net", "text": "Destroys the port forwarding mapping.\n\n @return [Boolean] True if command was successful, false otherwise.\n\ndef destroy(update_collection=true)\n return if new_record?\n previous_name = name_changed? ? name_was : name\n parent.modify_engine do |nat|\n nat.remove_redirect(previous_name)\n end\n parent_collection.delete(self, true) if parent_collection && update_collection\n new_record!\n true\n end", "token_count": 88} {"added": "2026-12-05", "author": "contentful/contentful.rb", "created": "2019", "id": "5d2abf217bf86eb4412ac693", "license": "MIT", "source": "code_search_net", "text": "Simplifies pagination\n\n @return [Contentful::Array, false]\n\ndef next_page(client = nil)\n return false if client.nil?\n return false if items.first.nil?\n\n new_skip = (skip || 0) + (limit || DEFAULT_LIMIT)\n\n plurals = {\n 'Space' => 'spaces',\n 'ContentType' => 'content_types',\n 'Entry' => 'entries',\n 'Asset' => 'assets',\n 'Locale' => 'locales'\n }\n client.public_send(plurals[items.first.type], limit: limit, skip: new_skip)\n end", "token_count": 125}