query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
When you return from a block, it returns from the method that contains the block this can cause some code not to be executed (see below) | def some_damn_method
puts "Enterng method"
1.times { puts "Entering block!"; return }
puts "Exiting method" # Never gets executed!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return(&block); end",
"def block?; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def b... | [
"0.8127028",
"0.7748477",
"0.77361524",
"0.77361524",
"0.77361524",
"0.77361524",
"0.77361524",
"0.77361524",
"0.77361524",
"0.77361524",
"0.77361524",
"0.77361524",
"0.77361524",
"0.77361524",
"0.77361524",
"0.77361524",
"0.77361524",
"0.77361524",
"0.77361524",
"0.77361524",
... | 0.7113194 | 31 |
Procs do the same thing as blocks | def blastoff
print "Initiating... "
10.times do |i|
return if i == 9
print i.to_s + " "
end
print "...blastoff!\n" # This never gets printed :(
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process(&block); end",
"def blocks() end",
"def multi(&block); end",
"def blocks; end",
"def blocks; end",
"def blocks; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; e... | [
"0.72977144",
"0.71225697",
"0.69694716",
"0.666311",
"0.666311",
"0.666311",
"0.6642661",
"0.6642661",
"0.6642661",
"0.6642661",
"0.6642661",
"0.6642661",
"0.6642661",
"0.6642661",
"0.6642661",
"0.6642661",
"0.6642661",
"0.6642661",
"0.6642661",
"0.6642661",
"0.6642661",
"... | 0.0 | -1 |
Procs are often passed around between methods By the time a Proc is invoked, the lexically enclosing method may already have returned | def proc_builder(message)
Proc.new { puts message; return }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def another_proc\n\tp = Proc.new {return}\n\tp.call\n\tputs \"After Proc\"\nend",
"def ret_proc \n proc = Proc.new { return \"a return from inside the proc returns not only from the proc, but the enclosing method itself, unlike a lambda.\"}\n proc.call\n return \"returning from inside the method\"\n end",... | [
"0.76339775",
"0.7612096",
"0.7422711",
"0.7414422",
"0.74104774",
"0.7374416",
"0.7338197",
"0.73238593",
"0.7295041",
"0.7229425",
"0.71988755",
"0.7198272",
"0.7172947",
"0.7148594",
"0.7146627",
"0.7132441",
"0.7123704",
"0.71031433",
"0.7057024",
"0.7048254",
"0.70117676... | 0.6083751 | 88 |
Lambdas work more like methods than blocks A return from a lambda returns from the lambda itself not the method that surrounds the lambda creation site | def test2
puts "Entering method"
l = ->{ puts "Entering lambda"; return }
l.call
puts "Exiting lambda" # this gets executed
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lambda; end",
"def lambda_inside\n return_lambda = lambda { return }\n return_lambda.call\n puts \"In Method! (Lambda)\"\nend",
"def another_lambda\n\tl = lambda {return}\n\tl.call\n\tputs \"After Lambda\"\nend",
"def another_lambda\n l = lambda {return 1}\n l.call\n puts \"After Lambda... | [
"0.80384374",
"0.7724974",
"0.74640703",
"0.7409878",
"0.7287321",
"0.72872704",
"0.71788806",
"0.71131086",
"0.7100404",
"0.70154715",
"0.70154715",
"0.70154715",
"0.7011379",
"0.70069695",
"0.6992789",
"0.69270337",
"0.69270337",
"0.69270337",
"0.68821937",
"0.68319905",
"0... | 0.6573267 | 34 |
format priority started with method from todo.rb | def format_priority(priority)
case priority
when "high"
value = " ⇧".colorize(:red)
when "medium"
value = " ⇨".colorize(:blue)
when "low"
value = " ⇩".colorize(:white)
else
value = ""
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_priority(priority)\n value = \" ⇧\".ljust(10).colorize(:red) if priority == \"high\"\n value = \" ⇨\".ljust(10).colorize(:yellow) if priority == \"medium\"\n value = \" ⇩\".ljust(10).colorize(:green) if priority == \"low\"\n value = \" \".ljust(10) if !priority\n return \"#{value}\"#.lju... | [
"0.7139605",
"0.70844007",
"0.67357826",
"0.66537654",
"0.66108924",
"0.6606167",
"0.6599474",
"0.65798205",
"0.657116",
"0.64302033",
"0.64024734",
"0.6249941",
"0.62366277",
"0.6236369",
"0.6212271",
"0.61431026",
"0.60538536",
"0.60463643",
"0.592093",
"0.58884",
"0.588818... | 0.7157059 | 0 |
change priority from todo.rb | def change_priority(priority)
@priority = priority
unless @priority =="low" || "high" || "medium"
raise UdaciListErrors::InvalidPriorityValue, "Please choose from low, medium or high, instead of #{options[:priority]}, OK?"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_priority\n self.priority = 100\n end",
"def set_priority\n if self.priority.eql? 'Blocker'\n self.priority = '1'\n elsif self.priority.eql? 'Critical'\n self.priority = '2'\n elsif self.priority.eql? 'Major'\n self.priority = '3'\n elsif self.priority.eql? 'Trivial'\n ... | [
"0.7432958",
"0.72314906",
"0.70735884",
"0.6928905",
"0.69264454",
"0.69264454",
"0.69184643",
"0.690561",
"0.6894399",
"0.6879169",
"0.6846856",
"0.68399704",
"0.68125945",
"0.6799039",
"0.6766946",
"0.6737498",
"0.67037714",
"0.6649776",
"0.6631047",
"0.66242546",
"0.66147... | 0.6724369 | 16 |
current active determines if the most recent task is active. if it is, return it. if it is not, return nil. need to nil check.. | def current
current_post = Post.last
# makes 2 checks.
# 1. if the item isn't nil. (sanity check)
# 2. if the task timed out yet. completed time > time now.
if current_post != nil # and current_post.completed_at > Time.now.utc
current_post
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current \n find_by_active(true)\n end",
"def last_active\n activity_log && activity_log.last_time\n end",
"def active?\n Time.current - recent_at <= PERIOD_ACTIVE\n end",
"def current\n\t\t\t\t\t\t@current = where(current: true).order(from: :desc).first if @current.nil?\n\t\t\t\t\t\tr... | [
"0.7213612",
"0.7195733",
"0.68250674",
"0.67933595",
"0.6753993",
"0.6693518",
"0.65896356",
"0.6568401",
"0.6540131",
"0.6521205",
"0.650356",
"0.650356",
"0.6493966",
"0.6462983",
"0.6461726",
"0.6447984",
"0.64097184",
"0.63801295",
"0.63705325",
"0.63646454",
"0.63609195... | 0.69940764 | 2 |
parse time method to parse the time value out of a string using some escape code. for now. i'm just assuming the first word of with the '+' prefix will be used. buggy... sorta basically i don't want this to be called every time. just on update. | def parse_time
# add a default time for a task.
length_of_task = Time.now + 15.minutes
# splits the entered text.
sentence = body.split ' '
esc_code = sentence.first
# determines if the word is long enough.
# if it was long enough, split the word into the necessary code.
if esc_code.le... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_time(time)\n time = \"0#{time}\" if time.match(/^\\d:\\d\\d/)\n time = time.gsub(/u/, '') if utime?\n time = time.gsub(/s/, '') if stime?\n\n time\n end",
"def parse_time\n s0 = @scanner.pos\n if match_str('(') == :failed\n @scanner.pos = s0\n s0 =... | [
"0.74738854",
"0.74030346",
"0.7288272",
"0.70075345",
"0.6975714",
"0.69327694",
"0.6828281",
"0.67798036",
"0.6711498",
"0.66617304",
"0.65857416",
"0.6569537",
"0.6546031",
"0.6543416",
"0.6510459",
"0.6486406",
"0.64679575",
"0.64506525",
"0.64242375",
"0.64090025",
"0.64... | 0.6775787 | 8 |
GET /products GET /products.json | def index
@products = Product.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend",
"def products\n request :public, :get, :products\n end",
"def index\n @products = Product.all\n render json: @products\n end",
"def index\n begin\n ... | [
"0.79500145",
"0.7929853",
"0.79054135",
"0.77477723",
"0.76619905",
"0.7622153",
"0.762195",
"0.762195",
"0.762195",
"0.76070404",
"0.75873625",
"0.75828224",
"0.7578298",
"0.75750685",
"0.7565435",
"0.7565435",
"0.7565435",
"0.7565435",
"0.7530454",
"0.7523024",
"0.75097287... | 0.0 | -1 |
GET /products/1 GET /products/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product(name)\n get(\"/apiproducts/#{name}\")\n end",
"def show\n product = Product.find_by_id(params[:id])\n\n render json: product\n end",
"def show\n @product = Product.find(params[:id])\n\n render json: @product\n end",
"def index\n @api_v1_products = Product.all\n jso... | [
"0.7722602",
"0.76332074",
"0.7631849",
"0.76071095",
"0.7576311",
"0.75523484",
"0.7507045",
"0.7485098",
"0.74559337",
"0.7450731",
"0.74385005",
"0.74216115",
"0.73620206",
"0.7319461",
"0.73192406",
"0.73192406",
"0.73192406",
"0.73162746",
"0.7312323",
"0.7309479",
"0.72... | 0.0 | -1 |
POST /products POST /products.json | def create
@product = Product.new(product_params)
respond_to do |format|
if @product.save
format.html { redirect_to @product, notice: 'Product was successfully created.' }
format.json { render :show, status: :created, location: @product }
else
format.html { render :new }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @product = Product.new(product_args)\n\n if @product.save\n render json: Product.all, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def create\n if params[:products]\n params[:products].each do |product|\n @... | [
"0.7674954",
"0.7589692",
"0.756074",
"0.7531862",
"0.7531213",
"0.7507928",
"0.7420413",
"0.7391407",
"0.7374718",
"0.7355908",
"0.73231804",
"0.72869605",
"0.7144144",
"0.7050259",
"0.7047559",
"0.70415026",
"0.7037288",
"0.7037288",
"0.7037288",
"0.70322204",
"0.70255643",... | 0.6881634 | 73 |
PATCH/PUT /products/1 PATCH/PUT /products/1.json | def update
respond_to do |format|
if @product.update(product_params)
format.html { redirect_to @product, notice: 'Product was successfully updated.' }
format.json { render :show, status: :ok, location: @product }
else
format.html { render :edit }
format.json { render json... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n begin\n @api_v1_product.update!(api_v1_product_params)\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end",
"def update\n if @product.update(product_params)\n render json: @product, status: :ok#, location: @colle... | [
"0.72710204",
"0.69353336",
"0.68692976",
"0.68467",
"0.681278",
"0.67682886",
"0.6750634",
"0.67411494",
"0.6715326",
"0.6700868",
"0.6686437",
"0.6659884",
"0.6654759",
"0.66535413",
"0.6640822",
"0.6640822",
"0.6638351",
"0.6631136",
"0.6631136",
"0.6627426",
"0.6620776",
... | 0.0 | -1 |
DELETE /products/1 DELETE /products/1.json | def destroy
@product.destroy
respond_to do |format|
format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n product = Product.find(params[:id])\n product.destroy\n\n render json: { deleted: params[:id] }\n end",
"def delete_product(name)\n delete(\"/apiproducts/#{name}\")\n end",
"def destroy\n p @product.destroy!\n render json: { result: 'deleted' }, status: :ok\n end",
... | [
"0.7716767",
"0.7593029",
"0.7548404",
"0.75026053",
"0.7501899",
"0.74741083",
"0.7439505",
"0.7417943",
"0.74088925",
"0.7370336",
"0.73533446",
"0.73478407",
"0.73357344",
"0.73357344",
"0.73357344",
"0.73308176",
"0.73308176",
"0.73308176",
"0.73308176",
"0.73308176",
"0.... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_product
@product = Product.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.532... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def product_params
params.require(:product).permit(:name, :cost, :desc, :image, :image_cache, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Return a list of api profile object hashes that should be "flushed". | def all_profiles(property_hash)
profiles = []
client = property_hash[:protocol_profile_client] || property_hash[:protocol_profile_server]
server = property_hash[:protocol_profile_server] || property_hash[:protocol_profile_client]
if !client.nil?
if client == server
profiles << { :profile_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report_profile_sha256s(report)\n return [] unless report.is_a?(Hash) && report[:profiles].is_a?(Array)\n report[:profiles].map { |p| p[:sha256] }\n end",
"def chargeable_profiles\n profile ? [profile] : []\n end",
"def pull_profiles\n \tprofiles_from_api = self.client.profiles\n\t\tprofiles_arr... | [
"0.5958914",
"0.5865918",
"0.58292127",
"0.56343675",
"0.55977374",
"0.5514453",
"0.54816306",
"0.5399348",
"0.52177644",
"0.5167024",
"0.5159659",
"0.5155031",
"0.5148207",
"0.509777",
"0.5086",
"0.50808066",
"0.5067252",
"0.5057319",
"0.5045348",
"0.5027243",
"0.50224686",
... | 0.49316356 | 32 |
Check if there are any profiles that need to be flushed. | def flush_profiles?
profile_properties.any? { |prop| !@property_flush[prop].nil? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def erased?\n !@profile\n end",
"def flush?\n suits.uniq.count == 1\n end",
"def exists?\n prepare_environment\n load_template(@data['serverProfileTemplateUri'], 'new_profile')\n return @resource_type.find_by(@client, @data).any? if resource['ensure'].to_sym == :absent\n super([nil, :found,... | [
"0.6124563",
"0.60295033",
"0.56598204",
"0.545121",
"0.5396227",
"0.5396227",
"0.53945273",
"0.5359101",
"0.53349125",
"0.5330659",
"0.53196144",
"0.5314108",
"0.5298481",
"0.52939534",
"0.5283856",
"0.52688766",
"0.5264155",
"0.52640486",
"0.5250752",
"0.5246547",
"0.523278... | 0.81153816 | 0 |
deleting or unlinking is done by setting the authData of the service name to nil | def set_service_auth_data(id, service_name, auth_data, headers: {}, **opts)
body = { authData: { service_name => auth_data } }
update_user(id, body, opts)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy!\r\n @oauth_service_factory = nil\r\n @data_format = nil\r\n @auth_method = nil\r\n @username = nil\r\n @password = nil\r\n @current_oauth_request = nil\r\n end",
"def destroy\n __log_activity(\"LOGOUT #{current_user}\")\n __debug_route\n __debug_request\n ... | [
"0.6477391",
"0.64096487",
"0.6380109",
"0.6379517",
"0.63238144",
"0.61819106",
"0.61707276",
"0.6170324",
"0.6097548",
"0.60894024",
"0.6069309",
"0.60645986",
"0.60552037",
"0.60503185",
"0.60290337",
"0.60145307",
"0.59703046",
"0.5945632",
"0.59440315",
"0.5940416",
"0.5... | 0.0 | -1 |
reads the instruction specification to generate a more processing friendly presentation from the more readable presentation in INSTR_DEFS | def create_instr_specs()
instr_specs = []
INSTR_DEFS.each do |instr_def|
instr_specs <<= extract_spec(instr_def)
end
instr_specs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(line)\n params = line.split(/\\s+/)\n return nil unless params[0] == 'instruction'\n\n spec_defs = params[2..-1]\n specs = parse_specs(spec_defs)\n\n specs\n end",
"def get_instructions\n\t\tinstructions = <<-TEXT\n\tField symbols:\n\t#{Symbols::HIT} --> Hit\n\t#{Symbols::MISS} --> Miss... | [
"0.60889274",
"0.59471506",
"0.5701638",
"0.56494826",
"0.56235075",
"0.5526507",
"0.551376",
"0.5450746",
"0.54276913",
"0.5366884",
"0.5322413",
"0.53043556",
"0.5293937",
"0.5280792",
"0.5204498",
"0.51893365",
"0.51788485",
"0.5160178",
"0.51397866",
"0.5114266",
"0.51122... | 0.6024776 | 1 |
Redirect after sign in | def store_action
return unless request.get?
if (request.path != "/organisations/sign_in" &&
request.path != "/organisations/sign_up" &&
request.path != "/organisations/password/new" &&
request.path != "/organisations/password/edit" &&
request.path != "/organisations/sign_ou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auth_after\n url = session[:auth_redirect] || root_path\n redirect_to url\n end",
"def signed_in_user\n redirect_to signin_path, :status => 302 unless signed_in?\n end",
"def signed_in_user\n redirect_to signin_path, :status => 302 unless signed_in?\n end",
"def logged_in_redirect\... | [
"0.7877201",
"0.78674316",
"0.78674316",
"0.77501565",
"0.7740231",
"0.7723901",
"0.7714929",
"0.77031136",
"0.7650529",
"0.7639733",
"0.7636807",
"0.76182157",
"0.75988317",
"0.7556143",
"0.75445426",
"0.75327414",
"0.75305176",
"0.7528303",
"0.7516764",
"0.75017613",
"0.749... | 0.0 | -1 |
Session keys will change after 1 hour of not using. This method will update session_key in database only when the facebook session_key has changed. | def store_session(session_key)
if self.session_key != session_key
update_attribute(:session_key, session_key)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_session_key\n @parameters['sessionKey'] = get_session_key\n end",
"def set_session_key(key) \n if self.new_record?\n @session_key=key\n else\n ActiveRecord::Base.session_keys[session_key_id]=key\n end\n decrypt_attributes if self.class.include? ... | [
"0.73018813",
"0.67140436",
"0.6440346",
"0.6402066",
"0.6391517",
"0.638405",
"0.6370641",
"0.6291978",
"0.61614764",
"0.6127262",
"0.6104697",
"0.6068014",
"0.60671043",
"0.60490084",
"0.6045991",
"0.60287094",
"0.59948534",
"0.5980043",
"0.59777385",
"0.5967722",
"0.590871... | 0.70466566 | 1 |
Recreate Facebooker::Session object outside of a request | def facebook_session
@facebook_session ||=
returning Facebooker::Session.create do |session|
# Facebook sessions are only good for 1 hour after storing
# secure_with! associates a session key to a
# Facebooker::Session object
session.secure_with!(session_key, facebook_id, 1.hou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_session\n \n end",
"def init_session\n if session\n if session.updated_at < Time.now - ::Gricer.config.max_session_duration\n self.session = Session.create previous_session: session, ip_address: @ip_address, agent: agent, requested_locale: @request_locale\n ... | [
"0.68274343",
"0.66958857",
"0.66540205",
"0.65132356",
"0.6512174",
"0.6510468",
"0.64486015",
"0.64024335",
"0.638037",
"0.6376591",
"0.6376591",
"0.6376591",
"0.6355028",
"0.6325409",
"0.63138413",
"0.63138413",
"0.631213",
"0.6307849",
"0.6307849",
"0.6307849",
"0.6307849... | 0.6618127 | 3 |
Returns an array of arrays which define the top menus for the corresponding view. Override all top menus in all Streamlined controllers by defining this method in ApplicationHelper, or override on a controller by controller basis in their specific helpers. Each array should contain the text of the link and the URL para... | def streamlined_top_menus
[
["TBD", {:action=>"new"}]
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def topnav_items(info={:object_id => 0, :object_name => nil})\n # Set up hashes of links\n if info[:object_name].blank?\n name = controller.controller_name.gsub('_', ' ')\n else\n name = info[:object_name].pluralize\n end\n index_link = {:name => name.capitalize + \" index\",\n ... | [
"0.6510577",
"0.6345768",
"0.6305809",
"0.6272102",
"0.6186116",
"0.6120457",
"0.6043288",
"0.5956877",
"0.5956877",
"0.5884006",
"0.5872096",
"0.5815796",
"0.5784863",
"0.5784619",
"0.57786024",
"0.5765104",
"0.5723723",
"0.56659776",
"0.56481874",
"0.5642823",
"0.5631216",
... | 0.74445987 | 0 |
TODO: move to REST or eliminate | def streamlined_auto_discovery_link_tag
# return if @syndication_type.nil? || @syndication_actions.nil?
#
# if @syndication_actions.include? params[:action]
# "<link rel=\"alternate\" type=\"application/#{@syndication_type.downcase}+xml\" title=\"#{@syndication_type.upcase}\" href=\"#{params[:action]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def get; end",
"def apis; end",
"def http; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end"... | [
"0.6865166",
"0.6344821",
"0.6326406",
"0.62409794",
"0.6228278",
"0.6228278",
"0.6228278",
"0.6228278",
"0.6228278",
"0.6228278",
"0.6228278",
"0.6228278",
"0.6228278",
"0.6228278",
"0.6228278",
"0.6182515",
"0.6182515",
"0.6182515",
"0.6182515",
"0.6146786",
"0.6066963",
... | 0.0 | -1 |
Alan wrote the following method, which was intended to show all of the factors of the input number: def factors(number) dividend = number divisors = [] begin divisors << number / dividend if number % dividend == 0 dividend = 1 end until dividend == 0 divisors end Alyssa noticed that this will fail if the input is 0, or... | def factors(number)
dividend = number
divisors = []
while dividend > 0 do
divisors << number / dividend if number % dividend == 0
dividend -= 1
end
divisors
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factors(number)\n divisors = []\n if number > 0 \n dividend = number\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n begin\n ... | [
"0.912444",
"0.91064245",
"0.91033137",
"0.91033137",
"0.90924895",
"0.9066068",
"0.9058413",
"0.9055604",
"0.9009219",
"0.89959353",
"0.8994907",
"0.8978197",
"0.8970321",
"0.89680487",
"0.89556503",
"0.89485264",
"0.8941468",
"0.8941468",
"0.8941468",
"0.8941468",
"0.894146... | 0.8945505 | 23 |
Creates a cached refresh token for the config directly to disk | def cache_refresh_token(config, token)
File.write(config.refresh_token_filename, token)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cached_refresh_token(config)\n File.read(config.refresh_token_filename).chomp\n end",
"def generate_refresh_token\n @raw_refresh_token = UniqueToken.generate\n secret_strategy.store_secret(self, :refresh_token, @raw_refresh_token)\n end",
"def refresh\n token = authenticate.call\n ... | [
"0.7744367",
"0.7168994",
"0.69071466",
"0.6880226",
"0.6829524",
"0.6760673",
"0.67390823",
"0.67225087",
"0.66974384",
"0.66753125",
"0.66500235",
"0.6610305",
"0.65561783",
"0.6459975",
"0.6313503",
"0.6313503",
"0.63039476",
"0.6294991",
"0.62816197",
"0.62742865",
"0.626... | 0.81622285 | 0 |
Returns the cached access token for the config directly from disk | def cached_access_token(config)
File.read(config.access_token_filename).chomp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cached_refresh_token(config)\n File.read(config.refresh_token_filename).chomp\n end",
"def access_token\n # Fetch from cache. We can expect this to be `nil` if unset or expired.\n #\n access_token = read_cache\n\n return access_token if access_token\n\n fetch_new_access_token\n ... | [
"0.7456183",
"0.74373066",
"0.71619606",
"0.6993262",
"0.69411194",
"0.68329334",
"0.6828311",
"0.6792336",
"0.670832",
"0.67003095",
"0.66937804",
"0.66772276",
"0.6645276",
"0.6632726",
"0.6632726",
"0.66132694",
"0.66034395",
"0.65611285",
"0.6500143",
"0.64526343",
"0.641... | 0.87306815 | 0 |
Returns the cached refresh token for the config directly from disk | def cached_refresh_token(config)
File.read(config.refresh_token_filename).chomp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_refresh_token\n\t\tif File.exists?(REFRESH_TOKEN_FILE_NAME)\n\t\t\treturn File.read(REFRESH_TOKEN_FILE_NAME, :encoding => Encoding::UTF_8)\n\t\telse\n\t\t\treturn get_new_refresh_token\n\t\tend\n\tend",
"def cache_refresh_token(config, token)\n File.write(config.refresh_token_filename, token)\n end",... | [
"0.7779616",
"0.7749353",
"0.7731045",
"0.6893046",
"0.6838104",
"0.6838104",
"0.6706908",
"0.65942866",
"0.6563831",
"0.6556389",
"0.65163285",
"0.65033704",
"0.6500323",
"0.6433072",
"0.64027923",
"0.6389044",
"0.63743657",
"0.63533574",
"0.634588",
"0.6292222",
"0.6280884"... | 0.8731511 | 0 |
This returns a token like string with no meaning but should always be different so never clashes in tests. | def random_token
SecureRandom.hex(20)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def friendly_token\n SecureRandom.base64(32).tr('+/=lIO0', 'pqrsxyz')\n end",
"def token_s\n fail 'sub-class to implement'\n end",
"def to_s\n token\n end",
"def token_safe?( str )\n not TOKEN_UNSAFE === str\n end",
"def friendly_token(length = T.unsafe(nil)); end",
"d... | [
"0.6792349",
"0.67025876",
"0.6593498",
"0.6470702",
"0.6460477",
"0.6407168",
"0.63221854",
"0.63221854",
"0.629824",
"0.6187298",
"0.61447763",
"0.60993177",
"0.60812193",
"0.60784525",
"0.60538715",
"0.60538715",
"0.60538715",
"0.60538715",
"0.60538715",
"0.60538715",
"0.6... | 0.5471348 | 90 |
Returns an absolute path in the compiled directory | def dest
File.join(Ichiban.project_root, 'compiled', dest_rel_to_compiled)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compiled_path; end",
"def get_project_path\n return File.absolute_path File.join(root_dir, src)\n end",
"def min_file_path\n compiled_path || current_file_path\n end",
"def source_root\n FilePath.new(build_module.root, name).canonicalize\n end",
"def path\n ... | [
"0.77822393",
"0.7311077",
"0.7035585",
"0.68358785",
"0.68097407",
"0.68081784",
"0.68081784",
"0.6720668",
"0.66274303",
"0.66274303",
"0.6535277",
"0.650204",
"0.6498646",
"0.64876705",
"0.6482459",
"0.64744884",
"0.6438828",
"0.64243704",
"0.6417908",
"0.64036673",
"0.639... | 0.67298836 | 7 |
Pass in a path relative to Ichiban.projet_root. Returns the path relative to the one you passed in. E.g. if the file is assets/js/example.js, then rel_to('assets/js') returns 'example.js'. | def rel_to(path)
path = path + '/' unless path.end_with?('/')
if rel.start_with?(path)
rel.sub(path, '')
else
raise "#{@abs} is not in #{path}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_proj_rel pn\n pn.relative_path_from(@dir)\n end",
"def rel_path(path)\n Pathname(path).expand_path.relative_path_from(Pathname(Dir.pwd))\n end",
"def path(rel)\n File.join(File.dirname(__FILE__), \"..\", rel)\nend",
"def rel relative_path\r\n return File.dirname(__FILE__) + \"/../\" + re... | [
"0.69735694",
"0.6898421",
"0.6770133",
"0.67339796",
"0.6659375",
"0.66312987",
"0.648408",
"0.6359305",
"0.6344826",
"0.63338035",
"0.62878966",
"0.6245738",
"0.61892027",
"0.6150695",
"0.6077105",
"0.60465765",
"0.59892553",
"0.5950653",
"0.5919528",
"0.58862156",
"0.58789... | 0.7279352 | 0 |
Returns a new path where the old extension is replaced with new_ext | def replace_ext(path, new_ext)
path.sub(/\..+$/, '.' + new_ext)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_extension(filepath, new_ext)\n dirname = File.dirname(filepath)\n extname = File.extname(filepath)\n basename = File.basename(filepath, extname)\n File.expand_path(File.join(dirname, basename + '.' + new_ext))\n end",
"def replace_extension path, ext\n base_name = File.basename(path,... | [
"0.77847624",
"0.7759997",
"0.77362543",
"0.7078659",
"0.68697155",
"0.6856279",
"0.68192303",
"0.66833645",
"0.6533386",
"0.6533386",
"0.64586765",
"0.62679845",
"0.6224934",
"0.62202233",
"0.61424994",
"0.6132418",
"0.61273694",
"0.6111442",
"0.6007551",
"0.5959191",
"0.594... | 0.8317783 | 0 |
GET /user_follows/1 GET /user_follows/1.xml | def show
@user_follow = UserFollow.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @user_follow }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_follows\n \t@user = User.find(params[:id])\n \t\n \trender json: @user.follows\n end",
"def show_follows\n\t@user = User.find(params[:id])\n\n\trender json: @user.follows\n\tend",
"def following\n\t#@friendships = Friendship.find(:all, :conditions => {:follower_id => params[:profile_id]})\n\trespo... | [
"0.70612204",
"0.70509326",
"0.7047555",
"0.68947655",
"0.6857201",
"0.6818745",
"0.6809378",
"0.68085456",
"0.68085456",
"0.68085456",
"0.6764937",
"0.67458147",
"0.6736522",
"0.6709429",
"0.66899747",
"0.6686055",
"0.6681634",
"0.6680544",
"0.6680544",
"0.6678125",
"0.66700... | 0.7321145 | 0 |
GET /user_follows/new GET /user_follows/new.xml | def new
@user_follow = UserFollow.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @user_follow }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @follower = Follower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @follower }\n end\n end",
"def new\n @user_following = UserFollowing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xm... | [
"0.76178616",
"0.7574066",
"0.73241216",
"0.7201584",
"0.7199513",
"0.7193399",
"0.7193399",
"0.71388763",
"0.69939846",
"0.69913715",
"0.69425917",
"0.6856109",
"0.685332",
"0.68497694",
"0.6814491",
"0.6780718",
"0.67450166",
"0.6687695",
"0.66820925",
"0.66785395",
"0.6672... | 0.79823375 | 0 |
POST /user_follows POST /user_follows.xml | def create
@user_follow = UserFollow.new(params[:user_follow])
respond_to do |format|
if @user_follow.save
format.html { redirect_to(@user_follow, :notice => 'User follow was successfully created.') }
format.xml { render :xml => @user_follow, :status => :created, :location => @user_follo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def follow(user)\n\tout_followings.create(to_id: user.id)\nend",
"def create\n\n user = User.find(params[:followed_id])\n @current_user.follow(user)\n redirect_to user\n\n\n # PATCH/PUT /relationships/1\n # PATCH/PUT /relationships/1.json\n def update\n\n end\n\n # DELETE /relationships/1\n # DELE... | [
"0.7204529",
"0.71900105",
"0.7168162",
"0.7134119",
"0.71327084",
"0.7116976",
"0.71080285",
"0.7073689",
"0.7070124",
"0.70657766",
"0.7055847",
"0.70405596",
"0.6994825",
"0.6975299",
"0.69731265",
"0.692503",
"0.6924484",
"0.69078404",
"0.68787485",
"0.68787485",
"0.68487... | 0.7082723 | 7 |
PUT /user_follows/1 PUT /user_follows/1.xml | def update
@user_follow = UserFollow.find(params[:id])
respond_to do |format|
if @user_follow.update_attributes(params[:user_follow])
format.html { redirect_to(@user_follow, :notice => 'User follow was successfully updated.') }
format.xml { head :ok }
else
format.html { ren... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n\n user = User.find(params[:followed_id])\n @current_user.follow(user)\n redirect_to user\n\n\n # PATCH/PUT /relationships/1\n # PATCH/PUT /relationships/1.json\n def update\n\n end\n\n # DELETE /relationships/1\n # DELETE /relationships/1.json\n def destroy\n user = Relationship.fin... | [
"0.71342856",
"0.66951513",
"0.6676147",
"0.66536105",
"0.66457766",
"0.6613883",
"0.6598181",
"0.6577967",
"0.6534376",
"0.65313345",
"0.652673",
"0.649827",
"0.6493372",
"0.64682984",
"0.64445883",
"0.64213955",
"0.64213955",
"0.6418945",
"0.6415851",
"0.6390296",
"0.638719... | 0.708679 | 1 |
DELETE /user_follows/1 DELETE /user_follows/1.xml | def destroy
@user_follow = UserFollow.find(params[:id])
@user_follow.destroy
respond_to do |format|
format.html { redirect_to(user_follows_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_follows\n\n\t@follower = User.find(params[:id])\n\t@followed = User.find(params[:follows_id])\n\n\t@follower.follows.delete(@followed)\n\t\thead :no_content\n\t\t\n\tend",
"def delete_follows\n \t@follower = User.find(params[:id])\n \t@followed = User.find(params[:follows_id])\n \t\n \tif @followe... | [
"0.76002026",
"0.72093743",
"0.7179109",
"0.71101743",
"0.7109813",
"0.7090737",
"0.7074669",
"0.70362616",
"0.6989023",
"0.69866437",
"0.6935669",
"0.6934863",
"0.6916822",
"0.6817851",
"0.6798401",
"0.6748564",
"0.6741846",
"0.66929406",
"0.66913146",
"0.6688707",
"0.668197... | 0.76218355 | 0 |
This method creates a Contest and returns the winner(s) in the notice message | def create_contest
@contest = Contest.new(contest_params)
# Store the name of the product for easier readability
@contest.product_name = Product.find_by_shopify_product_
id(contest_params[:product_id]).try(:name) if contest_
params[:product_id].present?
respond_to do |format|
if @contest.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def winner\n count1, count2 = @cups[6].count, @cups[13].count\n if count1 > count2\n @name1\n elsif count2 > count1\n @name2\n else\n :draw\n end\n end",
"def create_contest\n\t\t@contest = Contest.new(contest_params)\n\t\t# Store the name of the product for easier readability\n\t\... | [
"0.65940636",
"0.61216146",
"0.59474236",
"0.5936638",
"0.5932938",
"0.5879226",
"0.5850468",
"0.5845425",
"0.58272827",
"0.58027977",
"0.57786435",
"0.5775063",
"0.5772301",
"0.5772136",
"0.5755851",
"0.575136",
"0.57370865",
"0.5720003",
"0.5717945",
"0.5710357",
"0.5705268... | 0.5862485 | 6 |
Global token set on the application instance first. This means someone set a token on the app and they do not wish for any users to have to authenticate | def global_api(application_instance, url)
if application_instance.canvas_token.present?
LMS::Canvas.new(
url,
application_instance.canvas_token,
)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_internal_token!\n self.token ||= generate_token\n end",
"def ensure_auth_token\n unless self.auth_token\n self.auth_token = User.generate_token\n end\n end",
"def set_auth_token\n return if auth_token.present?\n self.auth_token = generate_auth_token\n end",
"def ensure_session_... | [
"0.7405211",
"0.7373615",
"0.72674674",
"0.7164108",
"0.7158588",
"0.71206236",
"0.70078444",
"0.6963451",
"0.69478786",
"0.6944631",
"0.691165",
"0.68805593",
"0.68606496",
"0.6844091",
"0.6844091",
"0.6844091",
"0.68322384",
"0.68304867",
"0.6817714",
"0.68025255",
"0.67787... | 0.0 | -1 |
Look for an auth object associated with the application instance If a user with admin permissions onboards their token can be associated with the application instance TODO This needs to use an account id so that we can take the current account and figure out the correct token for that account TODO When associating a to... | def application_instance_api(application_instance, url, site)
return nil unless application_instance.present?
if auth = application_instance.authentications.find_by(provider_url: url)
refreshable_auth(auth, url, site)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authentication_token\n object.authentication_token if !current_user || object.id == current_user.id\n end",
"def auth_token\n TokenProvider.issue_token(\n first_name: object.first_name,\n last_name: object.last_name,\n username: object.username,\n user_id: objec... | [
"0.648475",
"0.64065236",
"0.6336919",
"0.6259506",
"0.6159121",
"0.6129984",
"0.6119265",
"0.6092183",
"0.59444773",
"0.5943293",
"0.59295183",
"0.58897936",
"0.58736175",
"0.5867508",
"0.58499473",
"0.5821382",
"0.5817702",
"0.5803126",
"0.5782875",
"0.57747567",
"0.5769741... | 0.5666538 | 36 |
Look for an auth object associated with the course. This will have been obtained during the onboarding process | def course_api(course, url, site)
return nil unless course.present?
if auth = course.authentications.find_by(provider_url: url)
refreshable_auth(auth, url, site)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_by_omniauth(auth)\n identity = User::Identity.find_by(provider: auth.provider, uid: auth.uid)\n identity.user if identity\n end",
"def auth_user\n User.find(auth_user_id) unless auth_user_id.nil?\n end",
"def get_auth()\n\t\t\tfind_attributes(\"auth\").first\n\t\tend",
"def get_user... | [
"0.6524192",
"0.64319575",
"0.6386411",
"0.63648957",
"0.6180725",
"0.6145685",
"0.6084179",
"0.5990715",
"0.5901181",
"0.5829754",
"0.5827607",
"0.57990307",
"0.5777976",
"0.576386",
"0.5702302",
"0.56739134",
"0.56577843",
"0.5657093",
"0.5630573",
"0.56208295",
"0.55885726... | 0.57937175 | 12 |
bug: for some reason if the customization_script has /r, is showed here as /n. Looks likes is something in excon | def script
attributes[:customization_script]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_original_commands; end",
"def script; end",
"def script; end",
"def add_original_commands\n end",
"def crl_file\n super\n end",
"def fill_customization_director\n end",
"def cli_prefix; end",
"def tralics_commands\n base_commands = <<-'EOS'\n% Commands specific to Tralics\n\\de... | [
"0.55897343",
"0.5445996",
"0.5445996",
"0.542349",
"0.53696644",
"0.5341404",
"0.53338915",
"0.52989197",
"0.52984923",
"0.52621365",
"0.52508044",
"0.52508044",
"0.52508044",
"0.5229305",
"0.5225795",
"0.5201909",
"0.51999557",
"0.5188172",
"0.5187021",
"0.5176898",
"0.5173... | 0.57785505 | 0 |
Retrieve paginated results from DB | def find_allusers(offset, limit)
@user = User.all.offset(offset).limit(limit)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_with_pagination(connection, entity, per_page)\n offset = 0\n records = []\n\n begin\n set = handle_timeouts(MAX_TIMEOUTS, \"loading tasks (offset: #{offset})\") { connection.send(entity, offset, \"yes\", \"owner,coworker,reporter\") }\n\n records += set\n offset += per_page\n end until set... | [
"0.72271097",
"0.7109471",
"0.7057219",
"0.70471257",
"0.69923186",
"0.6980101",
"0.697709",
"0.6970956",
"0.6946056",
"0.69385076",
"0.6937109",
"0.6922688",
"0.6899301",
"0.68961114",
"0.6878454",
"0.687827",
"0.68710893",
"0.6817502",
"0.6809746",
"0.6803011",
"0.6785205",... | 0.0 | -1 |
Query DB with exact match | def find_user_byname(username)
@user = User.where(username: username)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_query(query); end",
"def search_records(match)\n match = match.downcase\n conn.exec_params('SELECT * FROM contacts WHERE lower(first_name)=$1 OR lower(last_name)=$1', [match])\n end",
"def match(*params)\n query(transform_query_values(params) { |v| \"==#{FmRest::V1.escape_find_ope... | [
"0.72354835",
"0.6986024",
"0.691888",
"0.6625684",
"0.64946455",
"0.6485941",
"0.64789265",
"0.64789265",
"0.64309597",
"0.63936114",
"0.6332694",
"0.6320226",
"0.6263771",
"0.6236632",
"0.6122372",
"0.61198205",
"0.6073892",
"0.6064656",
"0.60049903",
"0.5995464",
"0.598033... | 0.0 | -1 |
Get rows from DB by PK | def get_user_byid(id)
@user = User.find_by_id(id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primary_key_lookup(pk)\n if sql = @fast_pk_lookup_sql\n sql = sql.dup\n ds = dataset\n ds.literal_append(sql, pk)\n ds.fetch_rows(sql){|r| return ds.row_proc.call(r)}\n nil\n else\n dataset.first(primary_key_hash(pk))\n end\n end",... | [
"0.7310246",
"0.7219432",
"0.6382527",
"0.63476264",
"0.63358307",
"0.63358307",
"0.62884295",
"0.627003",
"0.62130994",
"0.62130994",
"0.62035733",
"0.61740535",
"0.61740535",
"0.61605734",
"0.6155109",
"0.61548096",
"0.61548096",
"0.61211425",
"0.61083597",
"0.60532004",
"0... | 0.0 | -1 |
Update rows in DB | def update_password(id, password_digest)
@user = User.update(id, password_digest: password_digest)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n eqs = self.class.columns.map { |column| \"#{column} = ?\"}.join(\", \")\n DBConnection.execute(<<-SQL, *attribute_values, id)\n UPDATE\n #{self.class.table_name}\n SET\n #{eqs}\n WHERE\n id = ?\n SQL\n end",
"def update #:nodoc:\n connection.u... | [
"0.71263164",
"0.69871706",
"0.69085234",
"0.68665504",
"0.6851652",
"0.6851155",
"0.6842603",
"0.6837504",
"0.6812955",
"0.6799317",
"0.6783388",
"0.6781377",
"0.67721355",
"0.6729756",
"0.67269266",
"0.6706013",
"0.6695176",
"0.66922516",
"0.66756916",
"0.6670629",
"0.66581... | 0.0 | -1 |
Delete rows from DB | def delete_user(id)
@user = User.destroy(id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n\n DB.execute(\"DELETE FROM #{table_name} WHERE id = #{@id};\")\n end",
"def delete\n binding.pry\n DATABASE.execute(\"DELETE FROM contents WHERE id = #{id}\")\n end",
"def _delete_records\n @ids_to_delete.each do |table, ids|\n delete_from_table(table, ids)\n end\n e... | [
"0.77756673",
"0.7361088",
"0.7307307",
"0.7274946",
"0.7270564",
"0.7260797",
"0.72573304",
"0.7236775",
"0.7231194",
"0.7198134",
"0.71708566",
"0.7168345",
"0.7167993",
"0.7158856",
"0.7141489",
"0.7130141",
"0.7120464",
"0.71183014",
"0.70813626",
"0.7068942",
"0.7059416"... | 0.0 | -1 |
check if the entity is a raw entity | def is_entity?(entity)
id, name, zone, zone_pos, card_id, player, type = parse_entity(entity)
!id.nil? || !name.nil? || !zone.nil? || !zone_pos.nil? || !card_id.nil? || !player.nil? || !type.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entity?\n @contents[0] == :entity\n end",
"def raw?\n !!@raw\n end",
"def has_raw_for? raw_object_class\n available_raws.include? raw_object_class\n end",
"def raw?\n @raw\n end",
"def only_entities?\n only? :entities\n end",
"def entity?\n n... | [
"0.7246713",
"0.69875085",
"0.6986522",
"0.6905418",
"0.626288",
"0.62055993",
"0.6108908",
"0.5998785",
"0.59360945",
"0.5810678",
"0.5796234",
"0.57902384",
"0.5769587",
"0.57690555",
"0.5738773",
"0.5715852",
"0.5542876",
"0.5526565",
"0.5512727",
"0.550019",
"0.550019",
... | 0.6559507 | 4 |
like the Simple Tracker, but only checks a "checkerboard" of squares | def track_hit(board, cell)
queue = [cell]
while current = queue.shift
# mark explored
board.explore!(current)
# if any neighbors are dashes, return first dash
blank = board.next_blank_neighbor(current)
return blank if blank != nil
# if any neighbors are hits, explore them
queue += ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def castling_check_squares(checks)\n i = 0\n index = colour == 'White' ? 4 : 60\n checks.times do\n index -= 1 if checks == 3\n index += 1 if checks == 2\n break if board[index].current_piece != ' '\n\n i += 1\n end\n i == checks ? castling_move(checks) : false\n end",
"def ga... | [
"0.751432",
"0.7221199",
"0.72117263",
"0.7078759",
"0.7001211",
"0.6918905",
"0.68983",
"0.6895076",
"0.6830524",
"0.67839956",
"0.6777303",
"0.67464286",
"0.67117745",
"0.669595",
"0.6694996",
"0.6690824",
"0.66881806",
"0.6680572",
"0.6658577",
"0.66496974",
"0.6642237",
... | 0.0 | -1 |
I could combine this under one universal 'get' method, but I want them separate for testing right now, since I'm spending too much time on this already. :) | def forecast(forecast_path)
response = Curl.get(forecast_path) do |curl|
curl.headers['Accept'] = 'application/json'
end
JSON.parse(response.body_str)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get; end",
"def get(*args, &block); end",
"def get(*args, &block)\n end",
"def get(object); end",
"def get!\n throw NotImplementedError\n end",
"def get!\n throw NotImplementedError\n end",
"def get\n raise NotImplementedError\n end",
"def get(key)\n end",
"d... | [
"0.70421606",
"0.70198464",
"0.6996982",
"0.6866366",
"0.6816317",
"0.6816317",
"0.6788379",
"0.67868316",
"0.67683077",
"0.6759134",
"0.6757778",
"0.6745543",
"0.67015654",
"0.66950357",
"0.6686257",
"0.66749054",
"0.6626419",
"0.6626419",
"0.6626419",
"0.6626419",
"0.661447... | 0.0 | -1 |
POST session => '/login' Authenticate and create a session for, a User | def create
@user = User.find_by(e_mail: params[:session][:email].downcase)
if @user && @user.authenticate(params[:session][:password])
# Login successful, save user_id to session and redirect to user page
log_in @user
redirect_to home_path
else
# Login unsuccessful, redirect to Log In Page and ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_session\n req_params = params[:user]\n unless req_params\n @msg = \"Login details not found\"\n render \"objects/msg.json\", status: :unauthorized and return\n end\n @user = User.find_by_email(req_params[:email])\n if @user && @user.authenticate(req_params[:password])\n ses... | [
"0.8250645",
"0.80362225",
"0.80274916",
"0.79344124",
"0.7839807",
"0.78107363",
"0.7788883",
"0.7781739",
"0.77585363",
"0.7750324",
"0.77441806",
"0.7739255",
"0.77361387",
"0.77234536",
"0.7722842",
"0.769149",
"0.76737374",
"0.76732165",
"0.7666833",
"0.7664181",
"0.7649... | 0.76193184 | 26 |
DELETE session => '/logout' Quit the Session of a User who has logged out | def destroy
log_out
redirect_to root_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logout\n session.delete(:user_id)\n end",
"def logout\n session.delete :user_id\n end",
"def destroy\n session[:user_id] = nil\n redirect_to sessions_path, flash: { info: 'Logged Out' }\n end",
"def destroy\n\n session.delete(:user_id)\n redirect_to root_path, notice: \"log... | [
"0.8560591",
"0.85555875",
"0.8505132",
"0.8500437",
"0.8478673",
"0.84387195",
"0.84320647",
"0.8429583",
"0.8419654",
"0.8412308",
"0.8398917",
"0.8398111",
"0.83766866",
"0.8374872",
"0.83724374",
"0.83565056",
"0.8343383",
"0.83359724",
"0.8335173",
"0.8325423",
"0.831442... | 0.0 | -1 |
Gets a friends last name from users table | def last_name
friend = User.find_by_id(self.friend_id)
return friend.last_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_lastname(who_asks)\n raise \"public_lastname: #{who_asks} is no User\" unless who_asks.is_a? User\n if (who_asks.shapter_admin or (who_asks.schools & self.schools).any? or self.is_friend_with?(who_asks) or who_asks == self)\n lastname\n else\n schools.any? ? \"from #{schools.first.nam... | [
"0.70736337",
"0.696901",
"0.6884138",
"0.67245656",
"0.6520941",
"0.65077955",
"0.64588434",
"0.6415061",
"0.63527673",
"0.6342072",
"0.63271964",
"0.63204914",
"0.62762225",
"0.627578",
"0.62749535",
"0.62705463",
"0.6264678",
"0.6264008",
"0.6263019",
"0.62460935",
"0.6224... | 0.8421397 | 0 |
Extends the base encryption logger. | def encryption_logger
@encryption_logger ||= HipaaCrypt.config.logger.tap do |logger|
logger.formatter = LogFormatter.new(self) if logger.respond_to? :formatter=
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_key\n @log_key ||= \"#{super}: #{name}\"\n end",
"def log_key\n @log_key ||= \"#{super}: #{name}\"\n end",
"def log_key\n @log_key ||= \"#{super}: #{name}\"\n end",
"def log_key\n @log_key ||= \"#{super}: #{name}\"\n end",
"def logger\n params[:secure] ? nil : sup... | [
"0.6019104",
"0.6019104",
"0.6019104",
"0.6019104",
"0.5942171",
"0.5773535",
"0.57033265",
"0.56575185",
"0.5619435",
"0.5606949",
"0.55824727",
"0.55697966",
"0.55662906",
"0.5559302",
"0.5553389",
"0.5553389",
"0.5553389",
"0.5553389",
"0.5553389",
"0.5553389",
"0.5553389"... | 0.7620189 | 0 |
Returns an attributes hash with decrypted value. | def attributes_without_encrypted_values
attributes_with_decrypted_values.except *eager_load_conductors.map(&:encrypted_attribute)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrypt_attrs\n self.class.encrypted_attrs.each do |attr|\n next unless (value = send(attr))\n\n send(\"#{attr}=\", decrypt(value)) if value.encoding.to_s.eql?('ASCII-8BIT')\n end\n end",
"def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end",
"def to_h... | [
"0.6523362",
"0.61798877",
"0.6053442",
"0.6042911",
"0.60036623",
"0.5939053",
"0.58868855",
"0.5843546",
"0.5840446",
"0.5823928",
"0.5692361",
"0.5681119",
"0.5677742",
"0.5667905",
"0.5645423",
"0.5615168",
"0.56102073",
"0.56102073",
"0.56102073",
"0.5572565",
"0.5565485... | 0.5530119 | 22 |
Returns an attributes hash with only encrypted attributes and their values. | def encrypted_attributes
active_record_attributes.except(*attributes_without_encrypted_values.keys)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_encrypted_encrypted_attributes\n @attr_encrypted_encrypted_attributes ||= begin\n duplicated= {}\n self.class.attr_encrypted_encrypted_attributes.map { |key, value| duplicated[key] = value.dup }\n duplicated\n end\n end",
"def attributes_without_encrypted_values\n ... | [
"0.7108091",
"0.68873936",
"0.68000907",
"0.644721",
"0.6400729",
"0.62769777",
"0.6271371",
"0.619852",
"0.618467",
"0.61775374",
"0.61509496",
"0.61509496",
"0.61509496",
"0.6116086",
"0.61138296",
"0.60854715",
"0.6062942",
"0.6044199",
"0.60329926",
"0.6031031",
"0.602295... | 0.7616943 | 0 |
Extends ActiveRecord's write_attribute to support encrypted attrs. | def write_attribute(attr, value)
if attribute_encrypted?(attr)
conductor_for(attr).encrypt(value)
else
super(attr, value)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_encrypted_encrypt(attribute, value)\n attr_encrypted_encrypted_attributes[attribute.to_sym][:operation] = :encrypting\n attr_encrypted_encrypted_attributes[attribute.to_sym][:value_present] = self.class.not_empty?(value)\n self.class.attr_encrypted_encrypt(attribute, value, evaluated_attr_e... | [
"0.74393374",
"0.73768157",
"0.72323316",
"0.7131553",
"0.7120223",
"0.6845054",
"0.6593178",
"0.6480073",
"0.6325669",
"0.6313302",
"0.6306687",
"0.627871",
"0.6243839",
"0.62150717",
"0.62140083",
"0.62114143",
"0.6203202",
"0.62019694",
"0.61872935",
"0.61861944",
"0.61861... | 0.8635688 | 0 |
Extends ActiveRecord's read_attribute to support encrypted attrs. | def read_attribute(attr)
if attribute_encrypted?(attr)
conductor_for(attr).decrypt
else
super(attr)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrypt_attrs\n self.class.encrypted_attrs.each do |attr|\n next unless (value = send(attr))\n\n send(\"#{attr}=\", decrypt(value)) if value.encoding.to_s.eql?('ASCII-8BIT')\n end\n end",
"def encrypted_password\n read_attribute(:password)\n end",
"def read_attribute(attr_nam... | [
"0.67751485",
"0.6762016",
"0.66985035",
"0.6666801",
"0.6519128",
"0.6514484",
"0.6512178",
"0.6510742",
"0.65083945",
"0.64952576",
"0.64818364",
"0.6471636",
"0.64364886",
"0.64197147",
"0.63702315",
"0.63048273",
"0.6287021",
"0.62778693",
"0.62604743",
"0.6245593",
"0.62... | 0.8183274 | 0 |
GET /socio_spcs GET /socio_spcs.json | def index
@socio_spcs = SocioSpc.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @socio_cpfs = SocioCpf.all\n end",
"def set_socio_spc\n @socio_spc = SocioSpc.find(params[:id])\n end",
"def create\n @socio_spc = SocioSpc.new(socio_spc_params)\n\n respond_to do |format|\n if @socio_spc.save\n format.html { redirect_to @socio_spc, notice: 'Socio spc ... | [
"0.6844222",
"0.6674467",
"0.63406736",
"0.6273472",
"0.62315077",
"0.6208288",
"0.6157651",
"0.61440426",
"0.6071991",
"0.60687745",
"0.6059889",
"0.6053236",
"0.6042217",
"0.6014204",
"0.59261656",
"0.5919124",
"0.5919124",
"0.58466977",
"0.5812566",
"0.57671565",
"0.575519... | 0.77198744 | 0 |
GET /socio_spcs/1 GET /socio_spcs/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @socio_spcs = SocioSpc.all\n end",
"def show\n @socio = Socio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @socio }\n end\n end",
"def index\n @socio_cpfs = SocioCpf.all\n end",
"def show\n @socio = Socio.fi... | [
"0.75288117",
"0.6720051",
"0.6715686",
"0.6639251",
"0.6568708",
"0.6469277",
"0.6378031",
"0.6367262",
"0.63139635",
"0.61061525",
"0.6105996",
"0.6087727",
"0.6087727",
"0.60633886",
"0.6025306",
"0.60200375",
"0.5992854",
"0.5989235",
"0.59672785",
"0.59010774",
"0.585768... | 0.0 | -1 |
POST /socio_spcs POST /socio_spcs.json | def create
@socio_spc = SocioSpc.new(socio_spc_params)
respond_to do |format|
if @socio_spc.save
format.html { redirect_to @socio_spc, notice: 'Socio spc was successfully created.' }
format.json { render action: 'show', status: :created, location: @socio_spc }
else
format.ht... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @socio_cpf = SocioCpf.new(socio_cpf_params)\n\n respond_to do |format|\n if @socio_cpf.save\n format.html { redirect_to @socio_cpf, notice: 'Socio cpf was successfully created.' }\n format.json { render action: 'show', status: :created, location: @socio_cpf }\n else\n ... | [
"0.6555344",
"0.64490026",
"0.63512397",
"0.6346295",
"0.6188843",
"0.6109039",
"0.6033995",
"0.59970677",
"0.5964809",
"0.59473276",
"0.5917161",
"0.59063625",
"0.5899066",
"0.5896521",
"0.5829742",
"0.5814346",
"0.56976664",
"0.56946003",
"0.5690837",
"0.5679961",
"0.566807... | 0.72416914 | 0 |
PATCH/PUT /socio_spcs/1 PATCH/PUT /socio_spcs/1.json | def update
respond_to do |format|
if @socio_spc.update(socio_spc_params)
format.html { redirect_to @socio_spc, notice: 'Socio spc was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @socio_spc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @socio_cpf.update(socio_cpf_params)\n format.html { redirect_to @socio_cpf, notice: 'Socio cpf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json... | [
"0.6790109",
"0.6658849",
"0.6653258",
"0.6440935",
"0.64263874",
"0.64155024",
"0.62927365",
"0.6290705",
"0.6245551",
"0.62402517",
"0.6237181",
"0.62312895",
"0.62240136",
"0.6222842",
"0.61925685",
"0.618729",
"0.61612654",
"0.6151887",
"0.61151356",
"0.60768867",
"0.6046... | 0.7245081 | 0 |
DELETE /socio_spcs/1 DELETE /socio_spcs/1.json | def destroy
@socio_spc.destroy
respond_to do |format|
format.html { redirect_to socio_spcs_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @socio_cpf.destroy\n respond_to do |format|\n format.html { redirect_to socio_cpfs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cso = Cso.find(params[:id])\n @cso.destroy\n\n respond_to do |format|\n format.html { redirect_to csos_url }\n ... | [
"0.7256453",
"0.72521836",
"0.7147893",
"0.7147893",
"0.69741213",
"0.69255227",
"0.6916226",
"0.69050235",
"0.68656063",
"0.6826662",
"0.68245834",
"0.6819679",
"0.676314",
"0.6759462",
"0.67438304",
"0.6722778",
"0.67226183",
"0.67081875",
"0.6671944",
"0.6654555",
"0.66511... | 0.7744579 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_socio_spc
@socio_spc = SocioSpc.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def socio_spc_params
params.require(:socio_spc).permit(:interessado_id, :arquivo)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981269",
"0.6783559",
"0.6746007",
"0.67423046",
"0.6735905",
"0.6593568",
"0.6504213",
"0.649792",
"0.6482664",
"0.6478558",
"0.64566684",
"0.64392304",
"0.6380194",
"0.6376366",
"0.636562",
"0.63208145",
"0.63006365",
"0.63001287",
"0.6292953",
"0.62927175",
"0.62911004... | 0.0 | -1 |
adjust position to account for \r on Windows | def adjust_occurrences(data)
if Gem.win_platform?
data = data.dup
data[:occurrences].map! { |occ| adjust_occurrence occ }
end
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rl_move_cursor_relative(new, data, start=0)\r\n woff = w_offset(@_rl_last_v_pos, @wrap_offset)\r\n cpos = @_rl_last_c_pos\r\n\r\n if !@rl_byte_oriented\r\n dpos = _rl_col_width(data, start, start+new)\r\n\r\n # Use NEW when comparing against the last invisible character in the\r\n # pr... | [
"0.63187206",
"0.62014055",
"0.6169368",
"0.60064745",
"0.5981039",
"0.58663976",
"0.581064",
"0.5783142",
"0.57310575",
"0.56937474",
"0.56735384",
"0.5667121",
"0.566076",
"0.5655717",
"0.5651592",
"0.56492347",
"0.56399244",
"0.5611563",
"0.5611105",
"0.5597643",
"0.557861... | 0.0 | -1 |
adjust position to account for \r on Windows | def adjust_occurrence(occurrence)
occurrence.dup.tap { |o| o.instance_variable_set(:@pos, o.pos + o.line_num - 1) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rl_move_cursor_relative(new, data, start=0)\r\n woff = w_offset(@_rl_last_v_pos, @wrap_offset)\r\n cpos = @_rl_last_c_pos\r\n\r\n if !@rl_byte_oriented\r\n dpos = _rl_col_width(data, start, start+new)\r\n\r\n # Use NEW when comparing against the last invisible character in the\r\n # pr... | [
"0.63195986",
"0.6200448",
"0.617079",
"0.600494",
"0.59800404",
"0.5866688",
"0.5810935",
"0.5783103",
"0.5730424",
"0.56926036",
"0.5673012",
"0.5667304",
"0.5661473",
"0.56555176",
"0.5652407",
"0.56482404",
"0.5640739",
"0.56114054",
"0.56108344",
"0.55991614",
"0.5577963... | 0.0 | -1 |
Return whether or not clause A being true implies that clause B must be true as well. | def implies(clause_a, clause_b)
simplified_clause_a = Simplifier.simplify_clause(clause_a)
simplified_clause_b = Simplifier.simplify_clause(clause_b)
return false if simplified_clause_a.nil? || simplified_clause_b.nil?
clause_a_matches = simplified_clause_a.match_clauses.group_by(&:match_key)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def informed_consent?\n consent_activity? && !reconsent? && !withdrawal? && !child_consent?\n end",
"def can_make_decision?\n self.awaiting_decisions? || self.awaiting_replies? || self.all_rejected?\n end",
"def cant_be_claimed_by_other_and_below_income_requirement?\n dependent.cant_be_claimed_b... | [
"0.6220808",
"0.61775374",
"0.59236795",
"0.58321565",
"0.5823106",
"0.5803699",
"0.5653673",
"0.5642393",
"0.56209797",
"0.55961233",
"0.55156034",
"0.55106866",
"0.54930425",
"0.5477649",
"0.5462462",
"0.5459598",
"0.5446801",
"0.5441867",
"0.54319227",
"0.54317564",
"0.541... | 0.7035527 | 0 |
Temporarily turns off auditing while saving. | def save_without_auditing
without_auditing { save }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_without_auditing\n without_auditing { save }\n end",
"def save_with_auditing\n with_auditing { save }\n end",
"def with_auditing\n auditing_was_enabled = Audited.auditing_enabled\n Audited.auditing_enabled = true\n super\n ensure\n Audited.auditing_en... | [
"0.82458025",
"0.73364204",
"0.73283017",
"0.70068455",
"0.6780273",
"0.6753743",
"0.6706377",
"0.663303",
"0.6548643",
"0.6484208",
"0.63934636",
"0.6369038",
"0.6330556",
"0.63206804",
"0.6319461",
"0.6236376",
"0.6139465",
"0.60555977",
"0.60140204",
"0.60140204",
"0.59926... | 0.818844 | 1 |
Executes the block with the auditing callbacks disabled. | def without_auditing(&block)
self.class.without_auditing(&block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def without_auditing(&block)\n auditing_was_enabled = auditing_enabled\n disable_auditing\n block.call\n ensure\n enable_auditing if auditing_was_enabled\n end",
"def without_auditing(&block)\n self.class.without_auditing(&block)\n end",
"def wi... | [
"0.8143905",
"0.78017384",
"0.7635161",
"0.7264768",
"0.6500235",
"0.63362694",
"0.6311202",
"0.60665935",
"0.604094",
"0.60333496",
"0.6019101",
"0.6013918",
"0.5964803",
"0.59273875",
"0.5901776",
"0.5875734",
"0.57861716",
"0.576608",
"0.5759403",
"0.5757385",
"0.57496923"... | 0.76810914 | 3 |
Temporarily turns on auditing while saving. | def save_with_auditing
with_auditing { save }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_without_auditing\n without_auditing { save }\n end",
"def save_without_auditing\n without_auditing { save }\n end",
"def with_auditing\n auditing_was_enabled = Audited.auditing_enabled\n Audited.auditing_enabled = true\n super\n ensure\n Audited.audit... | [
"0.77831036",
"0.7645905",
"0.75075144",
"0.7259416",
"0.72231704",
"0.71230346",
"0.70792675",
"0.704349",
"0.6894587",
"0.6697119",
"0.65893096",
"0.6454837",
"0.64443946",
"0.6397411",
"0.634182",
"0.62726444",
"0.62676704",
"0.61593527",
"0.61239535",
"0.6123536",
"0.6123... | 0.7833579 | 0 |
Executes the block with the auditing callbacks enabled. | def with_auditing(&block)
self.class.with_auditing(&block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_auditing\n auditing_was_enabled = class_auditing_enabled\n enable_auditing\n yield\n ensure\n disable_auditing unless auditing_was_enabled\n end",
"def without_auditing(&block)\n auditing_was_enabled = auditing_enabled\n disable_auditing\n ... | [
"0.67436665",
"0.67127156",
"0.64510274",
"0.6279859",
"0.6279859",
"0.62201333",
"0.61755186",
"0.5991437",
"0.598413",
"0.598413",
"0.5958174",
"0.59476745",
"0.59446496",
"0.5891783",
"0.5700106",
"0.5684655",
"0.56677485",
"0.56631476",
"0.56053835",
"0.55838424",
"0.5484... | 0.7521429 | 0 |
Gets an array of the revisions available user.revisions.each do |revision| user.name user.version end | def revisions(from_version = 1)
return [] unless audits.from_version(from_version).exists?
all_audits = audits.select([:audited_changes, :version, :action]).to_a
targeted_audits = all_audits.select { |audit| audit.version >= from_version }
previous_attributes = reconstruct_attributes(a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version_users\n if !self.paper_trail.live?\n v = self.version\n if v.association_data[:user_ids]\n v_users = []\n users = User.where(\"id IN (#{ v.association_data[:user_ids].join(',') })\")\n users.each do |u|\n v_users << u.paper_trail.version_at(v.created_at)\n ... | [
"0.71311945",
"0.6944176",
"0.69189036",
"0.68397397",
"0.67775595",
"0.6758697",
"0.6692288",
"0.663457",
"0.6628089",
"0.66277725",
"0.6520082",
"0.6457564",
"0.64441043",
"0.6409189",
"0.62063414",
"0.619747",
"0.61738175",
"0.6124502",
"0.61175954",
"0.6104518",
"0.603596... | 0.60730237 | 20 |
Get a specific revision specified by the version number, or +:previous+ Returns nil for versions greater than revisions count | def revision(version)
if version == :previous || audits.last.version >= version
revision_with Audited.audit_class.reconstruct_attributes(audits_to(version))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_revision(rev_num)\n if @current_revision.revision_identifier.to_s == rev_num\n return @current_revision\n end\n @revision_history.each do |revision|\n if revision.revision_identifier.to_s == rev_num\n return revision\n end\n end\n # revision with the specified revision ... | [
"0.7560023",
"0.7531266",
"0.73046815",
"0.72479314",
"0.72469234",
"0.7123682",
"0.7080274",
"0.703153",
"0.70143986",
"0.6994348",
"0.6954016",
"0.695393",
"0.6949923",
"0.6928843",
"0.6893474",
"0.68908817",
"0.6860832",
"0.6820999",
"0.68058854",
"0.68058693",
"0.6795132"... | 0.7108257 | 6 |
Find the oldest revision recorded prior to the date/time provided. | def revision_at(date_or_time)
audits = self.audits.up_until(date_or_time)
revision_with Audited.audit_class.reconstruct_attributes(audits) unless audits.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def just_the_revision_one_before\n self.posts_revisions.where(\"post_id = ?\", self.id).order(\"monologue_posts_revisions.updated_at DESC\").offset(1).limit(1).first\n end",
"def previous_revision\n self.class.find(:first, :conditions => {:revisable_original_id => revisable_original_id, :revisable_num... | [
"0.67310256",
"0.6684161",
"0.66557395",
"0.65978026",
"0.6511374",
"0.63972425",
"0.63536495",
"0.63410187",
"0.6293851",
"0.618348",
"0.6178597",
"0.611202",
"0.6110447",
"0.60938424",
"0.59645873",
"0.5951396",
"0.58713055",
"0.58159965",
"0.5814049",
"0.5804616",
"0.57983... | 0.6054221 | 15 |
List of attributes that are audited. | def audited_attributes
audited_attributes = attributes.except(*self.class.non_audited_columns)
audited_attributes = redact_values(audited_attributes)
audited_attributes = filter_encrypted_attrs(audited_attributes)
normalize_enum_changes(audited_attributes)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def audited_attributes\n attributes.except(*non_audited_columns.map(&:to_s))\n end",
"def audited_attributes\n self.attributes.keys.select { |k| !self.non_audited_columns.include?(k) }\n end",
"def audited_attributes\n attrs = @audited_attributes || []\n # handle STI ... | [
"0.807433",
"0.78644973",
"0.7736334",
"0.7736334",
"0.73435694",
"0.7252675",
"0.72500485",
"0.7171406",
"0.7119008",
"0.70649254",
"0.7029862",
"0.70124066",
"0.69435793",
"0.691794",
"0.68741083",
"0.6862207",
"0.6795728",
"0.6794885",
"0.679035",
"0.679035",
"0.679035",
... | 0.7328984 | 5 |
Returns a list combined of record audits and associated audits. | def own_and_associated_audits
Audited.audit_class.unscoped.where(auditable: self)
.or(Audited.audit_class.unscoped.where(associated: self))
.order(created_at: :desc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report\n @audits = Audit.all\n end",
"def audits\n Audit::Tracking.log.audits(audit_bucket, self.id)\n end",
"def retrieve_audits_from_s3\n [].tap do |results|\n auditable_audit = new_audit({})\n auditable_s3_key = @s3_auditor.resolve_s3_key(auditable_audit)\n results.concat(@s3_a... | [
"0.6966717",
"0.68748444",
"0.66059864",
"0.65566826",
"0.6486951",
"0.6486951",
"0.6345776",
"0.6251011",
"0.6213214",
"0.6213214",
"0.6133956",
"0.60842144",
"0.6048119",
"0.603626",
"0.5737865",
"0.5720775",
"0.57200426",
"0.56425995",
"0.5638478",
"0.559624",
"0.54997265"... | 0.60109204 | 14 |
Combine multiple audits into one. | def combine_audits(audits_to_combine)
combine_target = audits_to_combine.last
combine_target.audited_changes = audits_to_combine.pluck(:audited_changes).reduce(&:merge)
combine_target.comment = "#{combine_target.comment}\nThis audit is the result of multiple audits being combined."
tran... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def audits\n Audit::Tracking.log.audits(audit_bucket, self.id)\n end",
"def grouped_audits\n audits.group_by(&:request_uuid).map { |_, audits| audits.first }\n end",
"def report\n @audits = Audit.all\n end",
"def retrieve_audits_from_s3\n [].tap do |results|\n auditable_audit = new_au... | [
"0.5846475",
"0.579175",
"0.5516562",
"0.54223454",
"0.5345166",
"0.51224995",
"0.5094987",
"0.50438684",
"0.49696192",
"0.4959228",
"0.49337846",
"0.4932968",
"0.4932232",
"0.4925041",
"0.49126664",
"0.49126664",
"0.48725843",
"0.48725843",
"0.4851956",
"0.485194",
"0.483605... | 0.70858103 | 0 |
Replace values for given attrs to a placeholder and return modified hash | def filter_attr_values(audited_changes: {}, attrs: [], placeholder: "[FILTERED]")
attrs.each do |attr|
next unless audited_changes.key?(attr)
changes = audited_changes[attr]
values = changes.is_a?(Array) ? changes.map { placeholder } : placeholder
audited_changes[attr] ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decorated_attributes(attrs = {})\n attrs.dup\n end",
"def create_attrs hash\n r = hash.map { |k,v| \"#{k}=\\\"#{escape_attr v.to_s}\\\"\" }.join(' ')\n \" #{r}\" unless r.empty?\n end",
"def set_attrs(hash, clobber=true, target = nil)\n target ||= @attrs\n if clobber\n target.me... | [
"0.5824595",
"0.5804223",
"0.5749352",
"0.5719841",
"0.57165056",
"0.57165056",
"0.5619778",
"0.56025195",
"0.55896205",
"0.5588229",
"0.55589193",
"0.55541867",
"0.55277145",
"0.54756165",
"0.5465922",
"0.54657084",
"0.54382706",
"0.54352915",
"0.54182833",
"0.54139316",
"0.... | 0.5737506 | 3 |
We have to calculate this here since column_names may not be available when `audited` is called | def non_audited_columns
@non_audited_columns ||= calculate_non_audited_columns
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exsiting_columns_for_audit\n columns_for_audit & self.column_names\n end",
"def audit_columns(*columns)\n cattr_accessor :_audit_columns\n self._audit_columns = columns.map(&:to_s) & valid_column_names\n end",
"def synthetic_columns\n @columns ||= [:id]\n end",
"def exp... | [
"0.7655646",
"0.653837",
"0.65279186",
"0.6443194",
"0.6440945",
"0.63370585",
"0.6290894",
"0.62524766",
"0.6243562",
"0.62401897",
"0.6209245",
"0.6169311",
"0.61474943",
"0.61435115",
"0.6098106",
"0.60891783",
"0.6083636",
"0.60645384",
"0.6063743",
"0.6042469",
"0.602420... | 0.7269556 | 1 |
Executes the block with auditing disabled. Foo.without_auditing do | def without_auditing
auditing_was_enabled = class_auditing_enabled
disable_auditing
yield
ensure
enable_auditing if auditing_was_enabled
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def without_auditing(&block)\n auditing_was_enabled = auditing_enabled\n disable_auditing\n block.call\n ensure\n enable_auditing if auditing_was_enabled\n end",
"def without_auditing(&block)\n self.class.without_auditing(&block)\n end",
"def wi... | [
"0.8492687",
"0.8347148",
"0.82496893",
"0.82496893",
"0.8123317",
"0.66973174",
"0.65275335",
"0.63352865",
"0.61434853",
"0.60642457",
"0.59981996",
"0.5994024",
"0.5984997",
"0.5970143",
"0.5949167",
"0.59373295",
"0.58254594",
"0.58235276",
"0.5815566",
"0.58006984",
"0.5... | 0.7775353 | 5 |
Executes the block with auditing enabled. Foo.with_auditing do | def with_auditing
auditing_was_enabled = class_auditing_enabled
enable_auditing
yield
ensure
disable_auditing unless auditing_was_enabled
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_auditing(&block)\n self.class.with_auditing(&block)\n end",
"def without_auditing(&block)\n auditing_was_enabled = auditing_enabled\n disable_auditing\n block.call\n ensure\n enable_auditing if auditing_was_enabled\n end",
"def without_audi... | [
"0.85040814",
"0.70450664",
"0.68763894",
"0.68673617",
"0.68024004",
"0.68024004",
"0.65941244",
"0.6558212",
"0.6535662",
"0.6376828",
"0.6376828",
"0.60776573",
"0.6015355",
"0.60146284",
"0.597895",
"0.5970385",
"0.59621346",
"0.56768185",
"0.56351703",
"0.557901",
"0.554... | 0.7729646 | 1 |
All audit operations during the block are recorded as being made by +user+. This is not model specific, the method is a convenience wrapper around | def audit_as(user, &block)
Audited.audit_class.as_user(user, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_auditing(&block)\n self.class.with_auditing(&block)\n end",
"def audit_user\n user\n # TODO Renable/refactor for Questioner 2.0\n # applicable_audit ? applicable_audit.reify(has_many: true) : user\n end",
"def acting_as_user_of_record\n old_current = User.current\n Use... | [
"0.70657957",
"0.67916566",
"0.6219551",
"0.6195375",
"0.61845577",
"0.6137562",
"0.6121302",
"0.61140406",
"0.6087569",
"0.60865504",
"0.6072355",
"0.6070592",
"0.60677",
"0.60670596",
"0.6027984",
"0.6005981",
"0.59553254",
"0.5951934",
"0.59493583",
"0.5931641",
"0.5914979... | 0.78855836 | 1 |
def callbacks self.leads.callbacks(Time.now) end | def login=(value)
write_attribute :login, (value ? value.downcase : nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callbacks; end",
"def callbacks; end",
"def callbacks\n @callbacks ||= {}\n end",
"def after_callbacks\n @after_callbacks ||= []\n end",
"def after_recorded\n end",
"def call_back_lead\n if \"sent\" == status && \"Lead\" == source_type\n source.after_sent(self)\n e... | [
"0.707871",
"0.707871",
"0.6572121",
"0.648887",
"0.63204443",
"0.62219286",
"0.6211541",
"0.61423725",
"0.6121653",
"0.6118879",
"0.61092055",
"0.60633516",
"0.6024988",
"0.60102254",
"0.599953",
"0.5992823",
"0.597372",
"0.5909151",
"0.5906408",
"0.5858457",
"0.5858457",
... | 0.0 | -1 |
def assignments self.leads end def assignments=(val) self.leads = val end | def deactivate
self.activation_code = 'DEACTIVATED'
self.activated_at = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assignments; end",
"def assignments=(value)\n @assignments = value\n end",
"def assignments=(value)\n @assignments = value\n end",
"def assignments=(value)\n @assignments = value\n end",
"def assignments=(value)\n ... | [
"0.6567195",
"0.63807267",
"0.63807267",
"0.63807267",
"0.63807267",
"0.63807267",
"0.5791195",
"0.55366087",
"0.543984",
"0.5371535",
"0.5330167",
"0.53235215",
"0.52773666",
"0.5237192",
"0.5150396",
"0.5137681",
"0.5136813",
"0.51312363",
"0.51312363",
"0.51312363",
"0.513... | 0.0 | -1 |
Activates the user in the database. | def activate!
@activated = true
self.activated_at = Time.now.utc
self.activation_code = nil
save(false)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activate\r\n Marketplace::Database.instance.delete_deactivated_user(self)\r\n Marketplace::Database.instance.add_user(self)\r\n Marketplace::Activity.create(Activity.USER_REACTIVATE, self, \"#{self.name} has been reactivated\")\r\n end",
"def activate_user(user_id)\n post(\"/users/#{us... | [
"0.774844",
"0.7733132",
"0.7506561",
"0.7459922",
"0.73903275",
"0.73561454",
"0.73095596",
"0.72862256",
"0.72649777",
"0.72638553",
"0.7260902",
"0.7223405",
"0.72204673",
"0.72159785",
"0.72017646",
"0.71199465",
"0.709682",
"0.70864254",
"0.7054342",
"0.7048244",
"0.7033... | 0.6634492 | 91 |
Returns true if the user has just been activated. | def recently_activated?
@activated
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activated?\n self.user && self.user.activated?\n end",
"def recently_activated?\n @activated\n end",
"def recently_activated?\n @activated\n end",
"def recently_activated?\n @activated\n end",
"def recently_activated?\n @activated\n end",
"def recently_... | [
"0.82776856",
"0.7811329",
"0.7804574",
"0.7778738",
"0.7778738",
"0.77549386",
"0.77341413",
"0.7729316",
"0.7685652",
"0.76716274",
"0.7668748",
"0.7614284",
"0.759112",
"0.75275487",
"0.7495403",
"0.74625885",
"0.73862773",
"0.73260075",
"0.72826624",
"0.7257669",
"0.71833... | 0.76535165 | 54 |
Given an actor, "sender" or "receiver", remove selected from available options for opposite actor. | def actor_collection_for_select_options(project, actor)
# Return empty list if actor is not a sender nor a receiver
return [] unless actor.in?(['sender', 'receiver'])
# Gets the opposite actor of the actor given sender -> receiver, etc.
actor_opposite = actor == 'sender' ? 'receiver' : 'sender'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def actor_collection_for_select_options(project, actor)\r\n # Return empty list if actor is not a sender nor a receiver\r\n return [] unless actor.in?(['sender', 'receiver'])\r\n # Gets the opposite actor of the actor given sender -> receiver, etc.\r\n actor_opposite = actor == 'sender' ? 'receiver' : ... | [
"0.6248231",
"0.6083832",
"0.6055906",
"0.5877123",
"0.5877123",
"0.5857703",
"0.5816295",
"0.5781849",
"0.57661635",
"0.5738976",
"0.5648026",
"0.5635074",
"0.5623263",
"0.5579397",
"0.5572715",
"0.5555947",
"0.5539885",
"0.55133915",
"0.5463015",
"0.5460076",
"0.5416023",
... | 0.6193209 | 1 |
return raw OCI8 or JDBC connection | def raw_connection
@raw_connection.raw_connection
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jdbc_connection(unwrap = false)\n java_connection = raw_connection.connection\n return java_connection unless unwrap\n\n connection_class = java.sql.Connection.java_class\n begin\n if java_connection.wrapper_for?(connection_class)\n return java_connection.unwrap(... | [
"0.71521723",
"0.71228373",
"0.6702651",
"0.6424175",
"0.6372173",
"0.62704915",
"0.6179078",
"0.6039764",
"0.6035553",
"0.5968502",
"0.5941886",
"0.58537084",
"0.5822685",
"0.57998794",
"0.5773323",
"0.5763092",
"0.5762561",
"0.5759819",
"0.57545274",
"0.57184386",
"0.570205... | 0.5829096 | 12 |
Returns true if the connection is active. | def active? # :nodoc:
# Pings the connection to check if it's still good. Note that an
# #active? method is also available, but that simply returns the
# last known state, which isn't good enough if the connection has
# gone stale since the last use.
@raw_connection.ping
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def active?\n @connection.state == System::Data::ConnectionState::open\n end",
"def active_connection?\n connection_id = current_connection_id\n if conn = @reserved_connections.fetch(connection_id, nil)\n !! conn.in_use? # synchronize { conn.in_use? }\n else\n f... | [
"0.85904133",
"0.8438344",
"0.8395971",
"0.83820033",
"0.8354499",
"0.83302975",
"0.8291291",
"0.8163027",
"0.80979985",
"0.8076065",
"0.8034295",
"0.80028796",
"0.8000029",
"0.7971276",
"0.793619",
"0.793619",
"0.7930023",
"0.7918458",
"0.7915968",
"0.78917295",
"0.7855052",... | 0.81925505 | 7 |
Reconnects to the database. | def reconnect! # :nodoc:
super
@raw_connection.reset!
rescue OracleEnhanced::ConnectionException => e
@logger.warn "#{adapter_name} automatic reconnection failed: #{e.message}" if @logger
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reconnect\n\t\tif @connection != nil\n\t\t\tself.close\n\n\t\t\t@connection = MonetDBConnection.new(user = @username, passwd = @password, lang = @lang, host = @host, port = @port)\n\t\t\t@connection.connect(db_name = @db_name, auth_type = @auth_type)\n\t\tend\n\tend",
"def reconnect\n if @connection != ... | [
"0.7848088",
"0.7820569",
"0.75845444",
"0.74174196",
"0.72610855",
"0.72448",
"0.7208437",
"0.7067654",
"0.70577633",
"0.69739646",
"0.6962033",
"0.6853215",
"0.6678131",
"0.6678131",
"0.6659533",
"0.66485524",
"0.66002524",
"0.66002524",
"0.6542254",
"0.65405655",
"0.649729... | 0.63794535 | 28 |
Disconnects from the database. | def disconnect! # :nodoc:
super
@raw_connection.logoff rescue nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disconnect\n database.close if connected?\n @@connections[name][db_name] = nil\n end",
"def disconnect\n\t\tbegin\n\t\t\tActiveRecord::Base.remove_connection\n\t\trescue ::Exception => e\n\t\t\tself.error = e\n\t\t\telog(\"DB.disconnect threw an exception: #{e}\")\n\t\tensure\n\t\t\t# Database d... | [
"0.82922244",
"0.750791",
"0.7432125",
"0.73831415",
"0.727666",
"0.7272669",
"0.7272669",
"0.7272669",
"0.7272669",
"0.71500415",
"0.7130929",
"0.69882435",
"0.6977073",
"0.6943458",
"0.69303185",
"0.6898174",
"0.68509895",
"0.6816283",
"0.67968524",
"0.6793507",
"0.6765314"... | 0.590924 | 84 |
Returns the next sequence value from a sequence generator. Not generally called directly; used by ActiveRecord to get the next primary key value when inserting a new database record (see prefetch_primary_key?). | def next_sequence_value(sequence_name)
# if sequence_name is set to :autogenerated then it means that primary key will be populated by trigger
raise ArgumentError.new "Trigger based primary key is not supported" if sequence_name == AUTOGENERATED_SEQUENCE_NAME
# call directly connection method to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_sequence_value(sequence_name)\n select_one(\"select #{sequence_name}.nextval id from dual\")['id']\n end",
"def next_sequence_value(sequence_name)\n @connection.query(\"SELECT NEXT VALUE FOR #{sequence_name} FROM RDB$DATABASE\")[0][0]\n end",
"def next_value_for_sequence(se... | [
"0.7880468",
"0.78736115",
"0.736579",
"0.73264533",
"0.71977085",
"0.7120799",
"0.71137875",
"0.69131434",
"0.6670589",
"0.64823616",
"0.63515407",
"0.6333826",
"0.6235445",
"0.6188936",
"0.6163044",
"0.61068743",
"0.607345",
"0.604594",
"0.6044277",
"0.6044231",
"0.6015637"... | 0.7502125 | 2 |
Returns true for Oracle adapter (since Oracle requires primary key values to be prefetched before insert). See also next_sequence_value. | def prefetch_primary_key?(table_name = nil)
return true if table_name.nil?
table_name = table_name.to_s
do_not_prefetch = @do_not_prefetch_primary_key[table_name]
if do_not_prefetch.nil?
owner, desc_table_name = @raw_connection.describe(table_name)
@do_not_prefetch_pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supports_primary_key?\n true\n end",
"def supports_primary_key?\n true\n end",
"def primary_key?\n false\n end",
"def primary_key?\n schema && schema[:primary_key]\n end",
"def supports_primary_key? #:nodoc:\n true\n end",
"def schema_autoincrem... | [
"0.67367625",
"0.66843647",
"0.6677524",
"0.66770744",
"0.6659706",
"0.65536296",
"0.6549668",
"0.65274155",
"0.65222085",
"0.65017486",
"0.65017486",
"0.6499998",
"0.6493161",
"0.6474652",
"0.6357075",
"0.6337522",
"0.6313275",
"0.6311338",
"0.6290571",
"0.62845606",
"0.6281... | 0.5834987 | 36 |
Current database session user | def current_user
select_value(<<~SQL.squish, "SCHEMA")
SELECT SYS_CONTEXT('userenv', 'session_user') FROM dual
SQL
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user\n session[:usr_id]\n end",
"def current_user\n\n sql = \"SELECT * FROM users WHERE id = $1;\"\n \n results = run_sql(sql, [session[:user_id]]) \n return results.first\n end",
"def current_user\n\t\tUser.find_by(:id => session[:user_id])\n\tend",
"def current_user\n User... | [
"0.8267263",
"0.8236474",
"0.8142938",
"0.8113551",
"0.8113551",
"0.81060463",
"0.81060463",
"0.81022733",
"0.80885375",
"0.8043542",
"0.8016256",
"0.8016256",
"0.8016256",
"0.80155706",
"0.7999621",
"0.79835194",
"0.7973193",
"0.7970066",
"0.7934439",
"0.7914488",
"0.7898734... | 0.84142256 | 0 |
Current database session schema | def current_schema
select_value(<<~SQL.squish, "SCHEMA")
SELECT SYS_CONTEXT('userenv', 'current_schema') FROM dual
SQL
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_schema\n exec_query('SELECT current_schema', 'SCHEMA')[0][\"current_schema\"]\n end",
"def current_schema\n select_value('SELECT current_schema()', 'SCHEMA')\n end",
"def current_schema\n select_value('SELECT current_schema', 'SCHEMA')\n end",
"def schema\n ... | [
"0.80971736",
"0.80088085",
"0.8005698",
"0.7847378",
"0.74356663",
"0.7381828",
"0.73362064",
"0.7230829",
"0.72176003",
"0.7191697",
"0.71788585",
"0.6961893",
"0.6957445",
"0.6937397",
"0.6879346",
"0.68639916",
"0.6817435",
"0.6798065",
"0.67692477",
"0.67623943",
"0.6742... | 0.81262493 | 0 |
Default tablespace name of current user | def default_tablespace
select_value(<<~SQL.squish, "SCHEMA")
SELECT LOWER(default_tablespace) FROM user_users
WHERE username = SYS_CONTEXT('userenv', 'current_schema')
SQL
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def namespaced_table_name\n [self.class.table_namespace, table_name].reject {|s| s.nil? || s.empty?}.join('-')\n end",
"def namespace\n \"#{database.name}.#{name}\"\n end",
"def namespace\n \"#{database.name}.#{name}\"\n end",
"def default_database_name\n self.name.tableize\n end",
... | [
"0.6558178",
"0.65109587",
"0.65109587",
"0.645052",
"0.64352447",
"0.642895",
"0.6398095",
"0.63763416",
"0.6325644",
"0.6308763",
"0.6226267",
"0.6112137",
"0.6052561",
"0.6049767",
"0.6004395",
"0.5973072",
"0.5972079",
"0.58010113",
"0.57962406",
"0.5764188",
"0.576268",
... | 0.81097823 | 0 |
Find a table's primary key and sequence. Note: Only primary key is implemented sequence will be nil. | def pk_and_sequence_for(table_name, owner = nil, desc_table_name = nil) # :nodoc:
(owner, desc_table_name) = @raw_connection.describe(table_name)
seqs = select_values_forcing_binds(<<~SQL.squish, "SCHEMA", [bind_string("owner", owner), bind_string("sequence_name", default_sequence_name(desc_table_name)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primary_key(table)\n pk_and_sequence = pk_and_sequence_for(table)\n pk_and_sequence && pk_and_sequence.first\n end",
"def primary_key(table_name)\n pk_and_sequence = pk_and_sequence_for(table_name)\n pk_and_sequence && pk_and_sequence.first\n end",
"def primary_key(tab... | [
"0.81927365",
"0.80941564",
"0.80453277",
"0.7847304",
"0.78139",
"0.7748976",
"0.7733234",
"0.76905924",
"0.7648475",
"0.75342923",
"0.7490126",
"0.72992945",
"0.71325094",
"0.7107546",
"0.7005971",
"0.6967267",
"0.6926679",
"0.6911465",
"0.6897764",
"0.6878343",
"0.6813935"... | 0.7238785 | 12 |
Returns just a table's primary key | def primary_key(table_name)
pk_and_sequence = pk_and_sequence_for(table_name)
pk_and_sequence && pk_and_sequence.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primary_key(table_name)\n 'id' # table.primary_key || 'id'\n end",
"def primary_key(table)\n pk_and_sequence = pk_and_sequence_for(table)\n pk_and_sequence && pk_and_sequence.first\n end",
"def primary_key table\n return nil unless table\n table = self[table]\n ... | [
"0.90114045",
"0.8753829",
"0.8671879",
"0.8558876",
"0.8389883",
"0.83551794",
"0.83482826",
"0.8327614",
"0.8327614",
"0.8213962",
"0.8206724",
"0.81152874",
"0.8111593",
"0.80744445",
"0.8056917",
"0.8031583",
"0.8022948",
"0.79978794",
"0.79882115",
"0.7960592",
"0.795947... | 0.8562554 | 3 |
create bind object for type String | def bind_string(name, value)
ActiveRecord::Relation::QueryAttribute.new(name, value, Type::OracleEnhanced::String.new)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_for_bind(string)\n string\n end",
"def get_binding(str)\n binding\nend",
"def bind_name(name, type)\n @names[name.to_sym] = type unless name.nil?\n end",
"def bind_string(stmt, index, value)\n case value.encoding\n when Encoding.utf_8, Encoding.us_ascii\n ... | [
"0.7958688",
"0.68606144",
"0.66457605",
"0.6537399",
"0.6498694",
"0.63422",
"0.6329408",
"0.624689",
"0.62252736",
"0.62181985",
"0.61617947",
"0.61021036",
"0.61020184",
"0.60863817",
"0.60765785",
"0.60765785",
"0.6008119",
"0.6008119",
"0.59187937",
"0.5905233",
"0.59031... | 0.7716862 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.