query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Returns the bottom position number in the list. bottom_position_in_list => 2 | def bottom_position_in_list(except = nil)
item = bottom_item(except)
item ? item.send(:position) : 0
end | [
"def bottom_position_in_list(except = nil)\n item = bottom_item(except)\n item ? item.position : 0\n end",
"def bottom_position_in_list(except = nil)\n item = bottom_item(except)\n item ? item.send(position_column) : 0\n end",
"def assume_bottom_position\n set_list... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Use equivalentxml to determine equivalence | def equivalent_nokogiri(other)
if defined?(::EquivalentXml)
EquivalentXml.equivalent?(object, other.object)
else
equivalent_rexml(other)
end
end | [
"def equivalent_nodes(node_1, node_2)\n EquivalentXml.equivalent?(node_1,\n node_2,\n element_order: false,\n normalize_whitespace: true,\n ignore_attr_values: ['version', 'xmlns', 'xmlns:xsi', 'sc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Simple equivalence test for REXML | def equivalent_rexml(other)
begin
require 'active_support'
require 'active_support/core_ext'
rescue LoadError
# string equivalence
end
if Hash.respond_to?(:from_xml)
Hash.from_xml("<root>#{self}</root>") == Hash.from_xml("<root>#{other}</root>")
else
... | [
"def xml_cmp a, b\n a = REXML::Document.new(a.to_s)\n b = REXML::Document.new(b.to_s)\n\n normalized = Class.new(REXML::Formatters::Pretty) do\n def write_text(node, output)\n super(node.to_s.strip, output)\n end\n end\n\n normalized.new(indentation=0,ie_hack=false).write(node=a, a_normalize... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Affiche en console la liste des instances | def show_list
clear
puts "= LISTE DES INSTANCES #{name} =".bleu
puts "\n\n"
len_delim = defined?(LIST_ENTETE) ? LIST_ENTETE.length + 2 : 80
delim = ("-"*len_delim).bleu
if defined?(LIST_ENTETE)
puts delim
puts LIST_ENTETE
end
puts delim
all.each do |inst|
puts " #{inst.to_console}"
end
... | [
"def print_instances_details(only_running=true)\n @groups.values.each_with_index do |instances, i|\n instances.each do |instance|\n if only_running and (not instance.ready?)\n next\n end\n puts sprintf \"%02d: %-20s %-20s %-20s %-20s %-25s %-20s (%s) (%s) (%s)\",\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /fhir_base_urls GET /fhir_base_urls.json | def index
@fhir_base_urls = FhirBaseUrl.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @fhir_base_urls }
end
end | [
"def base_urls\n return @base_urls\n end",
"def base_urls=(value)\n @base_urls = value\n end",
"def base_url\n return url\n end",
"def base_url_path; end",
"def base_uri(endpoint)\n \"https://www.bloc.io/api/v1/#{endpoint}\"\n end",
"def base_url... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /fhir_base_urls/new GET /fhir_base_urls/new.json | def new
@fhir_base_url = FhirBaseUrl.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @fhir_base_url }
end
end | [
"def new\n @base_url = BaseUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @base_url }\n end\n\n end",
"def create\n @fhir_base_url = FhirBaseUrl.new(params[:fhir_base_url])\n\n respond_to do |format|\n if @fhir_base_url.save\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /fhir_base_urls POST /fhir_base_urls.json | def create
@fhir_base_url = FhirBaseUrl.new(params[:fhir_base_url])
respond_to do |format|
if @fhir_base_url.save
format.html { redirect_to @fhir_base_url, notice: 'Fhir base url was successfully created.' }
format.json { render json: @fhir_base_url, status: :created, location: @fhir_base... | [
"def index\n @fhir_base_urls = FhirBaseUrl.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fhir_base_urls }\n end\n end",
"def base_urls=(value)\n @base_urls = value\n end",
"def create\n @base_url = BaseUrl.new(params[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /fhir_base_urls/1 PUT /fhir_base_urls/1.json | def update
@fhir_base_url = FhirBaseUrl.find(params[:id])
respond_to do |format|
if @fhir_base_url.update_attributes(params[:fhir_base_url])
format.html { redirect_to @fhir_base_url, notice: 'Fhir base url was successfully updated.' }
format.json { head :no_content }
else
fo... | [
"def update\n @base_url = BaseUrl.find(params[:id])\n\n respond_to do |format|\n if @base_url.update_attributes(params[:base_url])\n format.html { redirect_to @base_url, notice: 'Base url was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { rend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /fhir_base_urls/1 DELETE /fhir_base_urls/1.json | def destroy
begin
@fhir_base_url = FhirBaseUrl.find(params[:id])
@fhir_base_url.destroy
rescue ActiveRecord::DeleteRestrictionError
flash[:"alert-danger"] = "Could not delete the URL because there are resources assigned to it."
redirect_to resources_path
return
end
respond... | [
"def destroy\n @base_url = BaseUrl.find(params[:id])\n @base_url.destroy\n\n respond_to do |format|\n format.html { redirect_to base_urls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @basis = Base.find(params[:id])\n @basis.destroy\n\n respond_to do |format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /reports GET /reports.xml | def index
@reports = Report.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @reports }
end
end | [
"def index\n @daily_reports = DailyReport.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @daily_reports }\n end\n end",
"def reports\n collection(\"reports\")\n end",
"def index\n @reports = report_model.all\n\n respond_to do... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /reports/1 PUT /reports/1.xml | def update
@report = Report.find(params[:id])
respond_to do |format|
if @report.update_attributes(params[:report])
format.html { redirect_to(@report, :notice => 'Report was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
... | [
"def update\n @report_request = ReportRequest.find(params[:id])\n\n @report_request.update_attributes(params[:report_request])\n \n respond_to do |format|\n format.html # update.html.erb\n if @report_request.errors.empty?\n format.xml { head :ok }\n else\n format.xml { ren... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return if a dataset with provided name exists | def dataset?(name)
datasets.key?(name)
end | [
"def data_source_exists?(name)\n query_values(data_source_sql(name), \"SCHEMA\").any? if name.present?\n rescue NotImplementedError\n data_sources.include?(name.to_s)\n end",
"def data_source_exists?(name); end",
"def data_has? data, name\n data.has_key?(name) || data.has_key?(name.to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Private: Fail the check if ActiveRecord cannot check migration status | def unsupported
mark_failure
mark_message "This version of ActiveRecord does not support checking whether migrations are pending"
end | [
"def migration_error?\n render :migration_error unless ENV[\"DB_MIGRATE_FAILED\"].blank?\n end",
"def migration_error?\n render :migration_error, status: 500 unless ENV[\"DB_MIGRATE_FAILED\"].blank?\n end",
"def migrate?\n raise NotImplementedError\n end",
"def supports_migrations?\n fa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make sure a pitch fits in the key's allowed range. | def check_pitch pitch
raise ArgumentError, "pitch is less than pitch range min" if pitch < @pitch_range.min
raise ArgumentError, "pitch is more than pitch range max" if pitch > @pitch_range.max
end | [
"def validate_private_key_range(private_key)\n value = private_key.to_i(16)\n MIN_PRIV_KEY_MOD_ORDER <= value && value <= MAX_PRIV_KEY_MOD_ORDER\n end",
"def include? pitch\n self.old_include?(pitch % 12)\n end",
"def key_length_valid?(number)\n number >= 1024 && number & (number - 1) == 0... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /datasets/1 GET /datasets/1.xml GET /dataset/1.eml | def show
@dataset = Dataset.find(params[:id])
@title = @dataset.title
@roles = @dataset.roles
respond_to do |format|
format.html # show.rhtml
format.eml { render :xml => @dataset.to_eml }
format.xml { render :xml => @dataset.to_xml }
end
end | [
"def index\n @datasets = Dataset.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @datasets }\n end\n end",
"def show\n @dataset = Dataset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /datasets/1 PUT /datasets/1.xml | def update
@dataset = Dataset.find(params[:id])
respond_to do |format|
if @dataset.update_attributes(params[:dataset])
flash[:notice] = 'Dataset was successfully updated.'
format.html { redirect_to dataset_url(@dataset) }
format.xml { head :ok }
else
format.html { r... | [
"def update\n\t\t@dataset = VOID::Dataset.find(params[:id])\n\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n flash[:notice] = 'Dataset was successfully updated.'\n format.html { redirect_to(datasets_url) }\n format.xml { head :ok }\n else\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /dairies GET /dairies.json | def index
@dairies = Dairy.all
end | [
"def index\n @dices = Dice.all\n render json: @dices\n end",
"def index\n @dices = Dice.all\n\n render json: @dices\n end",
"def index\n @dairies = Dairy.all\n end",
"def index\n @dioceses = Diocese.all\n\n render json: @dioceses\n end",
"def index\n @my_dairies = MyDairy.all\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Clean the changed paths and return only valid PHPUnit tests files. | def clean(paths)
paths.uniq!
paths.compact!
populate_test_files
paths = paths.select { |p| test_file?(p) }
clear_tests_files_list
paths
end | [
"def clean_tests\n puts \"Removing generated tests from '#{Settings[:test_dir]}'...\"\n Dir.foreach(Settings[:test_dir]) do |dir|\n path = Pathname.new(Settings[:test_dir]) + dir\n next if dir == '.' or dir == '..' or dir == 'support' or not path.directory?\n FileUtils.rm_rf(path)\n end\nend",
"def re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if the paths is a valid test file. | def test_file?(path)
@tests_files.include?(path)
end | [
"def check_valid_paths(paths)\n\t\t\t\n\t\t\tpaths.each { |p|\n\t\t\t\tif p =~ /\\s/\n\t\t\t\t\n\t\t\t\t\tTextMate::HTMLOutput.show(:title => \"FCSH Path Error\", :sub_title => \"\" ) do |io|\n\n\t\t\t\t\t\tio << \"<h2>FCSH Path Error</h2>\"\n\t\t\t\t\t\tio << \"<p>Warning fsch cannot handle paths containing a spac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A constructor that requires both the IP address of the machine to communicate with as well as the secret (string) needed to perform communication. AppControllers will reject SOAP calls if this secret (basically a password) is not present it can be found in the user's .appscale directory, and a helper method is usually ... | def initialize(ip, secret)
@ip = ip
@secret = secret
@conn = SOAP::RPC::Driver.new("https://#{@ip}:17443")
@conn.add_method("set_parameters", "djinn_locations", "database_credentials", "app_names", "secret")
@conn.add_method("set_apps", "app_names", "secret")
@conn.add_method("set_apps_to_r... | [
"def initialize(ip, secret)\n @ip = ip\n @secret = secret\n \n @conn = SOAP::RPC::Driver.new(\"https://#{@ip}:#{SERVER_PORT}\")\n @conn.add_method(\"start_job\", \"jobs\", \"secret\")\n @conn.add_method(\"put_input\", \"job_data\", \"secret\")\n @conn.add_method(\"get_output\", \"job_data\", \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Provides automatic retry logic for transient SOAP errors. Args: time: A Fixnum that indicates how long the timeout should be set to when executing the caller's block. retry_on_except: A boolean that indicates if nontransient Exceptions should result in the caller's block being retried or not. callr: A String that names... | def make_call(time, retry_on_except, callr)
refused_count = 0
max = 5
begin
Timeout::timeout(time) {
yield if block_given?
}
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
if refused_count > max
raise FailedNodeException.new("Connection was refused. Is the " +
... | [
"def try times = 1, options = {}, &block\n val = yield\n rescue options[:on] || Exception\n retry if (times -= 1) > 0\n else\n val\n end",
"def retry_on_transient_error\n (options.retry_count.to_i + 1).times do |n|\n logger.debug \"Attempt ##{n}\"\n begin\n result = yield\n re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tells an AppController that it needs to restart one or more Google App Engine applications. Args: app_names: An Array of Strings, where each String is an appid corresponding to an application that needs to be restarted. | def set_apps_to_restart(app_names)
make_call(NO_TIMEOUT, RETRY_ON_FAIL, "set_apps_to_restart") {
@conn.set_apps_to_restart(app_names, @secret)
}
end | [
"def restart_appengine_apps\n # use a copy of @apps_to_restart here since we delete from it in\n # setup_appengine_application\n apps = @apps_to_restart\n apps.each { |app_name|\n if !my_node.is_login? # this node has the new app - don't erase it here\n Djinn.log_info(\"Removing old version... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tells an AppController to no longer route HAProxy traffic to the given location. Args: app_id: A String that identifies the application that runs the AppServer to remove. ip: A String that identifies the private IP address where the AppServer to remove runs. port: A Fixnum that identifies the port where the AppServer w... | def remove_appserver_from_haproxy(app_id, ip, port)
make_call(NO_TIMEOUT, RETRY_ON_FAIL, "remove_appserver_from_haproxy") {
@conn.remove_appserver_from_haproxy(app_id, ip, port, @secret)
}
end | [
"def remove_appserver_from_haproxy(app_id, ip, port, secret)\n if !valid_secret?(secret)\n return BAD_SECRET_MSG\n end\n\n if !my_node.is_login?\n return NO_HAPROXY_PRESENT\n end\n\n Djinn.log_debug(\"Removing AppServer for app #{app_id} at #{ip}:#{port}\")\n get_scaling_info_for_app(app... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
creates a audit log record instance that each method model will use | def initialize_audit_log
# only save logs for POST,PUT,PATCH and DELETE methods
# creates
if (request.post? || request.patch? || request.put? || request.delete? )
@audit_log = AuditLog.new
@audit_log.ip = request.remote_ip
@audit_log.user_name = current_user.full_name
end
end | [
"def audit_log\n AuditLog.new(space_id, store_id)\n end",
"def build_created_audit(rec, eh)\n build_audit_payload(rec, eh[:new], nil, \"#{rec.class.to_s.downcase}_record_add\", \"Record created\")\n end",
"def audit_create\n action_name = get_action_name('create')\n write_audit(action:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
saves the initialzied audit log | def save_audit_log
if (@audit_log && @audit_log.auditable)
if ["update","destroy"].include?(action_name)
update_and_destroy_audit
elsif action_name == "create"
create_audit
end
end
end | [
"def set_audit_log_data\n @audit_log.auditable = @job if @audit_log\n end",
"def save_with_auditing\n with_auditing { save }\n end",
"def initialize_audit_log\n # only save logs for POST,PUT,PATCH and DELETE methods\n # creates\n if (request.post? || request.patch? || request.put? |... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse locations of chunks Offset: bytes 0 2 Sectors: byte 3 Empty offset, is an empty chunk | def locations
@locations ||= bytes(L_BYTES).each_slice(4).map do |loc_bytes|
{
offset: ByteArray.to_i(loc_bytes[0..2]),
sector_count: loc_bytes[3]
}
end.reject{ |l| l[:offset] == 0 }
end | [
"def data_chunk_start_pos\n read_page_header_and_data_chunk_start unless defined? @data_chunk_start\n\n @data_chunk_start\n end",
"def get_line_and_column_from_chunk(offset)\n if offset.zero?\n return [@chunk_line, @chunk_column]\n end\n\n string =\n offset >= @chunk.size ? @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Timestamps are 4 bytes read with Timeat | def timestamps
@timestamps ||= bytes[T_BYTES].each_slice(4).map do |t_bytes|
ByteArray.to_i(t_bytes)
end.reject{ |t| t == 0 }
end | [
"def read_timestamps\n FFMpeg.log.inject([]) do |array, log|\n array << (log[1] =~ /time=([\\w|\\.]+ )/ && [log[0], $1.to_f] || nil)\n end.compact\n end",
"def read(timestamp); []; end",
"def parse_timestamps\n self.keys.each do |key|\n self[key].map! do |timestamp| \n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
////////////////////////////////////////////////////////////////////////// Properties ////////////////////////////////////////////////////////////////////////// Get icon_index of the element GET | def icon_index()
return CORE_CONFIG::ELEMENT_ICONS[self.id]
end | [
"def icon_index(item)\n return $data_items[item.item_id].icon_index if item.item?\n return ($data_items.find { |i| !i.nil? && i.subtype_id == item.category_id}).icon_index if item.category?\n end",
"def icon\n return @icon\n end",
"def icon\n @icon\n end",
"def ImageList_E... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Allows for purchasing a product. Creates a new transaction with the proper data if the product is in stock. Takes a product and a date argument. The date can be passed as string "20160525" or as a date value type. The date defaults to today's date. | def purchase(product, date = Date.today)
date = date.is_a?(String) ? Date.parse(date) : date
if product.in_stock?
Transaction.new(self, product, date)
else
raise OutOfStockError, "'#{product.title}' is out of stock."
end
end | [
"def purchase(product)\n \t\tif product.in_stock?\n \t\t\tTransaction.new(self, product)\n \t\telse\n \t\t\traise OutOfStockError, \"#{product.title} is out of stock\"\n \t\tend\n \tend",
"def buying_a_product\n\t\t# Deleting all data from the database\n\t\tLineItem.delete_all\n\t\tOrder.delete_all\n\n\t\tr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Allows for returning a product. Checks if a transaction has been made in the store. It takes a product and a defect argument. The defect argument if true signals that the product bought has a defect. | def return_product(product, defect = false)
if Transaction.find_by(customer: self, product: product).empty?
raise NotRecordedTransactionError, "There was no such transaction recorded."
else
ProductReturn.new(self, product, defect)
end
end | [
"def call\n product = context.existing_product || context.product\n\n if product.used?\n context.fail!(error: I18n.t('inventory.product_is_used_already'))\n end\n end",
"def purchase(product)\n \t\tif product.in_stock?\n \t\t\tTransaction.new(self, product)\n \t\telse\n \t\t\traise Ou... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin This method checks if a user thumbed up this comment before Inputs: user who we want to check if he upped or not. Output: boolean true or false Author: Menisy =end | def upped_by_user?(user)
up = self.comment_up_downs.find_by_user_id_and_action(user.id,1) # get the up that a user gave to this comment before "if exists"
!up.nil? # if up is nil then return false if not then return true
end | [
"def downed_by_user?(user)\n down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) # get the down that a user gave to this comment before \"if exists\"\n !down.nil? # if down is nil then return false if not then return true\n end",
"def up_comment(user)\n upped_before = self.upped_by_user?(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin This method checks if a user thumbed down this comment before Inputs: user who we want to check if he upped or not. Output: boolean true or false Author: Menisy =end | def downed_by_user?(user)
down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) # get the down that a user gave to this comment before "if exists"
!down.nil? # if down is nil then return false if not then return true
end | [
"def upped_by_user?(user)\n up = self.comment_up_downs.find_by_user_id_and_action(user.id,1) # get the up that a user gave to this comment before \"if exists\"\n !up.nil? # if up is nil then return false if not then return true\n end",
"def up_comment(user)\n upped_before = self.upped_by_user?(user)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Returns number of ups for a comment Inputs: none Output: int number of ups Author: Menisy =end | def get_num_ups
ups = self.comment_up_downs.find_all_by_action(1).size
end | [
"def get_num_downs\n downs = self.comment_up_downs.find_all_by_action(2).size\n end",
"def comments_count\n 0\n end",
"def compute_comment_score(c)\n upcount = (c['up'] ? c['up'].length : 0)\n downcount = (c['down'] ? c['down'].length : 0)\n upcount-downcount\n end",
"def s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Returns number of downs for a comment Inputs: none Output: int number of downs Author: Menisy =end | def get_num_downs
downs = self.comment_up_downs.find_all_by_action(2).size
end | [
"def get_num_ups\n ups = self.comment_up_downs.find_all_by_action(1).size\n end",
"def compute_comment_score(c)\n upcount = (c['up'] ? c['up'].length : 0)\n downcount = (c['down'] ? c['down'].length : 0)\n upcount-downcount\n end",
"def comments_count\n 0\n end",
"def revie... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Ups a comment. Input: user who is upping the comment. Output: boolean indicating success or failure Author: Menisy =end | def up_comment(user)
upped_before = self.upped_by_user?(user)
downed_before = self.downed_by_user?(user)
if !upped_before && !downed_before then #if user never upped or downed the comment then up it
up = CommentUpDown.new(:action => 1)
up.comment = self
up.user = user
up.save
u... | [
"def up_comment\n comment = Comment.find(params[:comment_id])\n upped = comment.up_comment(current_user)\n if upped \n redirect_to :action => \"get\" ,:id => params[:id]\n else\n flash[:notice] = \"Temporary error has occured $red\"\n redirect_to :action => \"get\" ,:id => params[:id]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Downs a comment. Input: user who is downing the comment. Output: boolean indicating success or failure Author: Menisy =end | def down_comment(user)
upped_before = self.upped_by_user?(user)
downed_before = self.downed_by_user?(user)
if !upped_before && !downed_before then #if user never upped or downed the comment then up it
down = CommentUpDown.new(:action => 2)
down.comment = self
down.user = user
down.sa... | [
"def downed_by_user?(user)\n down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) # get the down that a user gave to this comment before \"if exists\"\n !down.nil? # if down is nil then return false if not then return true\n end",
"def downcomment\n comm = Comment.find_by_id(params[:id])\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Description: This story is mainly used in the notification system to summarize the content of the comment to fit within a certain length input: char_num:Int which is the number of chars it will be summarized to output: String > The summarized String Author: Kiro =end | def summarize_content (char_num)
if self.content.length <= char_num
return self.content
else return self.content[0..(char_num-1)] + "..."
end
end | [
"def summarize_title (char_num)\n if self.title.length <= char_num\n return self.title\n else return self.title[0..(char_num-1)] + \"...\"\n end\n end",
"def comment_length\n\t120\nend",
"def summarize(length = SUMMARY_LENGTH)\n summary = text.mb_chars.slice(0, length).to_s\n summary << ('…... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Field assigments Assigns the tweet's fields from a Twitter status object Returns the tweet record without saving it and persisting the changes to the database | def assign_fields(status)
self.text = expand_urls(status.text, status.urls)
self.in_reply_to_user_id = status.in_reply_to_user_id
self.in_reply_to_status_id = status.in_reply_to_status_id
self.source = status.source
self.lang = status.lang
self.retweet_count = status.retweet_count
self.favor... | [
"def find_or_create_tweet(status, author, twitter_account, state)\n tweet = tweets.where(twitter_id: status.id).first_or_initialize\n\n tweet.author = author\n tweet.twitter_account = twitter_account\n tweet.assign_state(state)\n\n # Saves the record\n tweet.update_fields_from_status(status)\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Assigns a certain workflow state given a symbol or string Knows about a whitelist of valid states | def assign_state(state)
state &&= state.try(:to_sym)
raise "Unknown state: #{ state }" unless Tweet.available_states.include?(state)
case state
when :conversation then self.state ||= state # do not override existing states with :conversation state
else self.state = state
end
end | [
"def state=(str)\n @address[:state] = simple_check_and_assign!(str)\n end",
"def WorkflowState(input, workflow, &block) # rubocop:disable Naming/MethodName\n result = case input\n when Sipity::WorkflowState\n input\n when Symbol, String\n WorkflowStat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Implement an instance method in your Ingredient class that helps check whether an ingredient is valid (i.e., contains only the ingredient names above)? | def allowed_ingredients
SAFE_INGREDIENTS.include?(name.downcase)
end | [
"def has_ingredient?(ingredient_name)\n ingredient_names.include?(ingredient_name)\n end",
"def has_ingredient?(name)\n ingredient(name).present?\n end",
"def must_have_ingredients\n unless ingredients.length > 0\n errors.add(:ingredients, \"must have at least one ingredient\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get the document an allowable privacy object for the document according to the db_tag raise if it is an invalid db_tag | def get_privacy db_tag
privacy_obj = privacy_objects.find{|p| p.db_tag == db_tag}
raise unless privacy_obj
return privacy_obj
end | [
"def set_privacy db_tag\r\n privacy_obj = privacy_objects.find{|p| p.db_tag == db_tag}\r\n raise unless privacy_obj\r\n self.update_attribute(\"privacy\",privacy_obj.db_tag)\r\n return privacy_obj\r\n end",
"def can_view_document(document)\n # allow access if user is logged in\n return... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set the document privacy according to the db_tag raise if it is an invalid db_tag | def set_privacy db_tag
privacy_obj = privacy_objects.find{|p| p.db_tag == db_tag}
raise unless privacy_obj
self.update_attribute("privacy",privacy_obj.db_tag)
return privacy_obj
end | [
"def get_privacy db_tag\r\n privacy_obj = privacy_objects.find{|p| p.db_tag == db_tag}\r\n raise unless privacy_obj\r\n return privacy_obj \r\n end",
"def doc_security=(v); end",
"def set_privacy(user=nil,level=0)\n # TODO finish and test\n # currently 0 = public, 1 = public but rea... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /subscriptions/1 PATCH/PUT /subscriptions/1.json | def update
@subscription = Subscription.find(params[:id])
if @subscription.update(subscription_params)
head :no_content
else
render json: @subscription.errors, status: :unprocessable_entity
end
end | [
"def update_subscription(subscription_id, params)\n request :patch,\n \"/v3/subscriptions/#{subscription_id}.json\",\n params\n end",
"def update\n @subscription = Subscription.get(params[:id])\n @subscription.update(params[:subscription])\n respond_with(@subscription.reload)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the vCloud data associated with vAppTemplate | def vcloud_attributes
Vcloud::Core::Fog::ServiceInterface.new.get_vapp_template(id)
end | [
"def get_vapp_template(vapp_id)\n end",
"def get_vapp_template(vAppId)\n params = {\n 'method' => :get,\n 'command' => \"/vAppTemplate/vappTemplate-#{vAppId}\"\n }\n\n response, headers = send_request(params)\n\n vapp_node = response.css('VAppTempla... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
stop_data contains any information we need for creating new stops. e.g. city id's stop time and ticket price | def update(stop_data)
@color = stop_data.fetch(:color, @color)
DB.exec("UPDATE trains SET color = '#{@color}' WHERE id = #{@id};")
times = stop_data.fetch(:times, [])
stop_data.fetch(:city_ids, []).each_with_index do |city_id, index|
DB.exec("INSERT INTO stops (train_id, city_id, time) VALUES (#{@... | [
"def create\n @stop = @tour.stops.build(stop_params)\n\n respond_to do |format|\n if @stop.save\n format.html { redirect_to tour_path(@tour), notice: \"Stop was successfully created.\" }\n format.json { render :show, status: :created, location: @stop }\n else\n format.html { ren... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
input = two arguments, a positive integer representing salary, and a boolean output = an integer representing bonus for salary rules: if boolean == true, bonus is half of salary if boolean == false, bonus is 0 test cases: what if salary is 0 and boolean is true? what if salary is an odd number, should integer or float ... | def calculate_bonus(salary, boolean)
boolean ? (salary.to_f / 2) : 0
end | [
"def calculate_bonus(salary, boolean)\n if boolean == true\n salary / 2\n else\n 0\n end\nend",
"def calculate_bonus(salary, bonus)\n if bonus == true\n salary / 2\n elsif bonus == false\n 0\n end\nend",
"def calculate_bonus salary, bool\n if bool == true\n salary/2\n else\n return 0... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /roster_squares/1/edit edit the behavior squares available to a student | def edit
@roster_square = RosterSquare.new
@roster_squares = RosterSquare.all
@student = Student.find_by_id(params[:id])
@student_squares = RosterSquare.where(student_id: @student.id)
@not_student_squares = []
#Set the squares for the specific school
@school_squares = Square.where(school_i... | [
"def update\n respond_to do |format|\n if @roster_square.update(roster_square_params)\n format.html { redirect_to @roster_square, notice: 'Roster square was successfully updated.' }\n format.json { render :show, status: :ok, location: @roster_square }\n else\n format.html { render ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if the square is used for the specific student. Unused at the moment | def is_student_square(square)
@is_square = false
@student_squares.each do |student_square|
if square.id == student_square.square_id
@is_square = true
break
end
if @is_square != true
@is_square = false
end
end
if @is_square == false
@no... | [
"def get_student_squares( student)\n the_squares = student.squares\n if the_squares.nil? || the_squares.empty?\n # no default squares for student, so use all squares at the school\n the_squares = Square.where(school_id: student.school_id)\n end\n the_squares\n end",
"def squ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get an Array of all scripts that have been imported into the Plot. | def imported_scripts
@imported_scripts ||= []
end | [
"def get_script_list\n @scripts = Dir.glob(\"#{@config[:scripts_directory]}/*.rb\")\n @scripts.map { |filename|\n filename[0...-3]\n }\n end",
"def modules_imported_script\n Array.new.tap { |scripts|\n scripts.concat bot_modules.usable(self).map(&:script)\n scripts.push self.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get an Array of the Plot's current Syntaxes. | def syntaxes
playbook.syntaxes
end | [
"def syntaxes\n Uv.syntaxes\n end",
"def list_syntaxes\n uri = URI.parse(\"#{BASE_URL}/syntaxes\")\n response = JSON.parse(@client.get(uri).body)\n return response['syntaxes'].map { |obj| Pastee::Syntax.new(obj) } if response['success']\n\n throw_error(response)\n end",
"def syntaxes\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return => An Array of Squirrel instances | def squirrels
# self.nests # what are my nests?
self.nests.map do |nest| # Nest instance
nest.squirrel
end
# binding.pry
# [#<Nest>, #<Nest>, #<Nest>]
# ||
# \/
# [#<Squirrel>, #<Squirrel>, #<Squirrel>]
end | [
"def my_squirrels\n my_nests.map do |nest|\n nest.squirrel\n end\n end",
"def index\n @squirrels = Squirrel.all\n end",
"def queries\n qrs = []\n self.each_query {|qr| qrs << qr }\n qrs\n end",
"def get_shelves\n shelves = [@shelf_ag, @shelf_hp, @shelf_qz]\n ret... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /job_requests/1 PUT /job_requests/1.json | def update
begin
@job_request = job_requests.find( params[ :id ] )
rescue ActiveRecord::RecordNotFound
@job_request = nil
end
respond_to do |format|
if @job_request && @job_request.update_attributes( params[ :job_request ] )
format.html { redirect_to root_path, notice: "Job Re... | [
"def update\r\n begin\r\n @job_request = @organization.job_requests.find( params[ :id ] )\r\n rescue ActiveRecord::RecordNotFound\r\n @job_request = nil\r\n end\r\n\r\n respond_to do |format|\r\n if @job_request && @job_request.update_attributes( params[ :job_request ] )\r\n format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
slurp CDS > Protein a.) common_data | def slurp_commondata(f)
var1=Hash.new
File.new(f,'r').each_line{|l|
l.chomp!
l.gsub!('"','')
cols= l.split(/\t/)
var1[cols[0]]=cols[1]
}
return var1
end | [
"def read_ICECommon\n # ICE_COMMON_FILE\n if @CTFile == nil\n ice_common_data = Common.file_read(\"#{ICE_COMMON_FILE}\")\n ice_common_data.each{|line|\n if line[0] != 35 && line.size != 0 # Comment Line\n @ICECommonSignal << line.split[0].strip\n end\n }\n @ICECommon... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes a string as argument, and returns the first Todo object that matches the argument. Return nil if no todo is found. | def find_by_title(str)
self.each do |todo|
return todo if todo.title == str
end
nil
# select { |todo| todo.title == str }.first # alt from solution
end | [
"def find_by_title(todo_title)\n select { |todo| todo.title == todo_title }.first\n end",
"def find_by_title(title)\n select { |todo| todo.title == title }.first\n end",
"def find(todo_id)\n sql = \"SELECT * FROM todos WHERE id=$1\"\n result = Repos.db_adapter.exec(sql, [todo_id])\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes a string as argument, and marks the first Todo object that matches the argument as done. | def mark_done(str)
todo = self.find_by_title(str)
todo.done! if todo
# find_by_title(str) && find_by_title(str).done! # alt from solution
end | [
"def mark_todo\n puts \"Which todo have you finished?\"\n action = get_input.to_i\n arr_index = 0\n @todos.each do |x|\n if x[\"completed\"] == \"no\"\n arr_index = arr_index + 1\n if arr_index == action\n x[\"completed\"] = \"yes\"\n save!\n break\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Mark every todo as done | def mark_all_done
self.each { |todo| todo.done! }
end | [
"def mark_all_done\n each {|todo| todo.done!}\n end",
"def mark_all_todos_as_done\n post('/todos/mark_as_done')\n end",
"def mark_as_done(todo)\n todo.mark_as_done!\n edit(todo)\n end",
"def mark_as_done(todo)\n @data_object.aff_to_do &= ~todo\n end",
"def mark_todo\n puts \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Move a +Tile+ on the +Map+. This movement action causes a chain reaction potentially moving (or killing) tiles down the map in that same direction. It does this by comparing each neighboring pair tile_1 > tile_2 tile_2 > tile_3 tile_3 > tile_4 And follows these rules empty tiles don't transfer movement enemies block en... | def move(tile, direction)
tiles = send(direction, tile)
move = []
tiles.each_cons(2) do |this, that|
break if this.empty?
# break move.clear if (tile == this) && this.enemy? && that.empty?
break move.clear if this.enemy? && that.enemy?
break move.c... | [
"def move_if_needed\n positions.each {|dir, pos|\n t = tile_at(pos)\n if t\n @direction, @position = directions.invert[dir], pos\n # Update the image so that the user actually sees the bug\n # turning if it did.\n update_image\n t.on\n return ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
show navbar date component | def show_header_date
I18n.localize(Date.today, format: :long)
end | [
"def navbar_date\n begin\n if @driver.find_element(:class, 'business-date pull-right').displayed?\n return @driver.find_element(:class, 'business-date pull-right')\n end\n rescue Selenium::WebDriver::Error::NoSuchElementError\n $results.info(\"Cannot find navbar date\")\n end\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Select all the paragraphs from the body text which are actual paragraphs (ie not headings). It's probably not an entirely accurate algorithm, but I think it's good enough for extracting the first paragraph to use as an excerpt. | def article_paragraphs(article)
source = article.file_descriptor.read
body = source.split("---\n", 3).last
body.split(/\n{2,}/).select { |paragraph| paragraph !~ /^#/ }
end | [
"def paragraphs s\n s.remall(@parreg).rems.map(&:to_s).map(&:strip).reject{|e| !e.match?(/\\w/)}\n end",
"def html_paragraphs(text)\n h(text).split(/\\n\\s*\\n/).collect { |para| \"<p>#{para}</p>\" }.join(\"\\n\")\n end",
"def parse_paragraphs(html)\n html.search('p').map { |p| pars... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the accessPackage property value. Access package containing this policy. Readonly. Supports $expand. | def access_package
return @access_package
end | [
"def access_package=(value)\n @access_package = value\n end",
"def access_package_id\n return @access_package_id\n end",
"def access_packages\n return @access_packages\n end",
"def access_packages=(value)\n @access_pa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the accessPackage property value. Access package containing this policy. Readonly. Supports $expand. | def access_package=(value)
@access_package = value
end | [
"def access_packages=(value)\n @access_packages = value\n end",
"def access_package_id=(value)\n @access_package_id = value\n end",
"def access_package_assignment_approvals=(value)\n @access_package_assignment_approvals = value\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the allowedTargetScope property value. Principals that can be assigned the access package through this policy. The possible values are: notSpecified, specificDirectoryUsers, specificConnectedOrganizationUsers, specificDirectoryServicePrincipals, allMemberUsers, allDirectoryUsers, allDirectoryServicePrincipals, all... | def allowed_target_scope
return @allowed_target_scope
end | [
"def allowed_target_scope=(value)\n @allowed_target_scope = value\n end",
"def policy_scope(target, options={})\n @_policy_scoped = true\n\n policy(target, options).scope\n end",
"def policy_scope(target, options={})\n policy(target, options).scope\n end",
"def request_acc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the allowedTargetScope property value. Principals that can be assigned the access package through this policy. The possible values are: notSpecified, specificDirectoryUsers, specificConnectedOrganizationUsers, specificDirectoryServicePrincipals, allMemberUsers, allDirectoryUsers, allDirectoryServicePrincipals, all... | def allowed_target_scope=(value)
@allowed_target_scope = value
end | [
"def allowed_target_scope\n return @allowed_target_scope\n end",
"def policy_scope(target, options={})\n @_policy_scoped = true\n\n policy(target, options).scope\n end",
"def request_access_for_allowed_targets=(value)\n @request_access_for_allowed_targets = value\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the automaticRequestSettings property value. This property is only present for an auto assignment policy; if absent, this is a requestbased policy. | def automatic_request_settings
return @automatic_request_settings
end | [
"def automatic_request_settings=(value)\n @automatic_request_settings = value\n end",
"def automatic_user_consent_settings\n return @automatic_user_consent_settings\n end",
"def request_approval_settings\n return @request_approval_settings\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the automaticRequestSettings property value. This property is only present for an auto assignment policy; if absent, this is a requestbased policy. | def automatic_request_settings=(value)
@automatic_request_settings = value
end | [
"def automatic_request_settings\n return @automatic_request_settings\n end",
"def automatic_user_consent_settings=(value)\n @automatic_user_consent_settings = value\n end",
"def automatic_replies_setting=(value)\n @automatic_replies_setting = va... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the catalog property value. Catalog of the access package containing this policy. Readonly. | def catalog
return @catalog
end | [
"def catalog=(value)\n @catalog = value\n end",
"def catalogs\n return @catalogs\n end",
"def catalog_type\n return @catalog_type\n end",
"def catalog_number\n self[:CatalogNumber]\n end",
"def catalogs=(value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the catalog property value. Catalog of the access package containing this policy. Readonly. | def catalog=(value)
@catalog = value
end | [
"def catalogs=(value)\n @catalogs = value\n end",
"def catalog_type=(value)\n @catalog_type = value\n end",
"def catalog_json=(str)\n @catalog_json = str\n @resource_hash = nil\n end",
"def save_catalog(catalog, options)\n if Puppet::Reso... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the customExtensionStageSettings property value. The collection of stages when to execute one or more custom access package workflow extensions. Supports $expand. | def custom_extension_stage_settings
return @custom_extension_stage_settings
end | [
"def custom_extension_stage_settings=(value)\n @custom_extension_stage_settings = value\n end",
"def stage_settings\n return @stage_settings\n end",
"def custom_settings\n return @custom_settings\n end",
"def custom_extension\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the customExtensionStageSettings property value. The collection of stages when to execute one or more custom access package workflow extensions. Supports $expand. | def custom_extension_stage_settings=(value)
@custom_extension_stage_settings = value
end | [
"def custom_extension_stage_settings\n return @custom_extension_stage_settings\n end",
"def custom_workflow_extensions=(value)\n @custom_workflow_extensions = value\n end",
"def custom_extension=(value)\n @custom_extension = value\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the expiration property value. The expiration date for assignments created in this policy. | def expiration
return @expiration
end | [
"def expiration=(value)\n @expiration = value\n end",
"def expiration_date_time\n return @expiration_date_time\n end",
"def expiration_date\n @plist['ExpirationDate']\n end",
"def getExpiration; @expires; end",
"def management_certificate_expiratio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the expiration property value. The expiration date for assignments created in this policy. | def expiration=(value)
@expiration = value
end | [
"def expiration_date=(value)\n expiration_date_will_change!\n @expiration_date = value\n end",
"def expiration=(expiration_date)\n unless self.new_record?\n logger.warn(\"Attempted to set expiration on existing record: access_token id=#{self.id}. Update ignored\")\n return\n end\n super(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the questions property value. Questions that are posed to the requestor. | def questions
return @questions
end | [
"def questions\n @data[:questions]\n end",
"def questions=(value)\n @questions = value\n end",
"def question\n return @question\n end",
"def custom_questions\n return @custom_questions\n end",
"def question=(value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the questions property value. Questions that are posed to the requestor. | def questions=(value)
@questions = value
end | [
"def question=(value)\n @question = value\n end",
"def custom_questions=(value)\n @custom_questions = value\n end",
"def answers=(value)\n @answers = value\n end",
"def custom_question_answers=(value)\n @custom_questi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the requestApprovalSettings property value. Specifies the settings for approval of requests for an access package assignment through this policy. For example, if approval is required for new requests. | def request_approval_settings
return @request_approval_settings
end | [
"def request_approval_settings=(value)\n @request_approval_settings = value\n end",
"def get_access_approval_settings request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the requestApprovalSettings property value. Specifies the settings for approval of requests for an access package assignment through this policy. For example, if approval is required for new requests. | def request_approval_settings=(value)
@request_approval_settings = value
end | [
"def update_access_approval_settings request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_update_access_approval_settings_request request_pb\n query_string_para... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the requestorSettings property value. Provides additional settings to select who can create a request for an access package assignment through this policy, and what they can include in their request. | def requestor_settings
return @requestor_settings
end | [
"def requestor_settings=(value)\n @requestor_settings = value\n end",
"def request_approval_settings\n return @request_approval_settings\n end",
"def request_approval_settings=(value)\n @request_approval_settings = value\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the requestorSettings property value. Provides additional settings to select who can create a request for an access package assignment through this policy, and what they can include in their request. | def requestor_settings=(value)
@requestor_settings = value
end | [
"def requestor=(value)\n @requestor = value\n end",
"def requestor_settings\n return @requestor_settings\n end",
"def request_approval_settings=(value)\n @request_approval_settings = value\n end",
"def automatic_request_settings=(va... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the reviewSettings property value. Settings for access reviews of assignments through this policy. | def review_settings
return @review_settings
end | [
"def review_settings=(value)\n @review_settings = value\n end",
"def assignment_settings\n return @assignment_settings\n end",
"def assignment_settings=(value)\n @assignment_settings = value\n end",
"def access_reviews\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the reviewSettings property value. Settings for access reviews of assignments through this policy. | def review_settings=(value)
@review_settings = value
end | [
"def assignment_settings=(value)\n @assignment_settings = value\n end",
"def review_set=(value)\n @review_set = value\n end",
"def update_review_generation_settings(account_id, v, review_generation_settings_request, opts = {})\n data, _status_code, _heade... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the specificAllowedTargets property value. The principals that can be assigned access from an access package through this policy. | def specific_allowed_targets
return @specific_allowed_targets
end | [
"def request_access_for_allowed_targets\n return @request_access_for_allowed_targets\n end",
"def specific_allowed_targets=(value)\n @specific_allowed_targets = value\n end",
"def allowed_target_scope\n return @allowed_target_scope\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the specificAllowedTargets property value. The principals that can be assigned access from an access package through this policy. | def specific_allowed_targets=(value)
@specific_allowed_targets = value
end | [
"def request_access_for_allowed_targets=(value)\n @request_access_for_allowed_targets = value\n end",
"def specific_allowed_targets\n return @specific_allowed_targets\n end",
"def allowed_target_scope=(value)\n @allowed_target_scope = value\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
pins that are dropped | def dropped_pins
location = Location.new
location.name = params[:locations][:name]
location.description = ""
location.user_id = @current_user.id
location.trip_id = params[:locations][:trip_id]
location.coordinates = [params[:locations][:pin][1].to_f, params[:locations][:pin][0].to_f]
location.save!
@... | [
"def drops\n @drops\n end",
"def custom_drops; @extra_drop; end",
"def unpin\n @pinned = false\n end",
"def cleanup_pins\n pin(:resetb).drive(0)\n pin(:tclk).drive(0)\n pin(:tdi).drive(0)\n pin(:tms).drive(0)\n pin(:tdo).dont_care\n end",
"def on_tile_drop(dro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TL;DR: adds data layers between existing base layers. Stacks data layer on top of the last data layer and/or the first base layer found, and keeps any existing "top" base layers on top. | def copy_data_layers(origin_map, destination_map, user)
last_data = destination_map.layers.reverse.find(&:data_layer?)
order = if last_data
last_data.order + 1
else
first_base = destination_map.layers.find(&:base_layer?)
first_base ? ... | [
"def add_layers\n add_top_layers if pushing_top_3d_boundary?\n add_bottom_layers if pushing_bot_3d_boundary?\n end",
"def add_bottom_layers\n @hypercube.each do |grid|\n new_layer = Array.new(@y_dim) { Array.new(@x_dim) { '.' } }\n grid.unshift(new_layer)\n end\n @z_origin += 1\n @z_d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Getter. Gets all activities for a given board. | def activities
return @activities if @activities != nil && @activities.length > 0
@activities = []
self.board.cards.each do |card|
card.actions.each do |action|
member = Trello::Member.find(action.member_creator_id)
action_record = {action: action, member: member}
... | [
"def activities\n return @activities if !@activities.nil? && @activities.length > 0\n \n @activities = []\n self.board.cards.each do |card|\n card.actions.each do |action|\n member = self.members.select { |member| member.id == action.member_creator_id }.first\n action_re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /role_funcions POST /role_funcions.json | def create
@role_funcion = RoleFuncion.new(role_funcion_params)
respond_to do |format|
if @role_funcion.save
format.html { redirect_to @role_funcion }
format.json { render action: 'show', status: :created, location: @role_funcion }
else
format.html { render action: 'new' }
... | [
"def update\n respond_to do |format|\n if @role_funcion.update(role_funcion_params)\n format.html { redirect_to @role_funcion }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @role_funcion.errors, status: :unpro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /role_funcions/1 PATCH/PUT /role_funcions/1.json | def update
respond_to do |format|
if @role_funcion.update(role_funcion_params)
format.html { redirect_to @role_funcion }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @role_funcion.errors, status: :unprocessable_ent... | [
"def change_role\n authorize @user\n @user.update!(role_params)\n json_response({message: \"Role changed successfully\"})\n end",
"def update\n authorize @role, :edit?\n respond_to do |format|\n if @role.update(api_v2_role_params)\n format.html { render :show, notice: \"Role was succes... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /role_funcions/1 DELETE /role_funcions/1.json | def destroy
@role_funcion.destroy
respond_to do |format|
format.html { redirect_to role_funcions_url }
format.json { head :no_content }
end
end | [
"def destroy\n @role = Role.find(params[:id])\n @role.destroy\n \n respond_to do |format|\n format.html { redirect_to roles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role = Role.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /trials/1 GET /trials/1.xml | def show
@trial = Trial.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @trial }
end
end | [
"def show\n @trial = Trial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @trial }\n format.json { render :json => @trial }\n end\n end",
"def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.htm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /trials/new GET /trials/new.xml | def new
@trial = Trial.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @trial }
end
end | [
"def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trial }\n format.json { render :json => @trial }\n end\n end",
"def new\n @trial = Trial.new\n \n respond_to do |format|\n format.html # new.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /trials POST /trials.xml | def create
@trial = Trial.new(params[:trial])
respond_to do |format|
if @trial.save
flash[:notice] = 'Trial was successfully created.'
format.html { redirect_to(@trial) }
format.xml { render :xml => @trial, :status => :created, :location => @trial }
else
format.html... | [
"def create\n @trial = Trial.new(params[:trial])\n\n respond_to do |format|\n if @trial.save\n format.html { redirect_to(@trial, :notice => 'Trial was successfully created.') }\n format.xml { render :xml => @trial, :status => :created, :location => @trial }\n else\n format.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /trials/1 PUT /trials/1.xml | def update
@trial = Trial.find(params[:id])
respond_to do |format|
if @trial.update_attributes(params[:trial])
flash[:notice] = 'Trial was successfully updated.'
format.html { redirect_to(@trial) }
format.xml { head :ok }
else
format.html { render :action => "edit" ... | [
"def update\n @trial = Trial.find(params[:id])\n\n respond_to do |format|\n if @trial.update_attributes(params[:trial])\n format.html { redirect_to(@trial, :notice => 'Trial was successfully updated.') }\n format.xml { head :ok }\n format.json { head :ok }\n else\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /trials/1 DELETE /trials/1.xml | def destroy
@trial = Trial.find(params[:id])
@trial.destroy
respond_to do |format|
format.html { redirect_to(trials_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @assertion = Assertion.find(params[:id])\n @assertion.destroy\n\n respond_to do |format|\n format.html { redirect_to(assertions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @trial.destroy\n respond_to do |format|\n format.html { redirect_to trials... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the query property value. Represents unique identification for the query. 'Asset ID' for SharePoint Online and OneDrive for Business, 'keywords' for Exchange Online. | def query=(value)
@query = value
end | [
"def query=(v); self[:query]=v end",
"def setQuery(query) \n\t\tself.queryString = query\n end",
"def set_Query(value)\n set_input(\"Query\", value)\n end",
"def query_string=(value)\n @query_string = value\n end",
"def set_query(query); end",
"def set_QueryKeywords... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the queryType property value. Represents the type of query associated with an event. 'files' for SPO and ODB and 'messages' for EXO.The possible values are: files, messages, unknownFutureValue. | def query_type
return @query_type
end | [
"def query_type=(value)\n @query_type = value\n end",
"def query_type_str\n query_type_enum[query_type]\n end",
"def get_event_type\n if @event_type\n @event_type\n else\n @local_result ? @local_result.event_type : '?'\n end\n end",
"def query_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the queryType property value. Represents the type of query associated with an event. 'files' for SPO and ODB and 'messages' for EXO.The possible values are: files, messages, unknownFutureValue. | def query_type=(value)
@query_type = value
end | [
"def query_alteration_type=(value)\n @query_alteration_type = value\n end",
"def query_type\n return @query_type\n end",
"def query_type_str\n query_type_enum[query_type]\n end",
"def query_type=(sym) #:nodoc:\n @query_type = sym\n @query_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Builds billing, shipping and origin addresses | def build_addresses(options={})
raise "override in purchase_order or sales_order"
end | [
"def build_addresses(options={})\n raise ArgumentError.new(\"No address declared for buyer (#{buyer.class.name} ##{buyer.id}), use acts_as_addressable :billing\") \\\n unless buyer.respond_to?(:find_default_address)\n \n # buyer's billing or default address\n unless default_billing_address\n i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculates tax and sets the tax_amount attribute It adds tax_amount across all line_items | def tax_total
self.tax_amount = line_items.inject(0.to_money) {|sum,l| sum + l.tax_amount }
self.tax_amount
end | [
"def tax_total\n self.tax_amount = line_items.inject(Money.new(0, self.currency || Money.default_currency)) {|sum,l| sum + l.tax_amount }\n self.tax_rate # calculates average rate, leave for compatibility reasons\n self.tax_amount\n end",
"def add_tax_as_line_item\n raise unless @fields['x_ta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gross amount including tax | def gross_total
self.gross_amount = self.net_total + self.tax_total
end | [
"def total_tax\n (doc/\"total-tax\").to_money\n end",
"def gross_total\n gross_total_base.round(2)\n end",
"def gross_price\n if @vat_included\n @price\n else\n net_price + vat_sum\n end\n end",
"def gross_amount\n get_awards[:gross_amt]\n end",
"def gross\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
is the number of line items stored in the order, though not to be confused by the items_count | def line_items_count
self.line_items.count
end | [
"def line_items_count\n self.line_items.size\n end",
"def items_count\n counter = 0\n self.line_items.each do |item|\n counter += item.quantity\n end\n counter\n end",
"def items_count\n counter = 0\n self.line_items.each do |item|\n counter += item.quant... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a commaseparated list of all errors found during the last attempt to create or update this +User+, as a String. | def get_all_errors
@user.errors.full_messages.compact.join(',')
end | [
"def get_all_errors\n\t\t@user.errors.full_messages.compact.join(', ')\n\tend",
"def to_s\n @errors.to_a.join(', ')\n end",
"def errors\n return @errors || []\n end",
"def get_all_errors\n\t\t@interest_point.errors.full_messages.compact.join(',')\n\tend",
"def error_messages\n errors ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.