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 |
|---|---|---|---|---|---|---|
Overriding base get_children method | def get_children(name, options)
children = hash[name]
children = children.is_a?(Hash) ? children : {}
create_hash_children(children, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_children\n \t@children\n end",
"def children\n raise NotImplementedError\n end",
"def children()\r\n raise \"get_children is not implemented for class #{self.class}\"\r\n end",
"def get_children\n return children\n end",
"def get_children\n @children\n end",
"def _ch... | [
"0.80703837",
"0.80561835",
"0.8050966",
"0.7938353",
"0.79237163",
"0.78895766",
"0.786302",
"0.786302",
"0.786302",
"0.786302",
"0.786302",
"0.786302",
"0.786302",
"0.786302",
"0.786302",
"0.786302",
"0.786302",
"0.786302",
"0.7847895",
"0.77922976",
"0.77922976",
"0.7792... | 0.0 | -1 |
Display info on clojars.org | def jar(name)
"https://clojars.org/#{name}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def info\n puts \"Version #{StaticData::APPLICATION_VERSION}\"\n puts \"Authors : \"\n StaticData::AUTHORS.each do |author| \n puts \"-- #{author}\"\n end \n end",
"def info\n validate_arguments!\n\n remotes = self.class.heroku_remotes\n\n # trigger 'No app specified' message\n remo... | [
"0.61132526",
"0.5840545",
"0.5778802",
"0.5776638",
"0.57387865",
"0.5656757",
"0.56497526",
"0.5623626",
"0.55443424",
"0.5516257",
"0.5514159",
"0.5505672",
"0.550557",
"0.54829913",
"0.5482642",
"0.5476999",
"0.547484",
"0.54692024",
"0.54602623",
"0.54574805",
"0.5448733... | 0.61938226 | 0 |
Display core class API on clojure.org | def ccore(name)
"http://clojure.github.com/clojure/clojure.#{name}-api.html"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_class(*) end",
"def display_class_info\n end",
"def apis; end",
"def show_methods(klass)\n \t\tputs Object.const_get(klass).methods.inspect\n\tend",
"def print_module(*) end",
"def help(shell, *) # :nodoc:\n super\n shell.say class_usage if class_usage\n end",
"def ... | [
"0.6842484",
"0.6656891",
"0.6279162",
"0.62136513",
"0.61427397",
"0.605855",
"0.60207134",
"0.6014062",
"0.6014062",
"0.6001246",
"0.59884393",
"0.5988055",
"0.59514093",
"0.5931222",
"0.5915402",
"0.5915402",
"0.5915402",
"0.5915402",
"0.5915402",
"0.5915402",
"0.5915402",... | 0.67032856 | 1 |
Can't be exposed due to command pipe on all url methods Groups of keywords to search whisper | def whisper_groups
{
'console'=>%w{console commandline shell irb terminal ascii},
'tag'=>%w{tag tagging taggable triple semantic},
'tree'=>%w{tree hierarchy outline},
'sites'=>%w{delicious freebase}
# thor, table, cli, repl, menu
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keyword_filter\n @keyword = params[:keyword]\n @destination = params[:destination]\n @urls = Url\n .by_keyword(@keyword)\n .created_by_id(current_user.context_group_id)\n end",
"def rest_keywords; end",
"def medley_search\n\t\t@keywords = params[:keywords].downcase.gsub(/[^a... | [
"0.69207495",
"0.6785088",
"0.67537934",
"0.6297067",
"0.62265396",
"0.6201929",
"0.61986834",
"0.61345476",
"0.61291474",
"0.6086602",
"0.608416",
"0.6061258",
"0.60577947",
"0.60389584",
"0.60374194",
"0.6008256",
"0.5989752",
"0.5964564",
"0.59434754",
"0.59434754",
"0.594... | 0.0 | -1 |
Sometimes methods that make requests to the S3 servers return some object, like a Bucket or an S3Object. Other times they return just true. Other times they raise an exception that you may want to rescue. Despite all these possible outcomes, every method that makes a request stores its response object for you in Service.response. You can always get to the last request's response via Service.response. objects = Bucket.objects('jukebox') Service.response.success? => true This is also useful when an error exception is raised in the console which you weren't expecting. You can root around in the response to get more details of what might have gone wrong. | def response
@@response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def object_uploaded?(s3_client, bucket_name, object_key, object_content)\r\n response = s3_client.put_object(\r\n bucket: bucket_name,\r\n key: object_key,\r\n body: object_content\r\n )\r\n if response.etag\r\n return true\r\n else\r\n return false\r\n end\r\nrescue StandardError => e\r\n put... | [
"0.6764345",
"0.6583383",
"0.65297735",
"0.6487195",
"0.6471982",
"0.6436077",
"0.6320404",
"0.62747705",
"0.6226402",
"0.6204526",
"0.6080931",
"0.60600615",
"0.5982425",
"0.59439087",
"0.59435123",
"0.59341025",
"0.59340453",
"0.59340453",
"0.59233314",
"0.59038174",
"0.588... | 0.0 | -1 |
GET /lookup_eligibility_ineligibilities/1 GET /lookup_eligibility_ineligibilities/1.xml | def show
@lookup_eligibility_ineligibility = LookupEligibilityIneligibility.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @lookup_eligibility_ineligibility }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @lookup_eligibilityoutcome = LookupEligibilityoutcome.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lookup_eligibilityoutcome }\n end\n end",
"def new\n @lookup_eligibility_ineligibility = LookupEligibilityIneligibilit... | [
"0.6392338",
"0.6362595",
"0.6002524",
"0.58916885",
"0.5822437",
"0.57754135",
"0.57059014",
"0.5621023",
"0.56051093",
"0.5546659",
"0.5543629",
"0.55289334",
"0.546228",
"0.5402923",
"0.53803074",
"0.53752756",
"0.5352163",
"0.53315026",
"0.53274006",
"0.52758014",
"0.5250... | 0.69207436 | 0 |
GET /lookup_eligibility_ineligibilities/new GET /lookup_eligibility_ineligibilities/new.xml | def new
@lookup_eligibility_ineligibility = LookupEligibilityIneligibility.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @lookup_eligibility_ineligibility }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @lookup_eligibilityoutcome = LookupEligibilityoutcome.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_eligibilityoutcome }\n end\n end",
"def new\n @lookup_set = LookupSet.new\n\n respond_to do |format|\n format.html # ne... | [
"0.7224239",
"0.72209775",
"0.70087916",
"0.6976742",
"0.6939614",
"0.69052505",
"0.6897753",
"0.68671465",
"0.6809934",
"0.6596656",
"0.6563703",
"0.6464675",
"0.6459714",
"0.64543545",
"0.6370616",
"0.6324864",
"0.6303932",
"0.6283815",
"0.62787235",
"0.61964405",
"0.619056... | 0.78218657 | 0 |
POST /lookup_eligibility_ineligibilities POST /lookup_eligibility_ineligibilities.xml | def create
@lookup_eligibility_ineligibility = LookupEligibilityIneligibility.new(params[:lookup_eligibility_ineligibility])
respond_to do |format|
if @lookup_eligibility_ineligibility.save
format.html { redirect_to(@lookup_eligibility_ineligibility, :notice => 'Lookup eligibility ineligibility was successfully created.') }
format.xml { render :xml => @lookup_eligibility_ineligibility, :status => :created, :location => @lookup_eligibility_ineligibility }
else
format.html { render :action => "new" }
format.xml { render :xml => @lookup_eligibility_ineligibility.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @lookup_eligibility_ineligibility = LookupEligibilityIneligibility.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_eligibility_ineligibility }\n end\n end",
"def eligibility(params = {})\n scope 'default'\n post('eligibili... | [
"0.5992028",
"0.5523101",
"0.54198956",
"0.5363869",
"0.519859",
"0.51799333",
"0.5152001",
"0.5136144",
"0.49891588",
"0.49807364",
"0.49185723",
"0.48435837",
"0.477708",
"0.4758843",
"0.47562805",
"0.47528693",
"0.475041",
"0.47366437",
"0.46925402",
"0.46822396",
"0.46464... | 0.6408266 | 0 |
PUT /lookup_eligibility_ineligibilities/1 PUT /lookup_eligibility_ineligibilities/1.xml | def update
@lookup_eligibility_ineligibility = LookupEligibilityIneligibility.find(params[:id])
respond_to do |format|
if @lookup_eligibility_ineligibility.update(params[:lookup_eligibility_ineligibility], :without_protection => true)
format.html { redirect_to(@lookup_eligibility_ineligibility, :notice => 'Lookup eligibility ineligibility was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @lookup_eligibility_ineligibility.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @lookup_eligibility_ineligibility = LookupEligibilityIneligibility.new(params[:lookup_eligibility_ineligibility])\n\n respond_to do |format|\n if @lookup_eligibility_ineligibility.save\n format.html { redirect_to(@lookup_eligibility_ineligibility, :notice => 'Lookup eligibility ineli... | [
"0.6186291",
"0.594073",
"0.5933826",
"0.59102356",
"0.57666814",
"0.573326",
"0.57115847",
"0.56262136",
"0.5557955",
"0.55192715",
"0.5432965",
"0.5362481",
"0.52917033",
"0.52713567",
"0.52187544",
"0.51526266",
"0.5148219",
"0.50992733",
"0.507693",
"0.50732994",
"0.50656... | 0.67129457 | 0 |
DELETE /lookup_eligibility_ineligibilities/1 DELETE /lookup_eligibility_ineligibilities/1.xml | def destroy
@lookup_eligibility_ineligibility = LookupEligibilityIneligibility.find(params[:id])
@lookup_eligibility_ineligibility.destroy
respond_to do |format|
format.html { redirect_to(lookup_eligibility_ineligibilities_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @lookup_eligibilityoutcome = LookupEligibilityoutcome.find(params[:id])\n @lookup_eligibilityoutcome.destroy\n\n respond_to do |format|\n format.html { redirect_to(lookup_eligibilityoutcomes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lookup_set = Looku... | [
"0.65765995",
"0.6481214",
"0.6417105",
"0.62830967",
"0.61391574",
"0.61318344",
"0.6107299",
"0.60895014",
"0.6032937",
"0.5990204",
"0.59896886",
"0.59790224",
"0.5977954",
"0.59540987",
"0.59210175",
"0.5903438",
"0.58983684",
"0.5874011",
"0.585948",
"0.5852378",
"0.5831... | 0.7323578 | 0 |
Return a map of defined fields | def fields
@fields ||= {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fields\n iterator = @form_fields.keySet.iterator\n map = {}\n while iterator.hasNext\n key = iterator.next.toString\n map[key.to_sym] = field(key)\n end\n map\n end",
"def fieldmap\n { \n 'MEMBERID' => 'id',\n 'EMAIL' => 'email',\n 'FNAME' =... | [
"0.78328586",
"0.7813289",
"0.759849",
"0.7477004",
"0.7473637",
"0.7329268",
"0.72925436",
"0.7224674",
"0.72234136",
"0.72069037",
"0.7138236",
"0.7138236",
"0.7018082",
"0.70114",
"0.6994684",
"0.699104",
"0.6954256",
"0.6932013",
"0.6932013",
"0.6932013",
"0.68958986",
... | 0.7653236 | 6 |
helper method for signup validation | def validate_signup(username, password, verify, email, errors)
errors[:username_error] = ''
errors[:password_error] = ''
errors[:verify_error] = ''
errors[:email_error] = ''
unless USER.match(username)
errors[:username_error] = 'invalid username. try just letters and numbers'
return false
end
unless PASS.match(password)
errors[:password_error] = 'invalid password.'
return false
end
if password != verify
errors[:verify_error] = 'password must match'
false
end
unless email.empty?
unless EMAIL.match(email)
errors[:email_error] = 'invalid email address'
return false
end
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attemp_signup\n\n end",
"def signup\n end",
"def signup\n end",
"def validate_signup(posted)\n errors = validate_required(posted, ['email'])\n email = posted['email']\n\n errors['email'] ||= error_for_email(dealer_dao, email)\n if / is already taken.\\Z/.match(errors['email... | [
"0.7691027",
"0.7650405",
"0.7650405",
"0.7375168",
"0.72886586",
"0.72365063",
"0.71356374",
"0.7091927",
"0.7084913",
"0.68694085",
"0.6855722",
"0.68494093",
"0.6802448",
"0.67960393",
"0.6776432",
"0.6773565",
"0.6755271",
"0.6746291",
"0.67056566",
"0.67028975",
"0.67002... | 0.6890174 | 9 |
hen returns the square of the sum. | def squared_sum(a, b)
# Q1 CODE HERE
return (a + b) ** 2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def square_of_sum\n\t\t@n**2*(@n+1)**2/4\n\tend",
"def square_of_sum\n end",
"def square_of_sum\n\tsquare_of = 0\n\n\t(1..100).each do |x|\n\t\tsquare_of += x\n\tend\n\tsquare_of = square_of**2\n\tsquare_of\nend",
"def square_of_sums\n return (@n * (@n + 1) / 2)**2\n end",
"def square_sum\n self.in... | [
"0.6458575",
"0.63287705",
"0.63121617",
"0.61242473",
"0.6078263",
"0.60502124",
"0.6044223",
"0.6008219",
"0.5978219",
"0.59639055",
"0.5924363",
"0.5866442",
"0.58387625",
"0.5825597",
"0.5825188",
"0.57771075",
"0.5746637",
"0.57293683",
"0.57133216",
"0.56885695",
"0.567... | 0.53299594 | 63 |
takes in an array of integers, sorts it, then increments every element by 1, and returns it | def sort_array_plus_one(a)
# Q2 CODE HERE
return a.each_index { |i| a[i] += 1}.sort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(array)\n result = Array.new(array.length, 0)\n\n array.each do |element|\n if result[element - 1]\n result[element - 1] += 1\n else\n result[element - 1] = 1\n end\n end\n\n result.uniq.size == 1 ? 1 : 0\nend",
"def sort_array_plus_one(array)\r\n\r\n\tarray.sort! {|x, y| x <=>... | [
"0.716102",
"0.7158489",
"0.7153316",
"0.6939943",
"0.68487835",
"0.6815756",
"0.6737138",
"0.6631303",
"0.65925354",
"0.65911543",
"0.6570582",
"0.65559715",
"0.6550725",
"0.65420485",
"0.6525719",
"0.645711",
"0.6451028",
"0.6444648",
"0.63888675",
"0.63857",
"0.63719934",
... | 0.75590134 | 0 |
takes in two strings, a first_name and last_name. It will return the first_name concatenated with the last_name, along with a space in between. | def combine_name(first_name, last_name)
# Q3 CODE HERE
return "#{first_name} #{last_name}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concat_name(first_name, last_name)\n\treturn \"#{last_name}, #{first_name}\"\nend",
"def full_name \n [first_name, last_name].join(' ')\n end",
"def full_name\n [first_name, last_name].join(' ').strip\n end",
"def full_name\n [first_name, last_name].join(\" \")\n end",
"def full_name\... | [
"0.8513865",
"0.8478131",
"0.8475223",
"0.84679693",
"0.84679693",
"0.84679693",
"0.84679693",
"0.84679693",
"0.84679693",
"0.8464803",
"0.84605855",
"0.84500635",
"0.84500635",
"0.84500635",
"0.84500635",
"0.84500635",
"0.8433795",
"0.8340965",
"0.83035195",
"0.8296428",
"0.... | 0.0 | -1 |
Expresiones Regulares Martes 7 de Junio 2016 | def find_account(string)
true if string.match /\d{4}-\d{3}-\d{3}/
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def re; end",
"def matematica_especial\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 33 )\n\n\n return_value = MatematicaEspecialReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n ... | [
"0.562506",
"0.5569295",
"0.55087507",
"0.53345597",
"0.5286127",
"0.5265933",
"0.51704836",
"0.5137873",
"0.51244587",
"0.50674766",
"0.5066242",
"0.5064156",
"0.5060712",
"0.5059975",
"0.5057123",
"0.5057123",
"0.5057123",
"0.50364596",
"0.50215876",
"0.4997799",
"0.4992717... | 0.0 | -1 |
redefine your position_taken? method here, so that you can use it in the valid_move? method above. | def position_taken?(array,index)
if array[index] == " " || array[index] == "" || array[index] == nil then
return false
elsif array[index] == "X" || array[index] == "O" then
return true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position_taken?(board, position)\n return false if valid_move?(board, position)\n return true unless valid_move?(board, position)\nend",
"def position_taken?\nend",
"def valid_move?(board, index)\n if index.between?(0, 8)\n # re-define your #position_taken? method here, so that you can use it in the #v... | [
"0.8409533",
"0.8161412",
"0.80915326",
"0.802741",
"0.80150443",
"0.78980684",
"0.7893883",
"0.7886275",
"0.78447807",
"0.7843449",
"0.7831682",
"0.78148174",
"0.7813732",
"0.7810363",
"0.78020334",
"0.7801113",
"0.7800951",
"0.7789361",
"0.7782831",
"0.777421",
"0.7774137",... | 0.0 | -1 |
I worked on this challenge by myself. Your Solution Below | def good_guess?(i)
if i == 42
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution4(input)\n end",
"def challenge; end",
"def solution(s, p, q)\r\n # write your code in Ruby 2.2\r\n # A -1\r\n # C -2\r\n # G -3\r\n # T -4\r\n # s - string with n charactekrs\r\n #cagccta\r\n #0123345\r\n #p,q - not empty arrays\r\n #\r\n #p[0]=2 q[0]=4 gcc 322 ... | [
"0.66699874",
"0.65802413",
"0.6146916",
"0.6141384",
"0.60677093",
"0.6048339",
"0.6008928",
"0.5924959",
"0.5917534",
"0.5897405",
"0.5886607",
"0.5859519",
"0.58535683",
"0.5827131",
"0.58258575",
"0.5825749",
"0.5824339",
"0.57750577",
"0.5770655",
"0.57650816",
"0.576445... | 0.0 | -1 |
click on link in a column by text on another column of the same row | def click_by_text_in_row(link_column, target_column, text)
(0...rows_number).each do |row_number|
return link(row_number, link_column).click if cell_text(row_number, target_column) == text
end
raise Capybara::ElementNotFound.new("Cell with provided text '#{text}' was not found")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def click_table_cell_by_text(tableId, columnNum, text)\n self.class.elements(:tableRows, \"#{'#' + tableId + ' tbody tr td:nth-of-type(' + columnNum.to_s + ')'}\")\n tableRows.each do |record|\n if record.text.upcase.include? text.upcase\n record.click\n break\n end\n end\n end",
... | [
"0.6716506",
"0.65883887",
"0.65567714",
"0.6317962",
"0.626402",
"0.6237579",
"0.62306386",
"0.6220083",
"0.620891",
"0.61969495",
"0.6102632",
"0.59873134",
"0.5985399",
"0.5979699",
"0.595483",
"0.59501034",
"0.5947952",
"0.5947952",
"0.58710873",
"0.5847772",
"0.57697266"... | 0.779351 | 0 |
indicating whether or not the state at the given path is current, replica of statechart.jsisCurrent | def current?(path = '.')
# check if {path} is resolvable from {thisState}
state = resolve(path)
!!state && state.__is_current__?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current?\n @node.current_path == path\n end",
"def current_path?(path)\n @ctx.path_with_slashes(@ctx.current_path) == @ctx.path_with_slashes(path)\n end",
"def in_state?(path)\n self.find_states(current_state.path).include? find_state(path)\n end",
"def is_active?(path)\n \tp... | [
"0.764556",
"0.70843726",
"0.69846594",
"0.6607892",
"0.65770423",
"0.65333956",
"0.65015364",
"0.6396947",
"0.6354102",
"0.6331657",
"0.6273729",
"0.62729245",
"0.6268846",
"0.6268846",
"0.6261532",
"0.62481254",
"0.6239457",
"0.61124057",
"0.6075466",
"0.6075466",
"0.605506... | 0.755199 | 1 |
Returns an array of paths to all current leaf states. replica of statechart.jscurrent | def all_active_paths
all_active_states.map(&:path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path_states\n @__cache__[:path] ||= @superstate ? [*@superstate.path_states, self] : [self] # recursion\n end",
"def all_active_states\n return [] unless __is_current__?\n return [self] if @substates.empty?\n\n @substates.reduce([]) do |arr, substate|\n arr.concat(substate.all_active_states... | [
"0.67504483",
"0.63467056",
"0.6272641",
"0.6237663",
"0.608601",
"0.5984849",
"0.5983336",
"0.5982493",
"0.59687835",
"0.5932218",
"0.5868056",
"0.58536065",
"0.5779925",
"0.57343876",
"0.57188547",
"0.57117903",
"0.5709347",
"0.5676379",
"0.56603",
"0.5641506",
"0.56331",
... | 0.73958105 | 0 |
Returns an array of all current leaf states, replica of statechart.js_current | def all_active_states
return [] unless __is_current__?
return [self] if @substates.empty?
@substates.reduce([]) do |arr, substate|
arr.concat(substate.all_active_states) if substate.__is_current__? # concat mutates ;)
arr
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def known_states\n branch.known_states\n end",
"def states\n @finity.states.map { |name, _| name }\n end",
"def states\n []\n end",
"def states\n []\n end",
"def graph_states\n self.graph.states\n end",
"def states; @_hegemon_states.keys; end",
"def state... | [
"0.69095683",
"0.68901783",
"0.68546224",
"0.68546224",
"0.68196034",
"0.66901064",
"0.66890776",
"0.6455533",
"0.6346789",
"0.6324241",
"0.6306311",
"0.62243193",
"0.62243193",
"0.62243193",
"0.6210569",
"0.62033767",
"0.62030065",
"0.6196925",
"0.6188841",
"0.6164448",
"0.6... | 0.741528 | 0 |
Resolves a string path into an actual `State` object, paths not starting with a '/' are resolved relative to the receiver state Returns if resolvable or 'nil' | def resolve(path)
return nil if !path
head, *path = path.class == String ? path.split('/') : path
next_piece = case head
when ''
self.root
when '.'
self
when '..'
self.superstate
else
substate_map[head.to_sym]
end
return nil if !next_piece
# recursively call the next states.resolve method with remaining `path<Array>` until becomes [], then return the last path
path.size === 0 ? next_piece : next_piece.resolve(path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_path(path); end",
"def current?(path = '.') \n # check if {path} is resolvable from {thisState}\n state = resolve(path)\n !!state && state.__is_current__?\n end",
"def transition_to(path, current_state=self.current_state)\n path = path.to_s\n state = current_state || self\n e... | [
"0.6952059",
"0.6196722",
"0.61504847",
"0.58851457",
"0.573641",
"0.57331425",
"0.5716962",
"0.5651046",
"0.5640092",
"0.56321806",
"0.5586801",
"0.5586801",
"0.5545987",
"0.5513155",
"0.54465306",
"0.54415435",
"0.5413735",
"0.5367446",
"0.53120667",
"0.52984804",
"0.529210... | 0.7423091 | 0 |
Returns: a string containing the full path from the root state the receiver state | def path
'/' + path_states.map(&:name)[1..-1].join('/')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path\n real_path = Pathname.new(root).realpath.to_s\n full_path.sub(%r{^#{real_path}/}, '')\n end",
"def getRoot\n @path[0]\n end",
"def root_path\n attributes.fetch(:rootPath)\n end",
"def full_defined_path()\n return nil if is_root?\n return ... | [
"0.69684416",
"0.6860809",
"0.68346965",
"0.6829917",
"0.66148967",
"0.66133165",
"0.6584625",
"0.6567868",
"0.6539801",
"0.65279204",
"0.65270686",
"0.64998394",
"0.64975363",
"0.6495314",
"0.64935803",
"0.6493509",
"0.6466854",
"0.64564914",
"0.6453605",
"0.6436328",
"0.643... | 0.73932385 | 0 |
Internal: Calculates and caches the path from the root state to the receiver state. Subsequent calls will return the cached path array. Returns an array of `State` objects. NOTE: replica of statechart.js's `_path`, NOTE: private | def path_states
@__cache__[:path] ||= @superstate ? [*@superstate.path_states, self] : [self] # recursion
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_active_paths\n all_active_states.map(&:path)\n end",
"def paths\n trail.paths.dup\n end",
"def paths\n @trail.paths.dup\n end",
"def get_paths_visited\n redis.smembers paths_visited_key\n end",
"def path_arr()\n return @paths\n end",
"def paths\n @paths ||= []\n... | [
"0.7062133",
"0.6486537",
"0.63977695",
"0.63220024",
"0.63203555",
"0.62293994",
"0.62293994",
"0.62240636",
"0.61668766",
"0.61650735",
"0.61644804",
"0.61572427",
"0.6153095",
"0.61462164",
"0.61180025",
"0.60136896",
"0.5986399",
"0.59740514",
"0.5965246",
"0.59284055",
"... | 0.80255246 | 0 |
Sets up a transition from the receiver state tot he given destination. all paths must be resolvable | def goto(*paths_and_opts)
if paths_and_opts.last.class == Hash
*paths, opts = paths_and_opts
else
paths, opts = paths_and_opts, {}
end
# loop through `paths` called from goto to get states
destination_states = paths.map do |p|
state = resolve(p)
state ? state : raise(CannotResolveError, "State#goto could not resolve path #{p} from #{self}")
end
# loop through all states added, find pivots of current state(preferably root? though not always) and target state
pivots = destination_states.map { |state| find_pivot(state) }
# there should only be 1 uniq state in [pivots]
if uniq_states(pivots).size > 1
raise MultiplePivotError, "StateNode#goto: multiple pivot states found between state #{self} and paths #{paths.join(', ')}"
end
pivot = pivots[0] || self
if pivot.can_exit?(destination_states, opts) === false
trace_state("State: [GOTO] : #{self} cannot exit")
return false
end
trace_state("State: [GOTO] : #{self} -> [#{destination_states.join(', ')}]")
# current state isn't active
if (!__is_current__? && @superstate)
raise InactiveStateError, "StateNode#goto: state #{self} is not current"
end
# if the pivot state is concurrent state and is NOT the current state (starting state), then we are attempting to cross a concurrency boundary.
if (pivot.concurrent? && pivot != self)
raise PivotingOnConcurrentStateError, "StateNode#goto: one or more of the given paths are not reachable from state #{self}: #{paths.join(', ')}"
end
# push transition to a queue `root.__transitions__`
root.queue_transition(pivot, destination_states, opts)
# flushes out all transitions queued up in `root.__transitions__`
root.transition unless self.__is_sending__?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transition_to(path, current_state=self.current_state)\n path = path.to_s\n state = current_state || self\n exit_states = []\n\n # Find the nearest parent state on the path of the current state which\n # has a sub-state at the given path\n new_states = state.find_states(path)\n ... | [
"0.61247617",
"0.610471",
"0.5931626",
"0.58610535",
"0.57902473",
"0.56667143",
"0.56667143",
"0.56667143",
"0.56559014",
"0.5655685",
"0.56455934",
"0.56455934",
"0.56402296",
"0.56402296",
"0.56402296",
"0.56321454",
"0.5615786",
"0.56139356",
"0.5612345",
"0.56034327",
"0... | 0.5463668 | 27 |
Performs all queued transitions. This is the method that actually takes the statechart from one set of current states to another, the actual change. NOTE: private | def transition
return nil unless @__transitions__ && @__transitions__.any?
@__transitions__.each do |trans|
(_, pivot), (_, states), (_, opts) = *trans
pivot.enter(states, opts)
end
@__transitions__ = []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_transitions\n from_states.each do |from|\n if (value = machine.transitions[name][from])\n machine.transitions[name][from] = [value, map[from]].flatten\n else\n machine.transitions[name][from] = map[from] || ANY_STATE\n end\n end\n end",
"def perform_... | [
"0.6886959",
"0.6363991",
"0.6234435",
"0.62176234",
"0.6186846",
"0.61618054",
"0.598081",
"0.5976518",
"0.59069425",
"0.5883039",
"0.58577216",
"0.57929933",
"0.57848984",
"0.5720151",
"0.57175356",
"0.56819546",
"0.56767356",
"0.56602454",
"0.5616116",
"0.55982506",
"0.557... | 0.55304897 | 24 |
Loop from 0 to min(p1.length, p2.length) (which is like the depth), find common paths from the root of the two path and terminate loop when mismatch occurs NOTE: private, part of goto, | def find_pivot(other)
p = nil
p1, p2 = self.path_states, other.path_states
depth_to_traverse = [p1.size, p2.size].min
for i in 0...depth_to_traverse do
if p1[i] == p2[i]
# keep going down the depth and set the new p as long as hierarchy is overlapping
p = p1[i]
else break
end
end
raise PivotingToDifferentStatechartError, "StateNode#find_pivot: states #{self} and #{other} do not belong to the same statechart" unless p
p
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def common_ancestor(node1, node2)\n depth1 = find_depth(node1)\n depth2 = find_depth(node2)\n\n if(depth1 >= depth2)\n long_depth = depth1\n short_depth = depth2\n long_node = node1\n short_node = node2\n else\n long_depth = depth2\n short_depth = depth1\n long_node = node2\n short_node... | [
"0.6363481",
"0.6101695",
"0.60607934",
"0.60562027",
"0.60124886",
"0.6004523",
"0.5864281",
"0.58456504",
"0.58186436",
"0.5759182",
"0.5749955",
"0.57463926",
"0.57391346",
"0.5710405",
"0.570921",
"0.5697324",
"0.56279135",
"0.5621424",
"0.55966544",
"0.55964595",
"0.5579... | 0.51584756 | 49 |
recursively find the root of this state by looking up superstateroot | def root
@__cache__[:root] ||= @superstate ? @superstate.root : self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root_level\n self.find\n end",
"def effective_root\n if empty? and children.size == 1\n children.first.effective_root\n else\n self\n end\n end",
"def get_root\n return self if tag == :root || parent.nil?\n parent.get_root\n end",
"def root\n n = self\n ... | [
"0.6518734",
"0.64218247",
"0.62022555",
"0.61491907",
"0.6108575",
"0.6079043",
"0.6017494",
"0.60052353",
"0.5928513",
"0.5910071",
"0.58953846",
"0.58838147",
"0.58656764",
"0.5845784",
"0.5834539",
"0.5807257",
"0.58002687",
"0.57870746",
"0.5771323",
"0.5766869",
"0.5736... | 0.67405653 | 0 |
conditional state, used for consulting when entered a clustered state to determine destination states`` | def C(&callback)
raise ConcurrentStateCannotHaveConditionError, "StateNode#C: a concurrent state may not have a condition state: #{self}" if concurrent?
@__condition__[:method] = callback
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_state_predicate; end",
"def reachable?; @state[\"reachable\"]; end",
"def get_state\n return self.state == 't' || self.state == true\n end",
"def extended_state\n\t if self.state == 'complete'\n \t if !self.accepted_at\n \t 'submitted'\n elsif self.accepted_at && (self.packed_at ==... | [
"0.70388734",
"0.6792312",
"0.6592066",
"0.62988657",
"0.629797",
"0.6259765",
"0.61461973",
"0.6136336",
"0.6136336",
"0.6136336",
"0.6136336",
"0.6136336",
"0.6136336",
"0.6136336",
"0.6136336",
"0.61118984",
"0.6100298",
"0.60683686",
"0.6027499",
"0.6027499",
"0.6027499",... | 0.0 | -1 |
come up with a different name for this, main_root? | def is_root?() @name === '__root__'; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name\n @root\n end",
"def application_root=(_arg0); end",
"def name\n @root_name\n end",
"def global; return root end",
"def root_dir=(_arg0); end",
"def root; end",
"def root; end",
"def root; end",
"def root; end",
"def root; end",
"def root; end",
"def root; end",
"de... | [
"0.75077826",
"0.7493479",
"0.7300559",
"0.724696",
"0.71924245",
"0.7047291",
"0.7047291",
"0.7047291",
"0.7047291",
"0.7047291",
"0.7047291",
"0.7047291",
"0.7047291",
"0.7047291",
"0.7047291",
"0.7047291",
"0.7047291",
"0.7047291",
"0.7047291",
"0.7047291",
"0.69490075",
... | 0.6980537 | 20 |
Invoked by `add_state`, currently only used by 'RoutableSTate' substate and should not be invoked by user | def did_attach() end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enter_state\n end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state\n end",
"def states; end",
"def after_state(state)\n end",
"def extra_state; end",
"def on_state_timeup(s... | [
"0.74351287",
"0.7181184",
"0.7181184",
"0.7181184",
"0.7181184",
"0.7181184",
"0.7181184",
"0.7181184",
"0.7181184",
"0.7068317",
"0.6832848",
"0.67783695",
"0.67558765",
"0.67216307",
"0.6637997",
"0.66072345",
"0.6588212",
"0.6588212",
"0.6588212",
"0.65441805",
"0.6504382... | 0.0 | -1 |
GET /paciente_reporte_rayos_xes GET /paciente_reporte_rayos_xes.json | def index
@paciente_reporte_rayos_xes = PacienteReporteRayosX.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_paciente_reporte_rayos_x\n @paciente_reporte_rayos_x = PacienteReporteRayosX.find(params[:id])\n end",
"def index\n @paciente_reporte_emergencia = PacienteReporteEmergencium.all\n end",
"def report\n @employees=Employee.all\n @routing_sheets=RoutingSheet.find(:all, :conditions=> \"routing... | [
"0.6430805",
"0.6263325",
"0.61529624",
"0.610506",
"0.6100106",
"0.60598713",
"0.604345",
"0.5948078",
"0.5862733",
"0.58599204",
"0.5845413",
"0.5838481",
"0.581266",
"0.5803088",
"0.5802839",
"0.5780189",
"0.5779125",
"0.57708776",
"0.57598925",
"0.5757677",
"0.5756085",
... | 0.7689339 | 0 |
GET /paciente_reporte_rayos_xes/1 GET /paciente_reporte_rayos_xes/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @paciente_reporte_rayos_xes = PacienteReporteRayosX.all\n end",
"def set_paciente_reporte_rayos_x\n @paciente_reporte_rayos_x = PacienteReporteRayosX.find(params[:id])\n end",
"def report\n @employees=Employee.all\n @routing_sheets=RoutingSheet.find(:all, :conditions=> \"routing_sheet... | [
"0.76042503",
"0.660566",
"0.627393",
"0.62371975",
"0.6111825",
"0.6080796",
"0.60706395",
"0.6005113",
"0.5973781",
"0.5915556",
"0.5871207",
"0.5867081",
"0.58440167",
"0.58169186",
"0.581179",
"0.5803793",
"0.57909036",
"0.57767266",
"0.5770588",
"0.57602626",
"0.57451373... | 0.0 | -1 |
POST /paciente_reporte_rayos_xes POST /paciente_reporte_rayos_xes.json | def create
@paciente_reporte_rayos_x = PacienteReporteRayosX.new(paciente_reporte_rayos_x_params)
@parte_rayos_x = ParteRayosX.find(params[:parte_rayos_x_id])
if @paciente_reporte_rayos_x.save
flash[:success] = "Paciente agregado exitosamente."
redirect_to "/parte_rayos_xes/"+@paciente_reporte_rayos_x.parte_rayos_x.id.to_s
else
flash[:danger] = "Error al agregar paciente"
redirect_to parte_rayos_x_path(@parte_rayos_x)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @paciente_reporte_rayos_xes = PacienteReporteRayosX.all\n end",
"def set_paciente_reporte_rayos_x\n @paciente_reporte_rayos_x = PacienteReporteRayosX.find(params[:id])\n end",
"def paciente_reporte_rayos_x_params\n params.require(:paciente_reporte_rayos_x).permit(:paciente_id, :parte_ray... | [
"0.7020163",
"0.6576096",
"0.6510586",
"0.578165",
"0.56335485",
"0.5591039",
"0.5494591",
"0.5427173",
"0.5394603",
"0.5338214",
"0.52980274",
"0.5272317",
"0.5252992",
"0.52459437",
"0.52184844",
"0.51605856",
"0.5159068",
"0.51460207",
"0.5120532",
"0.5083943",
"0.5080927"... | 0.63917714 | 3 |
PATCH/PUT /paciente_reporte_rayos_xes/1 PATCH/PUT /paciente_reporte_rayos_xes/1.json | def update
respond_to do |format|
if @paciente_reporte_rayos_x.update(paciente_reporte_rayos_x_params)
format.html {redirect_to @paciente_reporte_rayos_x, notice: 'Paciente reporte rayos x was successfully updated.'}
format.json {render :show, status: :ok, location: @paciente_reporte_rayos_x}
else
format.html {render :edit}
format.json {render json: @paciente_reporte_rayos_x.errors, status: :unprocessable_entity}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n respond_to do |format|\n if @reporte_detalle.update(... | [
"0.604622",
"0.60382116",
"0.6031984",
"0.6031108",
"0.59846884",
"0.5948373",
"0.59409237",
"0.5904332",
"0.58884406",
"0.5872377",
"0.58533937",
"0.5836528",
"0.58240783",
"0.5822332",
"0.5821302",
"0.5809282",
"0.5786042",
"0.5762916",
"0.5753514",
"0.5752342",
"0.57330334... | 0.72800946 | 0 |
DELETE /paciente_reporte_rayos_xes/1 DELETE /paciente_reporte_rayos_xes/1.json | def destroy
@paciente_reporte_rayos_x.destroy
respond_to do |format|
format.html {redirect_to paciente_reporte_rayos_xes_url, notice: 'Paciente reporte rayos x was successfully destroyed.'}
format.json {head :no_content}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @reporte_detalle.destroy\n respond_to do |format|\n format.html { redirect_to reporte_detalles_url, notice: 'Reporte detalle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @detalle_documento_de_compra.destroy\n respond_to do ... | [
"0.7038215",
"0.6975192",
"0.69639516",
"0.68752027",
"0.6869179",
"0.68417656",
"0.6803437",
"0.67955726",
"0.6780791",
"0.67799807",
"0.6756023",
"0.6739751",
"0.6724167",
"0.6724135",
"0.6720553",
"0.6713167",
"0.66907084",
"0.6690362",
"0.6689989",
"0.6688141",
"0.6671674... | 0.77500284 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_paciente_reporte_rayos_x
@paciente_reporte_rayos_x = PacienteReporteRayosX.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 paciente_reporte_rayos_x_params
params.require(:paciente_reporte_rayos_x).permit(:paciente_id, :parte_rayos_x_id, :fecha_consulta, :estudios, :ceh, :ta, :edad, :hc, :uno, :dos, :tres, :cuatro, :cinco, :observaciones)
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.6981606",
"0.6784227",
"0.6746523",
"0.67439264",
"0.67361516",
"0.6593381",
"0.6506166",
"0.64994407",
"0.6483518",
"0.64797056",
"0.64578557",
"0.6441216",
"0.63811713",
"0.63773805",
"0.6366333",
"0.63217646",
"0.6301816",
"0.63009787",
"0.6294436",
"0.62940663",
"0.629... | 0.0 | -1 |
PATCH/PUT /buyers/1 PATCH/PUT /buyers/1.json | def update
authorize @buyer
respond_to do |format|
if @buyer.update(buyer_params)
format.html { redirect_to store_index_url, notice: "The profile of the buyer #{@buyer.name} was successfully updated." }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @buyer.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @supermarket = Supermarket.find(params[:id]) \n respond_to do |format|\n if @supermarket.update(supermarket_params)\n format.json { render json: @supermarket, status: :ok }\n end\n end\n end",
"def update\n @buyer = Buyer.find(params[:id])\n\n respond_to do |format|... | [
"0.6778113",
"0.660911",
"0.6374318",
"0.6343765",
"0.6320981",
"0.6268602",
"0.6188752",
"0.6182549",
"0.6177518",
"0.6163438",
"0.61240405",
"0.6121388",
"0.609138",
"0.6019575",
"0.60083055",
"0.6001091",
"0.59965324",
"0.5986897",
"0.5986897",
"0.5975178",
"0.596417",
"... | 0.5983901 | 19 |
Use callbacks to share common setup or constraints between actions. | def set_buyer
@buyer = Buyer.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 buyer_params
params.require(:buyer).permit(:name, :address, :pay_type)
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 |
Enable db doc support. Assume that all the directories in up/down will have documentation and will generate relative to specified directory. | def enable_db_doc(target_directory)
task "#{task_prefix}:db_doc"
task "#{task_prefix}:pre_build" => ["#{task_prefix}:db_doc"]
(up_dirs + down_dirs).each do |relative_dir_name|
dirs_for_database(relative_dir_name).each do |dir|
task "#{task_prefix}:db_doc" => Dbt::DbDoc.define_doc_tasks(dir, "#{target_directory}/#{relative_dir_name}")
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable_db_doc(target_directory)\n task \"#{task_prefix}:db_doc\"\n task \"#{task_prefix}:pre_build\" => [\"#{task_prefix}:db_doc\"]\n\n (up_dirs + down_dirs).each do |relative_dir_name|\n dirs_for_database(relative_dir_name).each do |dir|\n task \"#{task_prefix}:db_doc\" => DbTas... | [
"0.8082018",
"0.63982993",
"0.61065114",
"0.61065114",
"0.6040331",
"0.59088266",
"0.58383006",
"0.5743116",
"0.5733773",
"0.5733237",
"0.5731032",
"0.57141006",
"0.56790346",
"0.5670435",
"0.56439495",
"0.56335855",
"0.56190217",
"0.5611029",
"0.5602273",
"0.5592684",
"0.559... | 0.8074049 | 1 |
Watches a page you specify at the current | def bot_watch(event, url, css)
event.respond 'okay! i will watch it..'
@url = url
@css = css
@id = event.message.author.id
quit_thread(event) unless @thread.nil?
make_watcher(event)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def watch(site, options); end",
"def watch\n\nend",
"def watch\n start_watch\n end",
"def watch!\n start_watch true\n end",
"def visit_page \n visit URL \n end",
"def watch_site(config_options)\n Bridgetown::Watcher.watch(@site, config_options)\n end",
"def u... | [
"0.6334627",
"0.6037808",
"0.60265344",
"0.5843886",
"0.5749172",
"0.5713361",
"0.56577575",
"0.5657422",
"0.5639842",
"0.55906653",
"0.5590492",
"0.55480856",
"0.55286145",
"0.5518414",
"0.5509301",
"0.5509301",
"0.5502789",
"0.5491805",
"0.54843396",
"0.5464544",
"0.5421687... | 0.6068851 | 1 |
Gets a text version of the diff between two strings | def diffed(old, new)
differ = Differ.diff_by_line(new, old)
differ.to_s[/\{[^}]+\}/][1...-1].gsub(/\s{2,}/, '')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diff_string(string1, string2); end",
"def diff_strings(a, b)\n require 'tempfile'\n require 'open3'\n\n # Create files\n Tempfile.open('old') do |old_file|\n Tempfile.open('new') do |new_file|\n # Write files\n old_file.write(a)\n old_file.flush\n ... | [
"0.7728201",
"0.74217856",
"0.71186507",
"0.70624536",
"0.68760157",
"0.678782",
"0.677613",
"0.64227253",
"0.6395935",
"0.6352099",
"0.63116944",
"0.63041323",
"0.6093596",
"0.60264504",
"0.6011963",
"0.59977853",
"0.59339666",
"0.58713907",
"0.5844936",
"0.5793171",
"0.5780... | 0.7117574 | 3 |
Stops watching a page if there is one | def bot_stop_watching(event)
if @thread.nil?
event.respond 'but i not watch thing rigth now???'
else
event.respond "i stop watc #{@url} at #{@css}"
@thread.exit
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop\n @keep_watching = false\n update_spinner('Stopping')\n nil\n end",
"def stop_watching\n @thread.kill\n end",
"def stop\n command(\"Page.stopLoading\", slowmoable: true)\n end",
"def stop\n @stopped = true\n end",
"def stop_listening\n @continue_listening = fa... | [
"0.6626773",
"0.65400887",
"0.64896744",
"0.6458154",
"0.64548546",
"0.64397085",
"0.6408303",
"0.6370208",
"0.6370208",
"0.6370208",
"0.63411456",
"0.63411456",
"0.63220197",
"0.63220197",
"0.63220197",
"0.63220197",
"0.6300671",
"0.62960136",
"0.62960136",
"0.62960136",
"0.... | 0.6630794 | 0 |
methods cycle method: go through an array and cycle back if >= array.length | def cycle(array, step, value)
oldIndex = array.index(value)
newIndex = (oldIndex + step) % array.length
return newIndex # return index not value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cycle arr\n while true\n arr.each do |elem|\n yield elem\n end\n end\nend",
"def single_cycle_check(array)\n numElementsVisited = 0\n currentIdx = 0\n while numElementsVisited < array.length\n if numElementsVisited > 0 & currentIdx == 0\n return false\n end\n numElementsVisited ... | [
"0.7139466",
"0.65579873",
"0.64060456",
"0.6372008",
"0.63525605",
"0.62596494",
"0.6139243",
"0.6119654",
"0.6105933",
"0.60965306",
"0.60911477",
"0.6090645",
"0.6086208",
"0.60787106",
"0.6068679",
"0.6049112",
"0.6036823",
"0.6027638",
"0.60076797",
"0.5991809",
"0.59851... | 0.6572769 | 1 |
Returns constant of subscription adapter specified in config/cable.yml. If the adapter cannot be found, this will default to the Redis adapter. Also makes sure proper dependencies are required. | def pubsub_adapter
adapter = (cable.fetch("adapter") { "redis" })
# Require the adapter itself and give useful feedback about
# 1. Missing adapter gems and
# 2. Adapter gems' missing dependencies.
path_to_adapter = "action_cable/subscription_adapter/#{adapter}"
begin
require path_to_adapter
rescue LoadError => e
# We couldn't require the adapter itself. Raise an exception that
# points out config typos and missing gems.
if e.path == path_to_adapter
# We can assume that a non-builtin adapter was specified, so it's
# either misspelled or missing from Gemfile.
raise e.class, "Could not load the '#{adapter}' Action Cable pubsub adapter. Ensure that the adapter is spelled correctly in config/cable.yml and that you've added the necessary adapter gem to your Gemfile.", e.backtrace
# Bubbled up from the adapter require. Prefix the exception message
# with some guidance about how to address it and reraise.
else
raise e.class, "Error loading the '#{adapter}' Action Cable pubsub adapter. Missing a gem it depends on? #{e.message}", e.backtrace
end
end
adapter = adapter.camelize
adapter = "PostgreSQL" if adapter == "Postgresql"
"ActionCable::SubscriptionAdapter::#{adapter}".constantize
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adapter\n a = cache_conn_instance.get(cache_name)\n if adapter_supported?(a.class)\n return a\n else\n raise Cachetastic::Errors::UnsupportedAdapter.new(cache_name, a.class)\n end\n end",
"def adapter\n return @adapter if @adapter\n self.use self.default_adapter... | [
"0.674695",
"0.6718133",
"0.67170995",
"0.66190565",
"0.6456952",
"0.64375293",
"0.6411274",
"0.6403192",
"0.63192284",
"0.613255",
"0.6097838",
"0.5989348",
"0.5982683",
"0.596692",
"0.59614116",
"0.5949812",
"0.59225994",
"0.58756155",
"0.58537143",
"0.5750181",
"0.5750181"... | 0.7343219 | 0 |
This method converts an underscore_string into a CamelCaseString. | def camelize
self.camelize_path.camelize_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CamelCasetoUnderscore(str)\n str.gsub(/::/, '/').\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n tr(\"-\", \"_\").\n downcase\n end",
"def camel_case(str)\n return str if str !~ /_/ && str =~ /[A-Z]+.*/\n str.split('_').m... | [
"0.86876017",
"0.79877114",
"0.79562813",
"0.7887685",
"0.78283054",
"0.7799591",
"0.7743443",
"0.77401805",
"0.77312326",
"0.772333",
"0.7691811",
"0.76649654",
"0.7656502",
"0.7647611",
"0.7641372",
"0.76309615",
"0.75739455",
"0.7569408",
"0.75680256",
"0.7561852",
"0.7526... | 0.0 | -1 |
Search issue by number GET /api/v1/issues/:number | def show
@issue = current_repository.issues.find_by(number: params[:number])
if @issue.blank?
render json: { error: 'Issue not found' }, status: :not_found
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_issue(number)\n github.issues.get(*github_org_repo, number)\n end",
"def get_issue(num)\n @issues = Octokit.issues \"LingduoKong/final\",:state => \"open\"\n @issues.each do |issue|\n if issue.number == num\n @issue = issue\n return @issue\n end\n end\nend",
"def get(*args)\n ... | [
"0.7577021",
"0.726103",
"0.70910215",
"0.6745213",
"0.66506314",
"0.6517576",
"0.6430679",
"0.6364486",
"0.6363683",
"0.6345136",
"0.6286326",
"0.62142307",
"0.61805785",
"0.61604667",
"0.6158889",
"0.61442393",
"0.61429447",
"0.6140085",
"0.6067698",
"0.60430235",
"0.602147... | 0.76550704 | 0 |
Will check and set sorting options for current result set. Subroutine of index method. | def check_sort_options() #:nodoc:
table_name = @tables.first[1]
old_sort = session[table_name][:sort].to_s
sort, direction = old_sort.split(' ')
# sort is requested
if params['sort']
# reverse sort if same selected
if params['sort'] == sort
direction = (direction == '1') ? '-1' : '1'
end
direction ||= 1
sort = params[:sort]
session[table_name][:sort] = "#{params['sort']} #{direction}"
session[table_name][:page] = 1
end
@records.sort( sort => direction.to_i ) if session[table_name][:sort]
params['sort'] = nil # otherwise there is problem with other links
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sorting\n @records = Record.all #Get existing records\n @sortType = params[:sortType] #Get parameters from the form on index\n @sortField = params[:sortField]\n\n @limit = params[:sortNum].to_i # params must be converted from string\n\n if @sortType == \"Decending\" # check i... | [
"0.7047712",
"0.6639795",
"0.64985466",
"0.6423052",
"0.6301379",
"0.62615967",
"0.62206864",
"0.61950904",
"0.61918014",
"0.61905366",
"0.6182327",
"0.61587423",
"0.6148957",
"0.61307263",
"0.61006546",
"0.60708696",
"0.60426503",
"0.6018112",
"0.6018112",
"0.6002937",
"0.59... | 0.6953187 | 1 |
Set aditional filter options when filter is defined by filter method in control object. | def user_filter_options(model) #:nodoc:
table_name = @tables.first[1]
if session[table_name]
DcFilter.get_filter(session[table_name][:filter]) || model
else
model
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_filter(opts)\n opts = check_params(opts,[:filters])\n super(opts)\n end",
"def add_filter\n @filter = true \n end",
"def list_filter_options(**opt)\n # May be overridden by the subclass.\n end",
"def filters=( args )\n @filters.clear\n add_filters(*args)\n end",
"def fil... | [
"0.78268254",
"0.7247881",
"0.7041101",
"0.6886675",
"0.6882358",
"0.6867084",
"0.66847146",
"0.66791457",
"0.6654578",
"0.6648214",
"0.6636697",
"0.66130275",
"0.6609339",
"0.6602647",
"0.6532818",
"0.65155876",
"0.64618266",
"0.6459867",
"0.6458366",
"0.6435416",
"0.641555"... | 0.0 | -1 |
Will set session[table_name][:filter] and save last filter settings to session. subroutine of check_filter_options. | def set_session_filter(table_name)
if params[:filter] == 'off' # clear all values
session[table_name][:filter] = nil
return
end
filter_value = if params[:filter_value].nil?
# NIL indicates that no filtering is needed
'#NIL'
else
if params[:filter_value].class == String and params[:filter_value][0] == '@'
# Internal value. Remove leading @ and evaluate expression
expression = DcInternals.get(params[:filter_value])
eval(expression) rescue nil
else
# No filter when empty
params[:filter_value] == '' ? '#NIL' : params[:filter_value]
end
end
# if filter field parameter is omitted then just set filter value
session[table_name][:filter] =
if params[:filter_field].nil?
saved = YAML.load(session[table_name][:filter])
saved['value'] = filter_value
saved.to_yaml
else
# As field defined. Split name and alternative input field
field = if params[:filter_field].match(' as ')
params[:filter_input] = params[:filter_field].split(' as ').last.strip
params[:filter_field].split(' as ').first.strip
else
params[:filter_field]
end
#
{'field' => field,
'operation' => params[:filter_oper],
'value' => filter_value,
'input' => params[:filter_input],
'table' => table_name }.to_yaml
end
# must be. Otherwise kaminari includes parameter on paging
params[:filter] = nil
params[:filter_id] = nil
params[:filter_oper] = nil
params[:filter_input] = nil
params[:filter_field] = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_filter_options(model) #:nodoc:\r\n table_name = @tables.first[1]\r\n if session[table_name]\r\n DcFilter.get_filter(session[table_name][:filter]) || model\r\n else\r\n model\r\n end\r\nend",
"def user_filter_options(model) #:nodoc:\r\n table_name = @tables.first[1]\r\n if session[table_name]... | [
"0.70839876",
"0.70839876",
"0.6745034",
"0.6519402",
"0.6514818",
"0.64166665",
"0.61868703",
"0.5929289",
"0.58721143",
"0.5869023",
"0.5820632",
"0.5757801",
"0.5757801",
"0.5757801",
"0.5714009",
"0.5652883",
"0.5639455",
"0.5621632",
"0.56202394",
"0.56148857",
"0.555673... | 0.79407525 | 0 |
Will check and set current filter options for result set. Subroutine of index method. | def check_filter_options() #:nodoc:
table_name = @tables.first[1]
model = @tables.first[0]
session[table_name] ||= {}
# process page
session[table_name][:page] = params[:page] if params[:page]
# new filter is applied
if params[:filter]
set_session_filter(table_name)
session[table_name][:page] = 1
end
# if data model has field dc_site_id ensure that only documents which belong to the site are selected.
site_id = dc_get_site._id if dc_get_site
# dont't filter site if no dc_site_id field or user is ADMIN
site_id = nil if !model.method_defined?('dc_site_id') or dc_user_can(DcPermission::CAN_ADMIN)
#
if @records = DcFilter.get_filter(session[table_name][:filter])
@records = @records.and(dc_site_id: site_id) if site_id
else
@records = if site_id
model.where(dc_site_id: site_id)
else
model
end
end
=begin
# TODO Use only fields requested. Higly experimental but necessary in some scenarios
if (columns = @form['result_set']['columns'])
cols = []
columns.each { |k,v| cols << v['name'] }
p '*',cols,'*'
@records = @records.only(cols)
end
=end
# pagination if required
per_page = (@form['result_set']['per_page'] || 30).to_i
if per_page > 0
@records = @records.page(session[table_name][:page]).per(per_page)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_filter_options\n @sort_modes = Organization.sort_modes\n @view_modes = Organization.view_modes\n\n @current_sort_mode = if @sort_modes.keys.include?(params[:sort_by])\n params[:sort_by]\n else\n @sort_modes.keys.first\n ... | [
"0.6896217",
"0.6781816",
"0.66839546",
"0.64638686",
"0.63141257",
"0.6276603",
"0.6266231",
"0.6205087",
"0.6202081",
"0.6197165",
"0.6177646",
"0.614709",
"0.6145204",
"0.6145204",
"0.61345583",
"0.61045486",
"0.6103005",
"0.6103005",
"0.6102026",
"0.60965526",
"0.6094438"... | 0.7084182 | 0 |
Show displays record in readonly mode. | def show
find_record
if (m = callback_method('before_show') )
ret = call_callback_method(m)
# Don't do anything if return is false
if ret.class == FalseClass
@form['readonly'] = nil # must be
return index
end
end
render action: 'edit', layout: 'cms'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readonly!\n @readonly = true\n end",
"def readonly! #:nodoc:\n @readonly = true\n end",
"def readonly\n true\n end",
"def readonly?; true; end",
"def readonly?; true; end",
"def readonly?; true; end",
"def show\r\n find_record\r\n # before_show callback\r\n if (m = callba... | [
"0.69478077",
"0.67702454",
"0.67576367",
"0.67053807",
"0.67053807",
"0.67053807",
"0.64766836",
"0.6435424",
"0.6435424",
"0.6374576",
"0.63551795",
"0.63551795",
"0.6343003",
"0.6341589",
"0.6341589",
"0.6341589",
"0.62736624",
"0.62736624",
"0.62736624",
"0.62736624",
"0.... | 0.6178476 | 36 |
Login action. Used to login direct to CMS. It is mostly used when first time creating site and when something goes so wrong, that traditional login procedure is not available. Login can be called directly with url | def login
session[:edit_mode] = 0 unless params[:ok]
render action: 'login', layout: 'cms'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login\n redirect_to lato_core.root_path if core_controlSession\n end",
"def login\n end",
"def login\n if request.post?\n if user_login(request.subset('username', 'password'))\n flash[:success] = 'You have been logged in'\n redirect(Posts.r(:index))\n else\n ... | [
"0.75986254",
"0.7528261",
"0.7512286",
"0.7459514",
"0.7459514",
"0.7459514",
"0.7459514",
"0.7459514",
"0.7459514",
"0.7459514",
"0.7459514",
"0.7459514",
"0.7459254",
"0.7443053",
"0.7423155",
"0.7423155",
"0.7369102",
"0.7360099",
"0.73526764",
"0.73526764",
"0.7345159",
... | 0.702454 | 36 |
Logout action. Used to logout direct from CMS. Logout can be called directly with url | def logout
session[:edit_mode] = 0
session[:user_id] = nil
render action: 'login', layout: 'cms'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logout\n logout_redirect = Settings.logout_redirect\n if logout_redirect == 'NONE'\n page_not_found\n return\n end\n MarkusLogger.instance.log(\"User '#{real_user.user_name}' logged out.\")\n clear_session\n if logout_redirect == 'DEFAULT'\n redirect_to action: 'login'\n els... | [
"0.80526847",
"0.8025935",
"0.802536",
"0.8002947",
"0.7928222",
"0.7924494",
"0.7896677",
"0.78945965",
"0.7864526",
"0.7851477",
"0.78008896",
"0.77834034",
"0.77834034",
"0.776881",
"0.77656716",
"0.7751532",
"0.7740392",
"0.77361953",
"0.77297646",
"0.76697886",
"0.766586... | 0.77876985 | 12 |
Duplicate embedded document. Since embedded documents are returned differently then top level document. Subroutine of duplicate_socument. | def duplicate_embedded(source) #:nodoc:
# TODO Works for two embedded levels. Dies with third and more levels.
dest = {}
source.each do |attribute_name, value|
next if attribute_name == '_id' # don't duplicate _id
if value.class == Array
dest[attribute_name] = []
value.each do |ar|
dest[attribute_name] << duplicate_embedded(ar)
end
else
# if duplicate string must be added. Useful for unique attributes
add_duplicate = params['dup_fields'].to_s.match(attribute_name + ',')
dest[attribute_name] = value
dest[attribute_name] << ' dup' if add_duplicate
end
end
dest
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duplicate_document(source)\r\n dest = {}\r\n source.attribute_names.each do |attribute_name|\r\n next if attribute_name == '_id' # don't duplicate _id\r\n# if duplicate, string must be added. Useful for unique attributes\r\n add_duplicate = params['dup_fields'].to_s.match(attribute_name + ',')\r\n d... | [
"0.7715262",
"0.7483858",
"0.66329336",
"0.6560853",
"0.6281626",
"0.62060547",
"0.6159449",
"0.60137683",
"0.5956936",
"0.5918448",
"0.5815487",
"0.5807321",
"0.5785628",
"0.5775357",
"0.5765833",
"0.57616353",
"0.5761095",
"0.5757371",
"0.57388204",
"0.5725774",
"0.57188964... | 0.64122456 | 4 |
Will create duplicate document of source document. This method is used for duplicating document and is called from create action. | def duplicate_document(source)
dest = {}
source.attribute_names.each do |attribute_name|
next if attribute_name == '_id' # don't duplicate _id
# if duplicate, string must be added. Useful for unique attributes
add_duplicate = params['dup_fields'].to_s.match(attribute_name + ',')
dest[attribute_name] = source[attribute_name]
dest[attribute_name] << ' dup' if add_duplicate
end
# embedded documents
source.embedded_relations.keys.each do |embedded_name|
next if source[embedded_name].nil? # it happens
dest[embedded_name] = []
source[embedded_name].each do |embedded|
dest[embedded_name] << duplicate_embedded(embedded)
end
end
dest
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duplicate_document(source)\r\n params['dup_fields'] += ',' if params['dup_fields'] # for easier field matching\r\n dest = {}\r\n source.attribute_names.each do |attribute_name|\r\n next if attribute_name == '_id' # don't duplicate _id\r\n\r\n # if duplicate, string dup is added. For unique fields\r\n ... | [
"0.75598246",
"0.71919334",
"0.70336044",
"0.65863997",
"0.6525738",
"0.64745295",
"0.63639694",
"0.61863554",
"0.61763835",
"0.6120166",
"0.6001447",
"0.59112006",
"0.5897147",
"0.5855327",
"0.5780419",
"0.571624",
"0.5700449",
"0.5680946",
"0.5674615",
"0.56721675",
"0.5645... | 0.7535978 | 1 |
Create (or duplicate) action. Action is also used for turning filter on. | def create
# abusing create for turning filter on
return index if params[:filter].to_s == 'on'
# not authorized
unless dc_user_can(DcPermission::CAN_CREATE)
flash[:error] = t('drgcms.not_authorized')
return index
end
#
if params['id'].nil? # create record
# Prevent double form submit
params[:form_time_stamp] = params[:form_time_stamp].to_i
session[:form_time_stamp] ||= 0
return index if params[:form_time_stamp] <= session[:form_time_stamp]
session[:form_time_stamp] = params[:form_time_stamp]
#
create_new_empty_record
params[:return_to] = 'index' if params[:commit] == t('drgcms.save&back') # save & back
if save_data
@parms['action'] = 'update'
@parms['id'] = @record.id # must be set, for proper update link
flash[:info] = t('drgcms.doc_saved')
return process_return_to(params[:return_to]) if params[:return_to]
render action: :edit
else
render action: :new
end
else # duplicate record
find_record
params['dup_fields'] += ',' if params['dup_fields'] # for easier field matching
new_doc = duplicate_document(@record)
create_new_empty_record(new_doc)
update_standards()
@record.save!
index
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @actions = [] unless defined?(@actions)\n @actions << :create\n end",
"def add_action(new_action)\n if action(new_action.name)\n raise DuplicateAction, \"Action '#{new_action.name}' already defined on service '#{_attributes_[:name]}'\"\n end\n\n actions << ... | [
"0.69806594",
"0.6787015",
"0.6614873",
"0.6564606",
"0.6406005",
"0.63478714",
"0.633957",
"0.6295927",
"0.62633103",
"0.6253337",
"0.62186044",
"0.6214477",
"0.6211874",
"0.62093186",
"0.6208617",
"0.61843085",
"0.616254",
"0.61181474",
"0.6101225",
"0.6087749",
"0.6080209"... | 0.0 | -1 |
Destroy action. Used also for enabling and disabling record. | def destroy
find_record
# Which permission is required to delete
permission = if params['operation'].nil?
if @record.respond_to?('created_by') # needs can_delete_all if created_by is present and not owner
(@record.created_by == session[:user_id]) ? DcPermission::CAN_DELETE : DcPermission::CAN_DELETE_ALL
else
DcPermission::CAN_DELETE # by default
end
else # enable or disable record
if @record.respond_to?('created_by')
(@record.created_by == session[:user_id]) ? DcPermission::CAN_EDIT : DcPermission::CAN_EDIT_ALL
else
DcPermission::CAN_EDIT # by default
end
end
ok2delete = dc_user_can(permission)
#
case
# not authorized
when !ok2delete then
flash[:error] = t('drgcms.not_authorized')
return index
when params['operation'].nil? then
# Process before delete callback
if (m = callback_method('before_delete') )
ret = call_callback_method(m)
# Don't do anything if return is false
return index if ret.class == FalseClass
end
# document deleted
if @record.destroy
save_journal(:delete)
flash[:info] = t('drgcms.record_deleted')
# Process after delete callback
if (m = callback_method('after_delete') ) then call_callback_method(m) end
# Process return_to link
return process_return_to(params[:return_to]) if params[:return_to]
else
flash[:error] = dc_error_messages_for(@record)
end
return index
# deaktivate document
when params['operation'] == 'disable' then
if @record.respond_to?('active')
@record.active = false
save_journal(:update, @record.changes)
update_standards()
@record.save
flash[:info] = t('drgcms.doc_disabled')
end
# reaktivate document
when params['operation'] == 'enable' then
if @record.respond_to?('active')
@record.active = true
update_standards()
save_journal(:update, @record.changes)
@record.save
flash[:info] = t('drgcms.doc_enabled')
end
end
#
@parms['action'] = 'update'
render action: :edit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_destroy\n @record = find_if_allowed(params[:id], :destroy)\n self.successful = @record.destroy\n end",
"def destroy! #TODO\n destroy || raise(ActiveRecord::RecordNotDestroyed)\n end",
"def destroy(record)\n record.destroy\n end",
"def record_destroy\n paper_trai... | [
"0.74106586",
"0.73332083",
"0.7320389",
"0.7269489",
"0.7243179",
"0.72333616",
"0.7225906",
"0.72176397",
"0.7194986",
"0.71857524",
"0.71796626",
"0.71713024",
"0.71622366",
"0.71622366",
"0.71581453",
"0.7136363",
"0.7111349",
"0.7111349",
"0.7107668",
"0.71046025",
"0.70... | 0.0 | -1 |
=begin Processes on_save_ok form directive. Data is saved to session for safety reasons. def process_on_save_ok | def forms_merge(hash1, hash2)
target = hash1.dup
hash2.keys.each do |key|
if hash2[key].is_a? Hash and hash1[key].is_a? Hash
target[key] = forms_merge(hash1[key], hash2[key])
next
end
target[key] = hash2[key] == '/' ? nil : hash2[key]
end
# delete keys with nil value
target.delete_if{ |k,v| v.nil? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_data\r\n form_fields = fields_on_form()\r\n return true if form_fields.size == 0\r\n\r\n form_fields.each do |v|\r\n session[:form_processing] = v['name'] # for debuging\r\n next if v['type'].nil? or v['name'].nil? or\r\n v['type'].match('embedded') or # don't wipe embedded types\r\n ... | [
"0.65353835",
"0.6439867",
"0.6182269",
"0.6080902",
"0.6028771",
"0.59831744",
"0.5938501",
"0.576472",
"0.57614785",
"0.57285726",
"0.57139885",
"0.5650281",
"0.56421685",
"0.5625181",
"0.56238294",
"0.5620591",
"0.5617369",
"0.56150126",
"0.55816376",
"0.557842",
"0.556558... | 0.0 | -1 |
Read drgcms form into yaml object. Subroutine of check_authorization. | def read_drg_cms_form
table_name = decamelize_type(params[:table].strip)
@tables = table_name.split(';').inject([]) { |r,v| r << [v.classify.constantize, v] }
# split ids passed when embedded document
ids = params[:ids].to_s.strip.downcase
@ids = ids.split(';').inject([]) { |r,v| r << v }
# formname defaults to last table specified
formname = params[:formname] || @tables.last[1]
@form = YAML.load_file( dc_find_form_file(formname) )
# when form extends another form file.
if @form['extend']
form = YAML.load_file( dc_find_form_file(@form['extend']) )
@form = forms_merge(form, @form)
end
# add readonly key to form if readonly parameter is passed in url
@form['readonly'] = 1 if params['readonly'] #and %w(1 yes true).include?(params['readonly'].to_s.downcase.strip)
# !!!!!! Always use strings for key names since @parms['table'] != @parms[:table]
@parms = { 'table' => table_name, 'ids' => params[:ids], 'formname' => formname,
'return_to' => params['return_to'], 'edit_only' => params['edit_only'],
'readonly' => params['readonly']
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDataFrom_FieldPermission_YmlFile(yamlInfo)\n YAML.load_file(\"./config/FieldPermission.yml\")[yamlInfo]\nend",
"def abstract_form\n # cache yaml files for speeeed\n $loaded_yaml_sheets ||= {}\n begin\n $loaded_yaml_sheets[id.to_i] ||= YAML::load(content)\n rescue Exception => e\n # ... | [
"0.5931479",
"0.56551415",
"0.5344726",
"0.53179777",
"0.53020734",
"0.52910525",
"0.5266863",
"0.52405834",
"0.5220856",
"0.51473206",
"0.5131775",
"0.5098446",
"0.5064317",
"0.50636077",
"0.5058688",
"0.501107",
"0.5007277",
"0.49791017",
"0.49506882",
"0.4935252",
"0.49342... | 0.62064284 | 0 |
Check if user is authorized for the action. If authorization is in order it will also load DRG form. | def check_authorization
params[:table] ||= params[:formname]
# Just show menu
# return show if params[:action] == 'show'
return login if params[:id].in?(%w(login logout))
# request shouldn't pass
if session[:user_roles].nil? or params[:table].to_s.strip.downcase.size < 3 or
!dc_user_can(DcPermission::CAN_VIEW)
return render(action: 'error', locals: { error: t('drgcms.not_authorized')} )
end
read_drg_cms_form
# Permissions can be also defined on form
#TODO So far only can_view is used. Think about if using other permissions has sense
if @form['permissions'].nil? or @form['permissions']['can_view'].nil? or
dc_user_has_role(@form['permissions']['can_view'])
# Extend class with methods defined in drgcms_controls module. May include embedded forms therefor ; => _
controls_string = (@form['controls'] ? @form['controls'] : params[:table].gsub(';','_')) + '_control'
controls = "DrgcmsControls::#{controls_string.classify}".constantize rescue nil
# version next
if controls.nil?
controls_string = "#{@form['controls'] || params[:table].gsub(';','_')}_control"
controls = "#{controls_string.classify}".constantize rescue nil
end
extend controls if controls
else
render(action: 'error', locals: { error: t('drgcms.not_authorized')} )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_authorization!\n #check_current_user!\n #authorized = current_user.present? && valid_organisation_date?\n\n # TODO check due_date\n if !current_user\n flash[:alert] = \"Por favor ingrese.\"\n redirect_to new_session_url(subdomain: 'app') and return\n elsif !current_... | [
"0.70911807",
"0.7014901",
"0.69858384",
"0.6886319",
"0.67628634",
"0.67185515",
"0.67185515",
"0.67149246",
"0.6700801",
"0.6631153",
"0.66274554",
"0.6568803",
"0.6568803",
"0.6551151",
"0.65370655",
"0.6523552",
"0.6519331",
"0.651591",
"0.6515352",
"0.65049607",
"0.64920... | 0.69491446 | 3 |
Find current record (document) for edit, update or delete. | def find_record #:nodoc:
if @tables.size == 1
@record = @tables.first[0].find(params[:id])
else
rec = @tables.first[0].find(@ids.first) # top most record
1.upto(@tables.size - 2) { |i| rec = rec.send(@tables[i][1].pluralize).find(@ids[i]) } # find embedded childrens by ids
@record = rec.send(@tables.last[1].pluralize).find(params[:id]) # record to edit
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_edit\n @record = find_if_allowed(params[:id], :update)\n end",
"def find_record\n self.class.resource_model.find(params[:id])\n end",
"def find(id)\n @document\n end",
"def find(id)\n @document\n end",
"def find_record\n @record ||= model.find_by_id(p... | [
"0.70010304",
"0.66371536",
"0.645126",
"0.645126",
"0.6336335",
"0.62574476",
"0.62544674",
"0.62016326",
"0.6194435",
"0.6165387",
"0.6150549",
"0.61180884",
"0.60496944",
"0.59447867",
"0.59217507",
"0.5868917",
"0.584968",
"0.5804183",
"0.5803293",
"0.5785114",
"0.5768705... | 0.6766594 | 2 |
Creates new empty record for new and create action. | def create_new_empty_record(initial_data=nil) #:nodoc:
if @tables.size == 1
@record = @tables.first[0].new(initial_data)
else
rec = @tables.first[0].find(@ids.first) # top most record
1.upto(@tables.size - 2) { |i| rec = rec.send(@tables[i][1].pluralize).find(@ids[i]) } # find embedded childrens by ids
@record = rec.send(@tables.last[1].pluralize).new(initial_data) # new record
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(params = {})\n record = new(params)\n record.save && record\n end",
"def create\n end",
"def create; end",
"def create; end",
"def create; end",
"def create; end",
"def create\r\n end",
"def create!\n end",
"def create\n \n end",
"def create\n... | [
"0.7196165",
"0.7078749",
"0.6986293",
"0.6986293",
"0.6986293",
"0.6986293",
"0.6986099",
"0.69436294",
"0.69215757",
"0.6920973",
"0.6911504",
"0.68936485",
"0.6864855",
"0.6864855",
"0.6864855",
"0.6857652",
"0.6852797",
"0.6850312",
"0.6801948",
"0.6788817",
"0.6784076",
... | 0.65859425 | 87 |
Update standard fields like updated_by, created_by, site_id | def update_standards(record = @record)
record.updated_by = session[:user_id] if record.respond_to?('updated_by')
if record.new_record?
record.created_by = session[:user_id] if record.respond_to?('created_by')
# set this only initialy. Allow to be set to nil on updates. This documents can then belong to all sites
# and will be directly visible only to admins
record.dc_site_id = dc_get_site._id if record.respond_to?('dc_site_id') and record.dc_site_id.nil?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updater(user)\n self.updated_by_id = user.id\n self.save\n end",
"def before_save(model)\n model.updated_by = @@current_user if model.respond_to?(\"updated_by\")\n end",
"def set_updated_by\n account.updated_by = current_user.id\n account\n end",
"def updater(user)\n # self.updated_by... | [
"0.6813427",
"0.67833054",
"0.67374307",
"0.6657943",
"0.6609125",
"0.6609125",
"0.6609125",
"0.6540887",
"0.6502547",
"0.6403734",
"0.63821065",
"0.6285329",
"0.6257967",
"0.6257402",
"0.6237996",
"0.62193424",
"0.6204756",
"0.6198226",
"0.6193736",
"0.61796474",
"0.617722",... | 0.66335404 | 4 |
Save document changes to journal table. Saves all parameters to retrieve record if needed. [Parameters:] [operation] 'delete' or 'update'. [changes] Current document changed fields. | def save_journal(operation, changes = {})
# return unless session[:save_journal]
if operation == :delete
@record.attributes.each {|k,v| changes[k] = v}
# elsif operation == :new
# changes = {}
end
#
if (operation != :update) or changes.size > 0
# determine site_id
site_id = @record.site_id if @record.respond_to?('site_id')
site_id = dc_get_site._id if site_id.nil? and dc_get_site
DcJournal.create(site_id: site_id,
operation: operation,
user_id: session[:user_id],
tables: params[:table],
ids: params[:ids],
doc_id: params[:id],
ip: request.remote_ip,
time: Time.now,
diff: changes.to_json)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_journal(operation, changes = {})\r\n if operation == :delete\r\n @record.attributes.each { |k, v| changes[k] = v }\r\n end\r\n changes.except!('created_at', 'updated_at', 'created_by', 'updated_by')\r\n\r\n if (operation != :update) || changes.size > 0\r\n # determine site_id\r\n site_id = @r... | [
"0.76388687",
"0.57638484",
"0.54505813",
"0.5311796",
"0.50651145",
"0.49676397",
"0.49089247",
"0.49069107",
"0.48403698",
"0.48345056",
"0.48258615",
"0.4803447",
"0.47994226",
"0.47728717",
"0.47701398",
"0.47694156",
"0.47416022",
"0.4741447",
"0.4731537",
"0.4726521",
"... | 0.73300993 | 1 |
Determines if callback method is defined in parameters or in control module. Returns callback method name or nil if not defined. | def callback_method(key) #:nodoc:
data_key = key.gsub('_','-') # data fields translate _ to -
cb = case
when params['data'] && params['data'][data_key] then params['data'][data_key]
# if dc_ + key method is present in model then it will be called automatically
when respond_to?('dc_' + key) then 'dc_' + key
when params[key] then params[key]
else nil
end
#
ret = case
when cb.nil? then cb # otherwise there will be errors in next lines
when cb.match('eval ') then cb.sub('eval ','')
when cb.match('return_to ')
params[:return_to] = cb.sub('return_to ','')
return nil
else cb
end
ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callback_defined?(name, *args)\n callback_method_name = args[0].in?([:before, :after, :around]) ? args[1] : args[0]\n self.send(\"_#{name}_callbacks\").collect(&:filter).include?(callback_method_name)\n end",
"def respond_to_missing?(method_name, include_private = false)\n *_, callback_name = *me... | [
"0.66897273",
"0.6491536",
"0.6491536",
"0.6477352",
"0.6477352",
"0.6477021",
"0.64740485",
"0.6416171",
"0.62035036",
"0.6110025",
"0.57577384",
"0.567433",
"0.5606997",
"0.55693513",
"0.5550242",
"0.5524033",
"0.55222595",
"0.54986054",
"0.53723353",
"0.5369573",
"0.529987... | 0.5588887 | 13 |
Same as javascript_tag helper. Ajax form actions may results in javascript code to be returned. This will add javascript tag to code. | def js_tag(script) #:nodoc:
"<script type=\"text/javascript\">#{script}</script>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def javascript_tag(content_or_options_with_block = T.unsafe(nil), html_options = T.unsafe(nil), &block); end",
"def ajax_action_code\n js = Waw::ActionController::JSGeneration.new\n code = js.generate_js_for_action(Waw::kernel, self, \"\")\n <<-EOF\n <script type=\"text/javascript\"... | [
"0.7257494",
"0.7030038",
"0.6784586",
"0.64556134",
"0.6374977",
"0.63626355",
"0.6337445",
"0.62223125",
"0.62118155",
"0.6195321",
"0.6135956",
"0.61212176",
"0.611304",
"0.6063451",
"0.606129",
"0.6048093",
"0.60180426",
"0.59655863",
"0.5941402",
"0.5872783",
"0.58177596... | 0.7299381 | 1 |
Process return_to parameter when defined on form or set by controls methods. params['return_to'] may contain 'index', 'reload' or 'parent.reload' or any valid url to return to, after successful controls method call. | def process_return_to(return_to)
script = case
when return_to == 'index' then return index
when return_to.match(/parent\.reload/i) then 'parent.location.href=parent.location.href;'
when return_to.match(/reload/i) then 'location.href=location.href;'
else "location.href='#{return_to}'"
end
render text: js_tag(script)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_return_to(return_to)\r\n script = case\r\n when return_to == 'index' then return index\r\n when return_to.match(/eval=/i) then return_to.sub('eval=', '')\r\n when return_to.match(/parent\\.reload/i) then 'parent.location.href=parent.location.href;'\r\n when return_to.match(/reload/i) then ... | [
"0.68137366",
"0.679878",
"0.6744079",
"0.61985743",
"0.61430174",
"0.6120043",
"0.600663",
"0.59498477",
"0.5925256",
"0.59185886",
"0.58513606",
"0.58135813",
"0.57416713",
"0.5716155",
"0.56671834",
"0.5653707",
"0.5531275",
"0.5508149",
"0.54460716",
"0.5438849",
"0.54343... | 0.6633759 | 3 |
Since tabs have been introduced on form it is a little more complicated to get all edit fields on form. This method does it. Subroutine of save_data. | def fields_on_form() #:nodoc:
fields = []
if @form['form']['fields']
# read only field elements (key is Fixnum)
@form['form']['fields'].each {|key,options| fields << options if key.class == Fixnum }
else
@form['form']['tabs'].keys.each do |tab|
@form['form']['tabs'][tab].each {|key,options| fields << options if key.class == Fixnum }
end
end
fields
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_form_fields\n @save_form_fields ||= collect_save_form_fields\n end",
"def fields_on_form #:nodoc:\r\n form_fields = []\r\n if @form['form']['fields']\r\n # read only field elements (key is Integer)\r\n @form['form']['fields'].each { |key, options| form_fields << options if key.cl... | [
"0.662098",
"0.65408444",
"0.64145684",
"0.6123326",
"0.5826113",
"0.5766643",
"0.57523185",
"0.5648538",
"0.5644005",
"0.5636018",
"0.5625351",
"0.5585195",
"0.5579176",
"0.5573238",
"0.55625856",
"0.5544034",
"0.5535934",
"0.55196404",
"0.5518544",
"0.5516568",
"0.55080634"... | 0.6700142 | 0 |
Save edited data. Take care that only fields defined on form are affected. It also saves journal data and calls before_save and after_save callbacks. | def save_data
fields = fields_on_form()
return true if fields.size == 0
#
fields.each do |v|
next if v['type'].nil?
next if v['type'].match('embedded') # don't wipe embedded fields
next if params[:edit_only] and params[:edit_only] != v['name'] # otherwise other fields would be wiped
next unless @record.respond_to?(v['name']) # there can be temporary fields on the form
next if v['readonly'] # fields with readonly option don't retain value and would be wiped
# return value from form field definition
value = DrgcmsFormFields.const_get(v['type'].camelize).get_data(params, v['name'])
@record.send("#{v['name']}=", value)
end
#
operation = @record.new_record? ? :new : :update
# controls callback method
if (m = callback_method('before_save') )
ret = call_callback_method(m)
# dont's save if callback method returns false
return false if ret.class == FalseClass
end
# maybe model has dc_before_save method defined. Call it. This was before callback
@record.dc_before_save(self) if @record.respond_to?('dc_before_save')
#
changes = @record.changes
update_standards() if changes.size > 0 # update only if there has been some changes
if (saved = @record.save)
save_journal(operation, changes)
# callback methods
if (m = callback_method('after_save') ) then call_callback_method(m) end
# check if model has dc_after_save method
@record.dc_after_save(self) if @record.respond_to?('dc_after_save')
end
saved
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_data\r\n form_fields = fields_on_form()\r\n return true if form_fields.size == 0\r\n\r\n form_fields.each do |v|\r\n session[:form_processing] = v['name'] # for debuging\r\n next if v['type'].nil? or v['name'].nil? or\r\n v['type'].match('embedded') or # don't wipe embedded types\r\n ... | [
"0.69059527",
"0.6117032",
"0.607445",
"0.60359377",
"0.59543896",
"0.59176624",
"0.5907739",
"0.5872968",
"0.583641",
"0.57506114",
"0.57491773",
"0.57234114",
"0.5718009",
"0.5701912",
"0.56875205",
"0.56787616",
"0.56625324",
"0.5595324",
"0.55815715",
"0.5570396",
"0.5570... | 0.6458112 | 1 |
GET /members GET /members.xml | def index
@members = Member.search(params[:search]).order(sort_column+" "+sort_direction).paginate(:per_page => 10, :page => params[:page])
@title = "Members"
respond_to do |format|
format.html # index.html.erb
format.js # index.js.erb
format.xml { render :xml => @members }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def members\n raw_response = get_request('users/members')\n parse_response(raw_response, :users)\n end",
"def list_members\n HTTP.headers(:accept => @@accept, \"content-type\" => @@content_type).basic_auth(:user => ENV[\"API_USERNAME\"], :pass => ENV[\"API_PASSWORD\"])\n .get(\... | [
"0.7903388",
"0.7372727",
"0.7194274",
"0.7098234",
"0.7059046",
"0.69730103",
"0.6923398",
"0.69045466",
"0.69045466",
"0.68216807",
"0.6803228",
"0.6799462",
"0.6763184",
"0.6763184",
"0.6763184",
"0.6763184",
"0.6763184",
"0.6763184",
"0.6763184",
"0.6763184",
"0.6763184",... | 0.62054163 | 74 |
GET /members/1 GET /members/1.xml | def show
@member = Member.find(params[:id])
@warband = @member.warband
@user = @warband.user
@items = @member.items
@title = @member.name
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @member }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def members\n raw_response = get_request('users/members')\n parse_response(raw_response, :users)\n end",
"def index\n @members = Defer { ::Member.all }\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @members }\n end\n end",
... | [
"0.7064496",
"0.6939014",
"0.6886399",
"0.68744516",
"0.6869744",
"0.68291515",
"0.6759661",
"0.6746517",
"0.66662574",
"0.6665919",
"0.6639834",
"0.6497042",
"0.64914745",
"0.6482442",
"0.6481389",
"0.6474925",
"0.6471089",
"0.646676",
"0.6463868",
"0.646213",
"0.64559525",
... | 0.6125471 | 64 |
GET /members/new GET /members/new.xml | def new
@member = Member.new
@title = "New member"
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @member }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @member = Member.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @member }\n end\n end",
"def new\n @member = Member.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @member }\n e... | [
"0.75905365",
"0.75905365",
"0.75905365",
"0.73785937",
"0.7339909",
"0.73335916",
"0.7262581",
"0.71329445",
"0.71195185",
"0.71195185",
"0.71195185",
"0.71195185",
"0.71195185",
"0.71195185",
"0.71195185",
"0.70735514",
"0.6980091",
"0.69704103",
"0.69519126",
"0.69349664",
... | 0.7645127 | 0 |
POST /members POST /members.xml | def create
@member = Member.new(params[:member])
@member.warband = current_user.warband if @member.warband.blank?
respond_to do |format|
if @member.save
format.html { redirect_to(@member, :notice => 'Member was successfully created.') }
format.xml { render :xml => @member, :status => :created, :location => @member }
else
format.html { render :action => "new" }
format.xml { render :xml => @member.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @member = @current_enterprise.members.build(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n fo... | [
"0.61671525",
"0.6156513",
"0.61417735",
"0.6114032",
"0.6083187",
"0.60502577",
"0.6038692",
"0.6017749",
"0.60003173",
"0.59865993",
"0.5971774",
"0.5899646",
"0.58964914",
"0.588346",
"0.58806616",
"0.58642143",
"0.5863212",
"0.5861496",
"0.5853878",
"0.58368444",
"0.58368... | 0.54660904 | 71 |
PUT /members/1 PUT /members/1.xml | def update
@member = Member.find(params[:id])
unless params[:item_id].blank?
i = Item.find(params[:item_id])
i.member = @member
i.warband = nil
i.save!
end
respond_to do |format|
if @member.update_attributes(params[:member])
format.html { redirect_to(@member, :notice => 'Member was successfully updated.') }
format.xml { head :ok }
format.json { render :json => @member }
else
format.html { render :action => "edit" }
format.xml { render :xml => @member.errors, :status => :unprocessable_entity }
format.json { render :json => @member.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @member = Member.find(params[:id])\n\n respond_to do |format|\n if @member.update_attributes(params[:member])\n flash[:notice] = 'Member was successfully updated.'\n format.html { redirect_to '/members/myindex' }\n format.xml { head :ok }\n else\n format.ht... | [
"0.62681997",
"0.6248367",
"0.6248367",
"0.6235916",
"0.62278175",
"0.61481386",
"0.6045742",
"0.60422605",
"0.6030557",
"0.59456027",
"0.59424746",
"0.59080094",
"0.5905808",
"0.5904432",
"0.59011877",
"0.5881098",
"0.5880963",
"0.58590305",
"0.5852408",
"0.5852408",
"0.5852... | 0.0 | -1 |
DELETE /members/1 DELETE /members/1.xml | def destroy
@member = Member.find(params[:id])
@member.destroy
respond_to do |format|
format.html { redirect_to(members_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n \n \n respond_to do |format|\n format.html { redirect_to(members_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n respond_to do |format|\... | [
"0.7258529",
"0.70853907",
"0.70709115",
"0.70709115",
"0.70334417",
"0.69972837",
"0.6850161",
"0.67788607",
"0.67172176",
"0.66850346",
"0.6668248",
"0.6632129",
"0.66006005",
"0.66006005",
"0.65934986",
"0.65896595",
"0.6587486",
"0.6587486",
"0.6573435",
"0.6573435",
"0.6... | 0.7142943 | 2 |
Ensure that the current User is the same as the one that the warband and member belongs to | def ensure_correct_user!
@member = Member.find(params[:id])
@user = @member.warband.user
redirect_to(user_path(current_user), :alert => "You may not perform this action on another user's Warband member!") and return unless current_user?(@user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_user(user)\n user == current_user\n end",
"def require_same_user\n if current_user != @user && !current_user.admin?\n flash[:alert] = \"you dont have access to do anything with #{@user.username}'s account\"\n redirect_to user_path(@user)\n \n end\n \n end",
"def validat... | [
"0.69296193",
"0.68647885",
"0.6826858",
"0.6766484",
"0.67326665",
"0.6656141",
"0.6653835",
"0.65959376",
"0.6578301",
"0.6572746",
"0.65722",
"0.656788",
"0.6562827",
"0.6545116",
"0.6539341",
"0.6537548",
"0.6488379",
"0.6484763",
"0.64823985",
"0.6447027",
"0.644553",
... | 0.78903437 | 0 |
Ensure that the current User has a Warband to add members to | def ensure_has_warband!
redirect_to new_warband_path, :alert => "You need to create a Warband first!" and return if current_user.warband.blank?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_correct_user!\n @member = Member.find(params[:id])\n @user = @member.warband.user\n redirect_to(user_path(current_user), :alert => \"You may not perform this action on another user's Warband member!\") and return unless current_user?(@user)\n end",
"def add_member(user)\n members << use... | [
"0.6733075",
"0.64796454",
"0.63712406",
"0.636226",
"0.6297319",
"0.6225041",
"0.6224692",
"0.62110895",
"0.6188878",
"0.61603063",
"0.6159718",
"0.6152703",
"0.6050154",
"0.601141",
"0.584922",
"0.5835002",
"0.5827075",
"0.58246994",
"0.58246994",
"0.57832927",
"0.57744646"... | 0.6965122 | 0 |
Get the column to order by. Default: name | def sort_column
Member.column_names.include?(params[:sort]) ? params[:sort] : "name"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def order_by_column\n return clazz.clustering_columns[0].name if clazz.clustering_columns.length > 0\n clazz.key_columns[0].name\n end",
"def sort_column\n Race.column_names.include?(params[:sort]) ? params[:sort] : 'name'\n end",
"def order_by_column\n target_class.clustering_col... | [
"0.7694296",
"0.7637907",
"0.75414926",
"0.75414926",
"0.75026983",
"0.7465791",
"0.7462408",
"0.7406389",
"0.7397424",
"0.73685056",
"0.7342495",
"0.7342495",
"0.73353827",
"0.73228514",
"0.7315346",
"0.7297553",
"0.7282554",
"0.7170641",
"0.7170641",
"0.7169783",
"0.7114556... | 0.75487685 | 2 |
Get the sort direction (order_by). Possible: asc, desc. Default: asc | def sort_direction
%w[asc desc].include?(params[:direction]) ? params[:direction] : "asc"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_direction\n %w[asc desc].include?(params[:direction]) ? params[:direction] : \"desc\"\n end",
"def sort_direction\n %w[asc desc].include?(params[:direction]) ? params[:direction] : \"desc\"\n end",
"def sort_direction\n %w[asc, desc].include?(params[:direction]) ? params[:directio... | [
"0.8421503",
"0.8421503",
"0.84033024",
"0.8326958",
"0.8326958",
"0.8326958",
"0.8326958",
"0.8326958",
"0.8280606",
"0.82384604",
"0.8209182",
"0.818399",
"0.818399",
"0.818399",
"0.8093254",
"0.8074329",
"0.8046106",
"0.7998723",
"0.7964224",
"0.7964224",
"0.7964224",
"0... | 0.8079886 | 19 |
returns command type symbol | def command_type
case @current[0]
when '@'
:A_COMMAND
when '('
:L_COMMAND
else
:C_COMMAND
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commandType\n result = \"\"\n if (@currentCommand.slice(0) == \"@\")\n result = \"A_COMMAND\"\n else\n result = \"C_COMMAND\"\n end\n return result\n end",
"def command_type(incoming_line)\n @command_type_table[incoming_line]\n end",
"def command_... | [
"0.8014424",
"0.7763871",
"0.7710443",
"0.7617218",
"0.7597702",
"0.74332714",
"0.7419875",
"0.72326726",
"0.70791066",
"0.6975794",
"0.69689286",
"0.69679725",
"0.6949577",
"0.6936389",
"0.689275",
"0.6837259",
"0.68089455",
"0.6707803",
"0.6680114",
"0.6658172",
"0.66205776... | 0.7915181 | 1 |
returns symbol for destination mnemonic | def dest
if @current.include?(';')
:null
else
@current.split('=')[0].to_sym
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dest(mnemonic)\n if Code::DEST.has_key?(mnemonic)\n return Code::DEST[mnemonic]\n else\n return \"000\"\n end\n end",
"def target_symbol\n self.class.target_symbol\n end",
"def arp_dest_mac; self[:arp_dest_mac].to_s; end",
"def symbol\n # prefer a code display value since... | [
"0.7939173",
"0.6199612",
"0.61395955",
"0.61010605",
"0.61010605",
"0.5963927",
"0.59393907",
"0.59044725",
"0.59044725",
"0.59044725",
"0.59044725",
"0.59044725",
"0.59044725",
"0.5869301",
"0.5837566",
"0.5832607",
"0.58254546",
"0.58254546",
"0.58254546",
"0.5735934",
"0.... | 0.5758681 | 19 |
returns Ruby symbol for comp mnemonic | def comp
if @current.include?(';')
@current.split(';')[0].to_sym
else
@current.split('=')[1].to_sym
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def symbol\n # prefer a code display value since the state name may not be unique between modules\n if !@codes.nil? && !@codes.empty?\n @codes.first.display.gsub(/\\s+/, '_').downcase.to_sym\n else\n @name.gsub(/\\s+/, '_').downcase.to_sym\n end\n en... | [
"0.70492697",
"0.70492697",
"0.6980984",
"0.6806778",
"0.67961967",
"0.666276",
"0.666276",
"0.666276",
"0.666276",
"0.666276",
"0.666276",
"0.6643156",
"0.6595151",
"0.6585637",
"0.6476847",
"0.64651084",
"0.6442182",
"0.6442182",
"0.6442182",
"0.64411265",
"0.6437244",
"0... | 0.61969835 | 27 |
returns Ruby symbol for jump mnemonic | def jump
if @current.include?(';')
@current.split(';')[1].to_sym
else
:null
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jump(str)\n @@JUMP_TABLE[str]\n end",
"def jump(n)\n \t\"*Jump!* \" * 2\n end",
"def jump(_jump)\n j1 = '0'\n j2 = '0'\n j3 = '0'\n\n if (_jump == 'null')\n #Do nothing\n elsif (_jump == 'JGT')\n j3 = '1'\n elsif (_jump == 'JEQ')\n ... | [
"0.7352569",
"0.720308",
"0.7000008",
"0.65494466",
"0.646579",
"0.6379797",
"0.6275658",
"0.62401766",
"0.6187919",
"0.6177618",
"0.6177618",
"0.6177618",
"0.6177618",
"0.6177618",
"0.6177618",
"0.5966271",
"0.5943481",
"0.5884791",
"0.5860945",
"0.58536315",
"0.5852182",
... | 0.7096541 | 2 |
handles process for translating assembly code | def process
if command_type == :C_COMMAND
@c = Code.new([comp, dest, jump])
"#{@c.translate_c}\n"
else
@c = Code.new(@current[1..-1])
"#{@c.translate_a}\n"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process(code, context)\n compiler = Verneuil::Compiler.new\n program = compiler.compile(code)\n # p program\n Verneuil::Process.new(program, context)\nend",
"def post_process\n end",
"def post_process; end",
"def translate\n @actions.each do |a|\n self.send(:\"parse_#{a['type'].gsub('-','_... | [
"0.63653845",
"0.60001594",
"0.5977293",
"0.59651995",
"0.59178174",
"0.58814913",
"0.5869802",
"0.57572687",
"0.57572687",
"0.57572687",
"0.57572687",
"0.57572687",
"0.57572687",
"0.57572687",
"0.57572687",
"0.57225037",
"0.56978595",
"0.565815",
"0.56513375",
"0.5624473",
"... | 0.5806512 | 7 |
filters comments and deritus from input file | def filter
read = []
@file.each do |line|
line = line.strip
if !line[0].nil? && (line[0] != '/') # if line is not comment or blank append to output
line = line.split(' ')[0] # removes inline comments
read.append(line)
end
end
read
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_comments(file)\n @in_file = file.readlines\n @in_file.delete_if{|index| index.match(/^[\\/]{2}/) }\n end",
"def read_file_omitting_comments(input)\n return '' unless File.exist?(input)\n\n File.readlines(input).reject { |line| line =~ /^\\s*#/ }.join('')\n end",
"def parse_w... | [
"0.71484625",
"0.7141207",
"0.70814806",
"0.6888638",
"0.6759238",
"0.67544377",
"0.66955245",
"0.65969354",
"0.65542036",
"0.65534973",
"0.65534973",
"0.65534973",
"0.64414686",
"0.6376996",
"0.62714255",
"0.62557584",
"0.6226949",
"0.619526",
"0.61599946",
"0.6149997",
"0.6... | 0.7532115 | 0 |
top level symbol free translator | def process
out = ''
@filtered.each do |line|
p = Parser.new(line)
out += p.process
end
out
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def english_mapping(force=false)\n if force\n cyc.cycl_term_to_nl_string(self.to_sym)\n else\n super()\n end\n end",
"def symbol! sym\ninitialize\ns0 = new_state\ns1 = new_state\nset_start(s0)\nset_final(s1, true)\nadd_transition(s0, s1, sym)\nif sym != \"\" && @alphabet.include?(\"#{sym}\") ... | [
"0.6523623",
"0.607099",
"0.6069775",
"0.60045373",
"0.5979698",
"0.5964885",
"0.5964885",
"0.5964885",
"0.5964885",
"0.5964885",
"0.5964885",
"0.5964885",
"0.5964885",
"0.595908",
"0.59538233",
"0.593299",
"0.58567935",
"0.5848645",
"0.58460546",
"0.5839914",
"0.5839914",
... | 0.0 | -1 |
resolves all symbols to decimal values | def resolve_symbols
s = Symbols.new(@filtered)
pro = s.process_labels
@filtered = s.translate_symbols(pro)
process
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_invalid_chars(price)\n decimalised = price[/[.]/] ? price : \"0.\" + price \n decimalised.gsub(/[£p]/, '').to_f\nend",
"def get_currency_symbol\n \"€\"\n end",
"def extract_price(text)\n text.gsub('£', '').to_d\n end",
"def format_price(price)\n price.gsub!(\"€\",\"\")\n price.gsu... | [
"0.7012196",
"0.61915886",
"0.6115424",
"0.6040388",
"0.59937614",
"0.5972032",
"0.59450966",
"0.5929074",
"0.5916402",
"0.591208",
"0.58461344",
"0.58376104",
"0.5796581",
"0.5794261",
"0.5792454",
"0.5792454",
"0.5792454",
"0.5786127",
"0.5786127",
"0.57354033",
"0.5727591"... | 0.5209368 | 71 |
first pass of file to assign psudeocommands to rom addresses | def process_labels
line_add = 0
out = []
@file.each do |line| # if line is psudeocommand, add label to hashtable
if line[0] == '('
@st[line[1..-2].to_sym] = line_add
else
out.push(line) # only retain true commands
line_add += 1
end
end
out # file with all psuedocommands removed
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialise(loadfile)\n\n # Initialise steps\n\n phases = Phases.new\n $commands = Commands.new\n \n if $testing == 1\n require_relative 'Testing.rb'\n require_relative '../Extra/Parser.rb'\n end\n \n if $debugplay == 1\n $debug.debugplay\n end\n \n # Initia... | [
"0.5585988",
"0.54968184",
"0.5463191",
"0.5333857",
"0.5322591",
"0.52899426",
"0.5272748",
"0.5252742",
"0.52218556",
"0.5209943",
"0.5199942",
"0.51117617",
"0.50838333",
"0.508228",
"0.50721186",
"0.506765",
"0.50507295",
"0.5034488",
"0.5033393",
"0.50282854",
"0.5022587... | 0.53071314 | 5 |
symbol lookup and symbol table management. | def sym_lookup(line)
out = ''
if @st.key?(line[1..-1].to_sym) # if varible is already in table, replace with value
out = "@#{@st[line[1..-1].to_sym]}"
else
@st[line[1..-1].to_sym] = @sym_address # add variable to table with current free address
out = "@#{@sym_address}" # replace with value
@sym_address += 1 # increment address
end
out
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def symbolicate!\n return if @isSymbolicated\n buildgdbcommandfile\n gdbout = rungdb\n @symbols = []\n gdbout.lines.each do |l|\n @symbols << Symbolized.new(l)\n end\n \n addresses.each do |a|\n @symbols.each do |s|\n if s.startaddress && a >= s.startaddress && a <= s.enda... | [
"0.67613196",
"0.67070276",
"0.65420955",
"0.64751244",
"0.64426565",
"0.64110595",
"0.63489664",
"0.62966424",
"0.6283137",
"0.627993",
"0.6271085",
"0.62562704",
"0.6236987",
"0.6235383",
"0.62180173",
"0.6162789",
"0.6154651",
"0.6147257",
"0.6136577",
"0.61317027",
"0.611... | 0.6425225 | 5 |
translates symbols to decimal in assembly file | def translate_symbols(file)
out = []
file.each do |line|
if (line[0] == '@') && line[1] !~ /\d/ # if A instruction contains a variable
out.push sym_lookup(line) # evaluate to decimal value
else
out.push line # keep decimal value as is
end
end
out # file with all var translated to decimal
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dec2code dec\n out = ''\n while (dec>0)\n out << SYMBOLS[dec % SYMBOLS_LENGTH]\n dec = dec / SYMBOLS_LENGTH\n end\n out\n end",
"def convert_symbols(a)\n # find (labels) and add them to the symbol table and\n # reference the next line of code, then delete the\n # l... | [
"0.57983226",
"0.57550323",
"0.5696666",
"0.5675554",
"0.56150144",
"0.55710125",
"0.5463608",
"0.5427594",
"0.5274744",
"0.52663344",
"0.51766115",
"0.5172624",
"0.51228696",
"0.512146",
"0.5118851",
"0.5108068",
"0.5104325",
"0.50268507",
"0.5025477",
"0.5023675",
"0.502367... | 0.6963676 | 0 |
Returns the adspaceItems' ID as integer representation | def to_i
@adspace
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_i\n @id\n end",
"def to_i\n @id\n end",
"def to_i\n @id\n end",
"def to_i\n @id\n end",
"def to_i\n @data[:id].to_i\n end",
"def to_i\n @data[:id].to_i\n end",
"def item_id\n return @item_id\n end",
"def item_id\n ... | [
"0.67945343",
"0.67945343",
"0.67945343",
"0.67945343",
"0.6642898",
"0.6642898",
"0.6528138",
"0.6528138",
"0.6528138",
"0.6494478",
"0.63589454",
"0.6322765",
"0.6231471",
"0.621123",
"0.62110114",
"0.62110114",
"0.6210885",
"0.6192828",
"0.6192828",
"0.6192828",
"0.6169647... | 0.64939296 | 10 |
Use callbacks to share common setup or constraints between actions. | def set_email_notification
@email_notification = @current_user.email_notification
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 |
Construct a foreign path A foreign path will be used with a value as a foreign selection to filter a model with foreign conditions | def initialize(model, selection_path)
@model = model
@selection_path = selection_path.dup
@association_path = selection_path.to_s.split(RELATIONSHIP_SEPARATOR)
selection_path = @association_path.pop
@selected_field, @operator = selection_path.split(OPERATOR_SEPARATOR)
@operator ||= 'equal'
_initialize_associations
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path!\n model.dataset.select(:path).get_unfiltered_raw(id).try(:[], :path)\n end",
"def initialize(parent, model, relation_name, foreign_key)\n super(model)\n @parent, @relation_name, @foreign_key = parent, relation_name, foreign_key\n conditions.merge!(@foreign_key => @parent)\n... | [
"0.5698615",
"0.5681156",
"0.5603464",
"0.55629283",
"0.55033964",
"0.5430027",
"0.5421681",
"0.531998",
"0.53084856",
"0.53002846",
"0.5238391",
"0.5235642",
"0.5235639",
"0.5211151",
"0.51780885",
"0.51748484",
"0.51477474",
"0.5143006",
"0.51416683",
"0.51266307",
"0.51185... | 0.48681048 | 46 |
It generates JSON using Oj serializer dump method. | def render
Oj.dump(to_json)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render\n Oj.dump(to_json)\n end",
"def to_json\n Oj.dump(to_hash)\n end",
"def serialize\n JSON.generate(to_h)\n end",
"def tojson\n\t\tend",
"def json_serialize\n end",
"def to_json\n @object.marshal_dump.to_json\n end",
"def to_json\n\t\tto_h.to_json\n\tend",
"d... | [
"0.75944746",
"0.7517921",
"0.73334366",
"0.7269353",
"0.72535264",
"0.7218276",
"0.71495837",
"0.71495837",
"0.7145622",
"0.7136411",
"0.7123903",
"0.71163017",
"0.7094965",
"0.70732987",
"0.69926566",
"0.69872504",
"0.6972174",
"0.6972174",
"0.6967357",
"0.6965688",
"0.6956... | 0.74371976 | 2 |
Fetch an item matching a given selector, and advance its state as determined by opts[:from] and opts[:to]. | def fetch_item(item_selector, opts)
query = item_selector.merge({:state => opts[:from]})
physical_item = @inventory.find_and_modify(:query => query,
:update => {'$set' => {:state => opts[:to], :add_time => Time.now}})
physical_item['_id']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch(opts)\n @opts.merge!(opts)\n ofx_req = build_query(opts[:type] || @opts[:type])\n do_query(ofx_req)\n end",
"def find(selector, opts={})\n itemFields = %{\n id\n updated\n title\n published\n abstract\n authors { nodes { name } }\n contributors { ... | [
"0.5804423",
"0.53254485",
"0.5297536",
"0.5215969",
"0.519743",
"0.5119374",
"0.50704426",
"0.50612473",
"0.50227195",
"0.50063574",
"0.49378568",
"0.4905207",
"0.49016437",
"0.48685294",
"0.4864081",
"0.48462716",
"0.4819145",
"0.48178604",
"0.48093507",
"0.48045737",
"0.47... | 0.69322497 | 0 |
Take a list of items added to an order, remove them, and the mark them as available. | def rollback(order_id, item_ids, old_state, new_state)
@orders.update({"_id" => order_id}, {"$pullAll" => {:item_ids => item_ids}})
item_ids.each do |id|
@inventory.find_and_modify(:query => {"_id" => id, :state => new_state},
:update => {"$set" => {:state => old_state, :add_time => nil}})
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_items(item, grocery_list)\n grocery_list.delete(item)\nend",
"def test_remove_promotion_multiple_items\n setup_new_order_with_items()\n editable_order_codes = (1..5)\n editable_order_codes.each do |status_id|\n o_status = OrderStatusCode.find(status_id)\n assert_kind_of OrderStatus... | [
"0.62479997",
"0.6235408",
"0.62233895",
"0.62152827",
"0.6147756",
"0.60910463",
"0.60576284",
"0.60576284",
"0.603442",
"0.60149044",
"0.5998231",
"0.5993208",
"0.59653264",
"0.5951653",
"0.5950167",
"0.5943333",
"0.59425426",
"0.5932523",
"0.59302944",
"0.5930037",
"0.5928... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.