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 |
|---|---|---|---|---|---|---|
Capture allows you to extract a part of the template into an instance variable. You can use this instance variable anywhere in your templates and even in your layout. Example of capture being used in a .herb page: | def capture(*args, &block)
# execute the block
begin
buffer = _buffer( block.binding )
rescue
buffer = nil
end
if buffer.nil?
capture_block(*args, &block)
else
capture_erb_with_buffer(buffer, *args, &block)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capture_from_template(*args, &block)\n self.output_buffer, _buf_was = \"\", self.output_buffer\n block.call(*args)\n ret = eval(\"@_out_buf\", block.binding)\n self.output_buffer = _buf_was\n ret\n end",
"def outer_capture(name, &block)\n #outer_view... | [
"0.66225857",
"0.6576994",
"0.65436095",
"0.6476463",
"0.6458712",
"0.620453",
"0.6141573",
"0.6098326",
"0.6088958",
"0.6084088",
"0.6046803",
"0.6023333",
"0.59849346",
"0.59539026",
"0.59404546",
"0.59367067",
"0.59027493",
"0.58447546",
"0.5820834",
"0.57488894",
"0.57473... | 0.56846726 | 21 |
overwrite this if you want to restrict access to only a few actions or if you want to check if the user has the correct rights example: only allow nonbobs def authorize?(user) user.login != "bob" end | def authorize?(_user)
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorize?(user)\n user && user.admin?\n end",
"def authorize?(user)\n true\n end",
"def authorize_user\n # simple authorization: kick out anonymous users from backend actions\n=begin\n if !current_user\n redirect_back_or_default(home_page) and return if action_name =~ /index|edit|upda... | [
"0.7913009",
"0.7873954",
"0.78349763",
"0.7801072",
"0.7645746",
"0.76129156",
"0.7597708",
"0.7596591",
"0.7592467",
"0.7585231",
"0.7560869",
"0.7560869",
"0.7551699",
"0.7475028",
"0.7463103",
"0.7443293",
"0.74278873",
"0.7411455",
"0.7411455",
"0.7411455",
"0.7411455",
... | 0.76896983 | 5 |
overwrite this method if you only want to protect certain actions of the controller example: don't protect the login and the about method def protect?(action) if ['action', 'about'].include?(action) return false else return true end end | def protect?(_action)
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def protect?(action)\n true\n end",
"def protect?(action)\n true\n end",
"def protect?(action)\n true\n end",
"def protect?(action)\n true\n end",
"def protect?(action)\n\t\ttrue\n\tend",
"def protect?(action)\n if ['login', 'signup', 'forgot_password'].include?(action)\n return f... | [
"0.8739489",
"0.8739489",
"0.8739489",
"0.8739489",
"0.8690509",
"0.859242",
"0.85438293",
"0.8368204",
"0.76225376",
"0.75355864",
"0.7384361",
"0.737991",
"0.73704153",
"0.7272443",
"0.7256734",
"0.71596515",
"0.713514",
"0.7120971",
"0.71082383",
"0.70501727",
"0.6972552",... | 0.8500154 | 8 |
login_required filter. add before_filter :login_required if the controller should be under any rights management. for finer access control you can overwrite def authorize?(user) | def login_required
return true unless protect?(action_name)
return true if user? && authorize?(session[:user])
# store current location so that we can
# come back after the user logged in
store_location
# call overwriteable reaction to unauthorized access
access_denied
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorize\n\t\tredirect_to '/login' unless current_user\n\tend",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n ... | [
"0.84650934",
"0.84080493",
"0.834458",
"0.8279834",
"0.8279834",
"0.8279834",
"0.8279834",
"0.8279834",
"0.8279834",
"0.8279834",
"0.8279834",
"0.8263244",
"0.82615757",
"0.8065285",
"0.8014279",
"0.80029434",
"0.7988257",
"0.79669994",
"0.7952756",
"0.7924652",
"0.7919369",... | 0.74128854 | 83 |
overwrite if you want to have special behavior in case the user is not authorized to access the current operation. the default action is to redirect to the login screen example use : a popup window might just close itself for instance | def access_denied
redirect_to controller: :users, action: :login
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login_popup\n session[:redirect_to_after_auth] = request.env['HTTP_REFERER']\n @login_form = LoginForm.new\n render :layout => \"blank\"\n end",
"def access_denied\n if @current_user\n render_401\n else\n redirect_to \"#{FUSESOURCE_URL}/login?return_to=#{external_url_to(request.requ... | [
"0.7049999",
"0.6924754",
"0.68786156",
"0.682282",
"0.6822572",
"0.6798174",
"0.67942536",
"0.6722108",
"0.67161083",
"0.67039895",
"0.6686108",
"0.66739297",
"0.6672799",
"0.6664577",
"0.6649029",
"0.66464686",
"0.6644109",
"0.66400594",
"0.663848",
"0.66259694",
"0.6623866... | 0.6725401 | 7 |
store current uri in the session. we can return to this location by calling return_location | def store_location
session['return-to'] = request.path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_location\n session[:return_to] = request.uri\n end",
"def store_location\n session[:return_to] = request.uri\n end",
"def store_location\n @session['return-to'] = @request.request_uri\n end",
"def store_location\n session[:return_to] = request.uri\n end",
"def ... | [
"0.84859025",
"0.8452036",
"0.8307692",
"0.82998973",
"0.8294753",
"0.8277763",
"0.8275724",
"0.82436717",
"0.82436717",
"0.82436717",
"0.82436717",
"0.82436717",
"0.82436717",
"0.82436717",
"0.8226129",
"0.81758904",
"0.817441",
"0.81406766",
"0.81406766",
"0.81406766",
"0.8... | 0.7901175 | 54 |
move to the last store_location call or to the passed default one | def redirect_back_or_default(default)
if session['return-to'].nil?
redirect_to default
else
redirect_to session['return-to']
session['return-to'] = nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore_location_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end",
"def redirect_back_or_default(default)\n redirect_to(pop_stored_location || default)\n end",
"def redirect_back_or_default(default)\n redirect_to(pop_stored_location || de... | [
"0.6953538",
"0.66228604",
"0.6615493",
"0.65199715",
"0.6452603",
"0.6350237",
"0.62600046",
"0.6196609",
"0.59864557",
"0.5919099",
"0.5915261",
"0.5905633",
"0.5897334",
"0.5845272",
"0.5811599",
"0.5797905",
"0.57930934",
"0.57930934",
"0.5764554",
"0.5764554",
"0.5740249... | 0.0 | -1 |
RFC4253 binary encoding of the public key. Returns a binary String. | def rfc4253
Encoding.encode_fields(
[:string, algo],
[:string, curve],
[:string, public_key_bytes],
[:string, application],
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_key\n # Base64 encode without line feeds\n Base64.strict_encode64(public_key_raw)\n end",
"def public_key_string\n [@public_key.to_s].pack(\"m*\").gsub(\"\\n\", \"\")\n end",
"def to_bytes\n @public_key\n end",
"def public_key\n encode64(curve.public_k... | [
"0.8180586",
"0.81357014",
"0.7845042",
"0.77406955",
"0.7406421",
"0.73196983",
"0.7288139",
"0.71725535",
"0.71725535",
"0.71259993",
"0.7067954",
"0.6993845",
"0.6970687",
"0.69563526",
"0.6947875",
"0.6939008",
"0.69184375",
"0.6863845",
"0.6823057",
"0.681676",
"0.674261... | 0.69643956 | 13 |
List of cars that a specific owner has | def cars
Car.all.select do |car|
car.car_owner == self
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cars\n Car.all.select {|c| c.owner == self}\n end",
"def cars\n Car.all.select { |car| car.car_owner == self }\n end",
"def owners\n self.cars.map{|car_instance| car_instance.owner}.uniq\n end",
"def all_cars\n Car.all.select do |car|\n car.owner == self\n end\n end",
"def my_... | [
"0.8111532",
"0.80976945",
"0.8077089",
"0.7950167",
"0.77198523",
"0.7597562",
"0.7549161",
"0.7412827",
"0.73435915",
"0.7328681",
"0.72770405",
"0.7105773",
"0.70313156",
"0.67837054",
"0.66382337",
"0.6619986",
"0.6601279",
"0.65381664",
"0.6434895",
"0.6423385",
"0.64233... | 0.8030087 | 3 |
list of all the mechanics that a specific owner goes to | def mechanics
self.cars.map do |car|
car.mechanic
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def owners_of_cars_serviced\n self.personal_mechanic_of.map{|owner_obj| owner_obj.name}\nend",
"def mechanics\n Mechanic.all.select{|mechanic|mechanic.specialty == self.classification}\n end",
"def personal_mechanic_of\n self.cars_serviced.map{|car| car.car_owner}\nend",
"def mechanics\n cars.map {|... | [
"0.6779603",
"0.6447505",
"0.6446004",
"0.62982714",
"0.6145239",
"0.61106086",
"0.60359746",
"0.5989723",
"0.597637",
"0.59735656",
"0.5939915",
"0.5860003",
"0.58308184",
"0.57709897",
"0.5769922",
"0.57079107",
"0.56801367",
"0.56497157",
"0.56417274",
"0.5640623",
"0.5637... | 0.5989565 | 8 |
The uniq +id+ of Threat. | def id(i = false)
return @id if i == false
@id = i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_id\n object_id.abs.to_s(16)\n end",
"def uniqid\n SecureRandom.hex(32)\n end",
"def uniqid\n SecureRandom.hex(32)\n end",
"def id() end",
"def id; 1; end",
"def unique_id #:nodoc:\n @unique_id = (@unique_id || 0) + 1\n end",
"def unique_id\n \"#{@tabl... | [
"0.6841131",
"0.6830288",
"0.6830288",
"0.6801679",
"0.6794175",
"0.6692612",
"0.667802",
"0.6676625",
"0.6663543",
"0.66525966",
"0.66157156",
"0.66151357",
"0.6604113",
"0.65872306",
"0.6573971",
"0.65575397",
"0.65488577",
"0.65079665",
"0.65063167",
"0.64999807",
"0.64644... | 0.0 | -1 |
Creates a list of all securities whose data is available at the CSCS site and writes the list to a CSV file | def securities
doc = Nokogiri::HTML(open(SECURITIES_LIST_URL))
CSV.open(SECURITIES_CSV, 'wb') do |csv|
csv << ["Symbol", "Name"]
doc.css('option').each do |node|
symbol = node['value']
name = node.content.strip
next if name.blank?
csv << [symbol, name]
end
end
puts "wrote securites list to #{SECURITIES_CSV}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process\n csv_to_securities\n output_securities\n end",
"def csv_to_securities\n CSV.foreach(file, col_sep: '|') do |row|\n growth_period = max_growth_period(row[2])\n securities << {name: row[0], symbol: row[1], growth: growth(growth_period[:chunk]), percentages: growth_period[:chunk], d... | [
"0.6892135",
"0.64617985",
"0.6370871",
"0.63354486",
"0.625626",
"0.616756",
"0.6155434",
"0.61411375",
"0.61243796",
"0.60894084",
"0.603169",
"0.60189056",
"0.5995852",
"0.59861916",
"0.59820557",
"0.5977463",
"0.59592074",
"0.59527594",
"0.5939055",
"0.5898658",
"0.586976... | 0.7696606 | 0 |
Fetches historical price data for a single security. Case insensitive. | def price_history(symbol)
uri = URI(PRICE_HISTORY_URL)
res = Net::HTTP.post_form(uri, 'Symbol' => symbol)
html_history = Pathname(__FILE__).join("..", "..", "raw", "#{symbol}-pricehistory.html")
csv_history = Pathname(__FILE__).join("..", "..", "price", "#{symbol.downcase}.csv")
File.open(html_history, 'w') do |f|
f.write res.body
end
first_line = true
CSV.open(csv_history, 'wb') do |csv|
doc = Nokogiri::HTML(open(html_history))
doc.css('.displayTable tr').each do |tr|
if first_line
first_line = false
next
end
tds = tr.css('td').map(&:text)
csv << tds
end
csv << ["Date", "Close", "Open"]
end
temp_file = Pathname(__FILE__).join("..","..","raw","rev")
`tac #{csv_history} > #{temp_file} && cat #{temp_file} > #{csv_history}`
throw `could not reverse file` unless $? == 0
puts "wrote #{symbol} prices to #{csv_history}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def market_data\n endpoint = \"#{HOST}/v1/cryptocurrency/listings/latest\"\n get(endpoint)\n end",
"def latest_market_data\n cryptsy = Cryptsy::API::Client.new\n # TODO: I need exception handling here because\n # when cryptsy fails to respond to my request, \n # it causes the program to crash.... | [
"0.59198064",
"0.5899886",
"0.5685197",
"0.5685197",
"0.56229275",
"0.5605949",
"0.5484749",
"0.54763585",
"0.54263735",
"0.54200244",
"0.541042",
"0.54077",
"0.5389224",
"0.5347694",
"0.53347397",
"0.5313515",
"0.53111166",
"0.5289264",
"0.5283505",
"0.52787596",
"0.5274268"... | 0.0 | -1 |
GET /git_hub_accounts GET /git_hub_accounts.json | def index
@git_hub_accounts = GitHubAccount.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def social_accounts_for_a_project\n uri = \"#{@api_url}/#{@project_id}/accounts?access_token=#{@access_token}\"\n get uri\n end",
"def list_accounts\n HTTP.headers(:accept => @@accept).basic_auth(:user => ENV[\"API_USERNAME\"], :pass => ENV[\"API_PASSWORD\"])\n .get(\"#{@@base_url}/users/#{self.guid... | [
"0.72475946",
"0.7183663",
"0.7085941",
"0.7065189",
"0.6592239",
"0.65557265",
"0.65470034",
"0.64849067",
"0.6433112",
"0.64226514",
"0.64226514",
"0.6371161",
"0.6336721",
"0.63341355",
"0.62801224",
"0.62502885",
"0.6215116",
"0.62005436",
"0.6169974",
"0.61428094",
"0.61... | 0.7667698 | 0 |
GET /git_hub_accounts/1 GET /git_hub_accounts/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @git_hub_accounts = GitHubAccount.all\n end",
"def social_accounts_for_a_project\n uri = \"#{@api_url}/#{@project_id}/accounts?access_token=#{@access_token}\"\n get uri\n end",
"def list_accounts\n HTTP.headers(:accept => @@accept).basic_auth(:user => ENV[\"API_USERNAME\"], :pass => E... | [
"0.7330723",
"0.7027974",
"0.6829566",
"0.6756432",
"0.6746607",
"0.6613153",
"0.6582691",
"0.64242345",
"0.64099777",
"0.63721204",
"0.63721204",
"0.6277911",
"0.6244605",
"0.622611",
"0.62088126",
"0.62056386",
"0.6128936",
"0.6128188",
"0.6119497",
"0.6112001",
"0.6103147"... | 0.0 | -1 |
POST /git_hub_accounts POST /git_hub_accounts.json | def create
@git_hub_account = GitHubAccount.new(git_hub_account_params)
respond_to do |format|
if @git_hub_account.save
format.html { redirect_to @git_hub_account, notice: 'Git hub account was successfully created.' }
format.json { render :show, status: :created, location: @git_hub_account }
else
format.html { render :new }
format.json { render json: @git_hub_account.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n megam_rest.post_accounts(to_hash)\n end",
"def create_account\n unless authenticated?\n payload = encode( { :user => { :github_account => github_user } } )\n response = site['users.json'].post payload, :content_type => :json\n !response.nil?\n end\n end",
... | [
"0.70106983",
"0.6693332",
"0.66851413",
"0.6485045",
"0.63097775",
"0.62466717",
"0.6178254",
"0.601136",
"0.60006094",
"0.5977357",
"0.59711695",
"0.5918652",
"0.5913381",
"0.5884085",
"0.58681846",
"0.58422697",
"0.58385473",
"0.5834355",
"0.58221996",
"0.58199316",
"0.580... | 0.7365121 | 0 |
PATCH/PUT /git_hub_accounts/1 PATCH/PUT /git_hub_accounts/1.json | def update
respond_to do |format|
if @git_hub_account.update(git_hub_account_params)
format.html { redirect_to @git_hub_account, notice: 'Git hub account was successfully updated.' }
format.json { render :show, status: :ok, location: @git_hub_account }
else
format.html { render :edit }
format.json { render json: @git_hub_account.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{arg... | [
"0.64008665",
"0.6331505",
"0.6243914",
"0.6243914",
"0.6214345",
"0.61832714",
"0.61608803",
"0.6087791",
"0.60874164",
"0.6071628",
"0.5965184",
"0.5943581",
"0.593131",
"0.59123033",
"0.59123033",
"0.59075767",
"0.589002",
"0.5881495",
"0.5879934",
"0.584358",
"0.5840226",... | 0.6967796 | 0 |
DELETE /git_hub_accounts/1 DELETE /git_hub_accounts/1.json | def destroy
@git_hub_account.destroy
respond_to do |format|
format.html { redirect_to git_hub_accounts_url, notice: 'Git hub account was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_account\n @connection.request({\n :method => 'DELETE'\n }) \n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @git_hub_repo.destroy\n respond_to do |format|\n format.h... | [
"0.69192773",
"0.6889097",
"0.68113285",
"0.68068105",
"0.67776823",
"0.6698914",
"0.66471183",
"0.66297776",
"0.6561531",
"0.6515462",
"0.64417374",
"0.641845",
"0.64025825",
"0.64022315",
"0.6375246",
"0.6366884",
"0.63426626",
"0.63280404",
"0.63279504",
"0.63234305",
"0.6... | 0.7738173 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_git_hub_account
@git_hub_account = GitHubAccount.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.61637366",
"0.60446453",
"0.59452957",
"0.591511",
"0.58885515",
"0.5834122",
"0.57761765",
"0.5702554",
"0.5702554",
"0.5652102",
"0.5619581",
"0.5423898",
"0.5409782",
"0.5409782",
"0.5409782",
"0.5394745",
"0.53780794",
"0.5356209",
"0.5338898",
"0.53381324",
"0.5328622... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def git_hub_account_params
params.require(:git_hub_account).permit(:oauth, :user_id, :state)
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.69780594",
"0.678054",
"0.6742781",
"0.67387927",
"0.67346025",
"0.6590683",
"0.6501642",
"0.6495788",
"0.6479752",
"0.64763314",
"0.645457",
"0.6437739",
"0.6377168",
"0.6372484",
"0.6363871",
"0.63179374",
"0.62981373",
"0.6297456",
"0.62916917",
"0.6290227",
"0.628954",... | 0.0 | -1 |
GET /site_options GET /site_options.json | def index
@site_options = SiteOption.page params[:page]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n \n load_options\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @options }\n end\n end",
"def get_options; end",
"def show\n option = Option.find_by domain: params[:shop]\n add_cors_headers\n render json: {option: op... | [
"0.67797995",
"0.64889205",
"0.6476725",
"0.64064956",
"0.63673234",
"0.6305824",
"0.62550074",
"0.6212719",
"0.61968917",
"0.6175441",
"0.6162154",
"0.6157858",
"0.61312324",
"0.61312324",
"0.61312324",
"0.61312324",
"0.61312324",
"0.61311567",
"0.60909057",
"0.60874486",
"0... | 0.68772197 | 0 |
GET /site_options/1 GET /site_options/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @site_options = SiteOption.page params[:page]\n end",
"def index\n \n load_options\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @options }\n end\n end",
"def show\n option = Option.find_by domain: params[:shop]\n ... | [
"0.67548496",
"0.6647049",
"0.6537527",
"0.6428299",
"0.63132375",
"0.62737644",
"0.6234558",
"0.6207041",
"0.6207041",
"0.6207041",
"0.6207041",
"0.6207041",
"0.6147521",
"0.6105493",
"0.6105425",
"0.6091439",
"0.60862714",
"0.6073987",
"0.6013751",
"0.6004823",
"0.60017115"... | 0.0 | -1 |
POST /site_options POST /site_options.json | def create
@site_option = SiteOption.new(site_option_params)
respond_to do |format|
if @site_option.save
format.html { redirect_to @site_option, notice: 'Site option was successfully created.' }
format.json { render :show, status: :created, location: @site_option }
else
format.html { render :new }
format.json { render json: @site_option.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def site_option_params\n params.require(:site_option).permit(:key, :value)\n end",
"def set_site_option\n @site_option = SiteOption.find(params[:id])\n end",
"def site_setting_params\n params.require(:site_setting).permit(:api_key, :key, :value, :section)\n end",
"def update\n resp... | [
"0.71661717",
"0.60355175",
"0.5920063",
"0.59008116",
"0.5880804",
"0.5787656",
"0.57770056",
"0.5743637",
"0.57208055",
"0.57089794",
"0.5699894",
"0.56843215",
"0.56512046",
"0.56244344",
"0.56217563",
"0.5619964",
"0.55922467",
"0.5591797",
"0.55810463",
"0.55725694",
"0.... | 0.7129474 | 1 |
PATCH/PUT /site_options/1 PATCH/PUT /site_options/1.json | def update
respond_to do |format|
if @site_option.update(site_option_params)
format.html { redirect_to @site_option, notice: 'Site option was successfully updated.' }
format.json { render :show, status: :ok, location: @site_option }
else
format.html { render :edit }
format.json { render json: @site_option.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put_update(options = {})\n options[:id] ||= @website.id\n options[:website] ||= @attributes\n\n put :update,options\n end",
"def update\n respond_to do |format|\n if @option.update(option_params)\n format.html { redirect_to @option, notice: 'Option was successfully updated.' }\n ... | [
"0.65404874",
"0.6347837",
"0.6347837",
"0.6347837",
"0.6326963",
"0.6313514",
"0.6312925",
"0.62752265",
"0.6270044",
"0.6223684",
"0.6221114",
"0.62066907",
"0.61895543",
"0.61385566",
"0.61370564",
"0.61157537",
"0.6108254",
"0.6108254",
"0.6091407",
"0.608557",
"0.6080082... | 0.7358336 | 0 |
DELETE /site_options/1 DELETE /site_options/1.json | def destroy
@site_option.destroy
respond_to do |format|
format.html { redirect_to site_options_url, notice: 'Site option was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @option = Option.find(params[:id])\n @option.destroy\n\n respond_to do |format|\n format.html { redirect_to options_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @option = Option.find(params[:id])\n @option.destroy\n\n respond_to do |format|\n... | [
"0.69684345",
"0.69684345",
"0.6915845",
"0.68266886",
"0.68266886",
"0.68266886",
"0.6722619",
"0.6714879",
"0.671233",
"0.66763663",
"0.6671023",
"0.66495323",
"0.6645642",
"0.6637474",
"0.66220176",
"0.6614891",
"0.66142863",
"0.66067547",
"0.65976673",
"0.6588616",
"0.657... | 0.76084745 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_site_option
@site_option = SiteOption.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 site_option_params
params.require(:site_option).permit(:key, :value)
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.69780594",
"0.678054",
"0.6742781",
"0.67387927",
"0.67346025",
"0.6590683",
"0.6501642",
"0.6495788",
"0.6479752",
"0.64763314",
"0.645457",
"0.6437739",
"0.6377168",
"0.6372484",
"0.6363871",
"0.63179374",
"0.62981373",
"0.6297456",
"0.62916917",
"0.6290227",
"0.628954",... | 0.0 | -1 |
Creates a new instace of Haml::Engine that will compile the given template string when render is called. See README for available options. When adding options, remember to add information about them to README! ++ | def initialize(template, options = {})
@options = {
:suppress_eval => false,
:attr_wrapper => "'",
:locals => {},
:autoclose => ['meta', 'img', 'link', 'script', 'br', 'hr'],
:filters => {
'sass' => Sass::Engine,
'plain' => Haml::Filters::Plain,
'preserve' => Haml::Filters::Preserve }
}
if !NOT_LOADED.include? 'redcloth'
@options[:filters].merge!({
'redcloth' => RedCloth,
'textile' => Haml::Filters::Textile,
'markdown' => Haml::Filters::Markdown
})
end
if !NOT_LOADED.include? 'bluecloth'
@options[:filters]['markdown'] = Haml::Filters::Markdown
end
@options.rec_merge! options
unless @options[:suppress_eval]
@options[:filters].merge!({
'erb' => ERB,
'ruby' => Haml::Filters::Ruby
})
end
@options[:filters].rec_merge! options[:filters] if options[:filters]
@precompiled = @options[:precompiled]
@template = template.strip #String
@to_close_stack = []
@output_tabs = 0
@template_tabs = 0
@index = 0
# This is the base tabulation of the currently active
# flattened block. -1 signifies that there is no such block.
@flat_spaces = -1
begin
# Only do the first round of pre-compiling if we really need to.
# They might be passing in the precompiled string.
do_precompile if @precompiled.nil? && (@precompiled = String.new)
rescue Haml::Error => e
e.add_backtrace_entry(@index, @options[:filename])
raise e
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render(html, options={})\n require \"haml\" unless defined? Haml\n Haml::Engine.new(html, options).render\nend",
"def engine_for(string, options = {}) #:nodoc:\n ERB::Engine.new(string, :filename => options[:filename])\n end",
"def initialize_engine\n require_template_library 'haml_coffe... | [
"0.69729686",
"0.651563",
"0.6509544",
"0.6409629",
"0.630058",
"0.630058",
"0.626652",
"0.6248283",
"0.6157806",
"0.615253",
"0.61245763",
"0.6122389",
"0.60709286",
"0.60359865",
"0.58955634",
"0.5870721",
"0.5843179",
"0.58269066",
"0.58142525",
"0.58075684",
"0.57337636",... | 0.7253111 | 0 |
Processes the template and returns the result as a string. | def render(scope = Object.new, &block)
@scope_object = scope
@buffer = Haml::Buffer.new(@options)
local_assigns = @options[:locals]
# Get inside the view object's world
@scope_object.instance_eval do
# Set all the local assigns
local_assigns.each do |key,val|
self.class.send(:define_method, key) { val }
end
end
# Compile the @precompiled buffer
compile &block
# Return the result string
@buffer.buffer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_template(template)\n @dlogger.debug \"Processing template #{template} for file #{@file}\"\n # The '-' arg allows folks to use <% -%> or <%- -%> to instruct ERB to\n # not insert a newline for that line, which helps avoid a bunch of blank\n # lines in the processed file where there was code ... | [
"0.71331054",
"0.71229565",
"0.70446223",
"0.70446223",
"0.69180226",
"0.69126296",
"0.680027",
"0.67977244",
"0.670304",
"0.6698221",
"0.6656174",
"0.6640755",
"0.6622332",
"0.660274",
"0.65878296",
"0.65452635",
"0.65354955",
"0.6514634",
"0.64951897",
"0.64919287",
"0.6490... | 0.0 | -1 |
Processes and deals with lowering indentation. | def process_indent(count, line)
if count <= @template_tabs && @template_tabs > 0
to_close = @template_tabs - count
to_close.times do |i|
offset = to_close - 1 - i
unless offset == 0 && mid_block_keyword?(line)
close
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indentation; end",
"def indentation; end",
"def process_current_level\n @previous_level = @current_level * 1\n leading_whitespace = self.class.get_leading_whitespace_from_text @text\n if leading_whitespace == \"\"\n @current_level = 0\n \n # If there is leading whitespace but indent_tok... | [
"0.72355",
"0.72355",
"0.6948815",
"0.66114366",
"0.66114366",
"0.66114366",
"0.66114366",
"0.66114366",
"0.6508558",
"0.64841306",
"0.6446463",
"0.63954324",
"0.62700516",
"0.6263764",
"0.6261392",
"0.6248822",
"0.62078506",
"0.6139988",
"0.61314905",
"0.61252093",
"0.610450... | 0.5728608 | 42 |
Processes a single line of Haml. This method doesn't return anything; it simply processes the line and | def process_line(line, index, block_opened)
@index = index + 1
@block_opened = block_opened
case line[0]
when DIV_CLASS, DIV_ID
render_div(line)
when ELEMENT
render_tag(line)
when COMMENT
render_comment(line)
when SCRIPT
sub_line = line[1..-1]
if sub_line[0] == SCRIPT
push_script(sub_line[1..-1].strip.dump.gsub('\\#', '#'), false)
else
push_script(sub_line, false)
end
when FLAT_SCRIPT
warn(FLAT_WARNING) unless defined?(Test::Unit)
push_flat_script(line[1..-1])
when SILENT_SCRIPT
sub_line = line[1..-1]
unless sub_line[0] == SILENT_COMMENT
mbk = mid_block_keyword?(line)
push_silent(sub_line, !mbk)
if (@block_opened && !mbk) || line[1..-1].split(' ', 2)[0] == "case"
push_and_tabulate([:script])
end
end
when FILTER
name = line[1..-1].downcase
start_filtered(options[:filters][name] || name)
when DOCTYPE
if line[0...3] == '!!!'
render_doctype(line)
else
push_plain line
end
when ESCAPE
push_plain line[1..-1]
else
push_plain line
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_line(text, index)\n @index = index + 1\n\n case text[0]\n when DIV_CLASS; render_div(text)\n when DIV_ID\n return push_plain(text) if text[1] == ?{\n render_div(text)\n when ELEMENT; render_tag(text)\n when COMMENT; render_comment(text[1..-1].strip)\n wh... | [
"0.66866916",
"0.6371857",
"0.63340217",
"0.6311449",
"0.6162634",
"0.6099818",
"0.6096381",
"0.60699666",
"0.6062567",
"0.5990351",
"0.59317875",
"0.5925609",
"0.58602667",
"0.5804123",
"0.5796832",
"0.57924",
"0.5766928",
"0.56948787",
"0.5677734",
"0.56652325",
"0.56640947... | 0.59178966 | 12 |
Returns whether or not the line is a silent script line with one of Ruby's midblock keywords. | def mid_block_keyword?(line)
line.length > 2 && line[0] == SILENT_SCRIPT && MID_BLOCK_KEYWORDS.include?(line[1..-1].split[0])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mid_block_keyword?(text)\n text[MID_BLOCK_KEYWORD_REGEX, 1]\n end",
"def multiline_kspawn? line\n if @kspawn_multiline\n @kspawn[:text] << line\n if line.include?(\"~\")\n @kspawn_multiline = false\n # However nothing but whitespace can follow that tilde!\n validate_... | [
"0.71664965",
"0.62384915",
"0.61926043",
"0.6038193",
"0.5996653",
"0.59807503",
"0.59342927",
"0.5914263",
"0.5871068",
"0.5843907",
"0.58161455",
"0.5737429",
"0.5660754",
"0.56392163",
"0.55896443",
"0.5573804",
"0.5571034",
"0.54868287",
"0.54152566",
"0.5364381",
"0.535... | 0.81454504 | 0 |
Deals with all the logic of figuring out whether a given line is the beginning, continuation, or end of a multiline sequence. This returns whether or not the line should be rendered normally. | def handle_multiline(count, line, index)
suppress_render = false
# Multilines are denoting by ending with a `|` (124)
if is_multiline?(line) && @multiline_buffer
# A multiline string is active, and is being continued
@multiline_buffer += line[0...-1]
suppress_render = true
elsif is_multiline?(line) && (MULTILINE_STARTERS.include? line[0])
# A multiline string has just been activated, start adding the lines
@multiline_buffer = line[0...-1]
@multiline_count = count
@multiline_index = index
process_indent(count, line)
suppress_render = true
elsif @multiline_buffer
# A multiline string has just ended, make line into the result
unless line.empty?
process_line(@multiline_buffer, @multiline_index, count > @multiline_count)
@multiline_buffer = nil
end
end
return suppress_render
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_multiline?(line) # ' '[0] == 32\n line && line.length > 1 && line[-1] == MULTILINE_CHAR_VALUE && line[-2] == 32\n end",
"def is_continuing_line?(line)\n line.expunge =~ /^[^#]*\\\\\\s*(#.*)?$/\n #first use expunge to eliminate inline closures\n #th... | [
"0.71779305",
"0.7170381",
"0.71383476",
"0.69160855",
"0.6878952",
"0.67792785",
"0.67317754",
"0.67087305",
"0.6650737",
"0.6636308",
"0.6582096",
"0.6582096",
"0.65816474",
"0.6580231",
"0.65592915",
"0.65592587",
"0.6495358",
"0.64484686",
"0.63894767",
"0.63748693",
"0.6... | 0.6028672 | 42 |
Checks whether or not +line+ is in a multiline sequence. | def is_multiline?(line) # ' '[0] == 32
line && line.length > 1 && line[-1] == MULTILINE_CHAR_VALUE && line[-2] == 32
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_line?(line)\n end",
"def is_multiline?\n @code =~ /\\n/\n end",
"def hasline?(line)\n\t\tlines.include?(line)\n\tend",
"def multiline?(node)\n node.multiline? && !allowed_multiline_argument?(node)\n end",
"def multiline?(node); end",
"def is_multiline?(text)\n text && t... | [
"0.74378026",
"0.73967206",
"0.7265395",
"0.72243714",
"0.7201628",
"0.702526",
"0.6691634",
"0.6682373",
"0.66731364",
"0.6638963",
"0.659111",
"0.6511659",
"0.6453622",
"0.644961",
"0.6393159",
"0.6382578",
"0.63365144",
"0.63322836",
"0.6331418",
"0.6331418",
"0.6303721",
... | 0.8116655 | 0 |
Renders a block of text as plain text. Also checks for an illegally opened block. | def push_plain(text)
if @block_opened
raise SyntaxError.new("Illegal Nesting: Nesting within plain text is illegal.")
end
push_text text
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text_block(text)\n h(text).gsub(/\\n/, '<br/>').html_safe\n end",
"def guard_text( text )\n # todo/fix 2: note we need to differentiate between blocks and inline\n # thus, to avoid runs - use guard_block (add a leading newline to avoid getting include in block that goes before)\n \n #... | [
"0.6933479",
"0.6345912",
"0.6283119",
"0.59790367",
"0.5870202",
"0.57793903",
"0.57793903",
"0.5680058",
"0.56651706",
"0.5662044",
"0.56446624",
"0.56310827",
"0.56254303",
"0.56011015",
"0.55785584",
"0.55431235",
"0.5532853",
"0.55262274",
"0.55258405",
"0.5521732",
"0.5... | 0.5678747 | 8 |
Causes text to be evaluated in the context of | def push_script(text, flattened)
unless options[:suppress_eval]
push_silent("haml_temp = #{text}", true)
out = "haml_temp = _hamlout.push_script(haml_temp, #{@output_tabs}, #{flattened})\n"
if @block_opened
push_and_tabulate([:loud, out])
else
@precompiled << out
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def guard_text( text )\n # todo/fix 2: note we need to differentiate between blocks and inline\n # thus, to avoid runs - use guard_block (add a leading newline to avoid getting include in block that goes before)\n \n # todo/fix: remove wrap_markup; replace w/ guard_text\n # why: text might be cs... | [
"0.6703125",
"0.64729875",
"0.6394591",
"0.6370468",
"0.6221134",
"0.60974795",
"0.605928",
"0.60579985",
"0.60202324",
"0.60125774",
"0.5941613",
"0.5892254",
"0.5889658",
"0.5837285",
"0.5832771",
"0.5829251",
"0.58164066",
"0.5800361",
"0.5790664",
"0.5784453",
"0.57589066... | 0.53845084 | 64 |
Causes text to be evaluated, and Haml::Helpersfind_and_flatten to be run on it afterwards. | def push_flat_script(text)
unless text.empty?
push_script(text, true)
else
unless @block_opened
raise SyntaxError.new('Filters must have nested text.')
end
start_flat(false)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_script(text, flattened)\n unless options[:suppress_eval]\n push_silent(\"haml_temp = #{text}\", true)\n out = \"haml_temp = _hamlout.push_script(haml_temp, #{@output_tabs}, #{flattened})\\n\"\n if @block_opened\n push_and_tabulate([:loud, out])\n else\n @... | [
"0.64501137",
"0.63002247",
"0.62489784",
"0.6005252",
"0.596188",
"0.5889307",
"0.5871147",
"0.5860163",
"0.58411336",
"0.5760531",
"0.5733684",
"0.56631017",
"0.55841964",
"0.5583739",
"0.5578642",
"0.5571282",
"0.5501445",
"0.5486324",
"0.5467103",
"0.5453275",
"0.5447904"... | 0.5375784 | 27 |
Closes a Ruby block. | def close_block
push_silent "end"
@template_tabs -= 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close( &block )\n compile!( :close!, &block )\n end",
"def close\n if !block_given?\n return @j_del.java_method(:close, []).call()\n end\n raise ArgumentError, \"Invalid arguments when calling close()\"\n end",
"def close\n if !block_given?\n return @j_d... | [
"0.81262",
"0.6873272",
"0.6873272",
"0.6873272",
"0.6788309",
"0.66180015",
"0.6501231",
"0.64997464",
"0.6482776",
"0.64688987",
"0.63957846",
"0.6365916",
"0.6283044",
"0.6227082",
"0.61157036",
"0.60545677",
"0.60503143",
"0.6018441",
"0.60027874",
"0.595364",
"0.595364",... | 0.6830456 | 4 |
Closes a flattened section. | def close_flat(in_tag)
@flat_spaces = -1
if in_tag
close
else
push_silent('_hamlout.stop_flat')
@template_tabs -= 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_section\n end",
"def close\n unless @is_closed || @anchors.length <= 2 then\n @sections << Section.new( @anchors.last,\n @anchors.first )\n\n @is_closed = true\n\n balance_last_anchor\n balance_first_anchor\n\n @length += @secti... | [
"0.63031733",
"0.61084735",
"0.5951489",
"0.5777545",
"0.5659706",
"0.5640892",
"0.56124604",
"0.5545891",
"0.5399016",
"0.5338929",
"0.5320356",
"0.52603024",
"0.52589905",
"0.52585536",
"0.525513",
"0.5216814",
"0.5172355",
"0.5162089",
"0.51515067",
"0.51311356",
"0.512182... | 0.626808 | 1 |
Closes a loud Ruby block. | def close_loud(command)
push_silent 'end'
@precompiled << command
@template_tabs -= 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close( &block )\n compile!( :close!, &block )\n end",
"def close_block\n push_silent \"end\"\n @template_tabs -= 1\n end",
"def autoclose_open_blocks_and_return\n ( rslt = close_block; chain rslt; pipe_2_variable ) while @head.size > 1\n return close_block\n end",
"def... | [
"0.78774107",
"0.7050745",
"0.6999576",
"0.68757516",
"0.6743511",
"0.65358675",
"0.65294015",
"0.6528676",
"0.6509287",
"0.6482596",
"0.64213896",
"0.6404929",
"0.6399863",
"0.6399863",
"0.6399863",
"0.637883",
"0.6371598",
"0.6336938",
"0.6331138",
"0.63190514",
"0.63094705... | 0.0 | -1 |
Closes a filtered block. | def close_filtered(filter)
@flat_spaces = -1
if filter.is_a? String
if filter == 'redcloth' || filter == 'markdown' || filter == 'textile'
raise HamlError.new("You must have the RedCloth gem installed to use #{filter}")
else
raise HamlError.new("Filter \"#{filter}\" is not defined!")
end
else
filtered = filter.new(@filter_buffer).render
unless filter == Haml::Filters::Preserve
push_text(filtered.rstrip.gsub("\n", "\n#{' ' * @output_tabs}"))
else
push_silent("_hamlout.buffer << #{filtered.dump} << \"\\n\"\n")
end
end
@filter_buffer = nil
@template_tabs -= 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_filtered(filter)\n filter.internal_compile(self, @filter_buffer)\n @flat = false\n @flat_spaces = nil\n @filter_buffer = nil\n @template_tabs -= 1\n end",
"def close( &block )\n compile!( :close!, &block )\n end",
"def close(buffer = \"\")\n re... | [
"0.7155363",
"0.6831974",
"0.6410868",
"0.61975116",
"0.61324805",
"0.5969622",
"0.59511644",
"0.5903915",
"0.5857694",
"0.5717808",
"0.566644",
"0.55566216",
"0.5547245",
"0.5472479",
"0.5456408",
"0.54315585",
"0.54052246",
"0.5402685",
"0.5395234",
"0.53869987",
"0.5380892... | 0.7142367 | 1 |
Parses a line that will render as an XHTML tag, and adds the code that will | def render_tag(line)
matched = false
line.scan(TAG_REGEX) do |tag_name, attributes, attributes_hash, object_ref, action, value|
matched = true
value = value.to_s.strip
case action
when '/'
atomic = true
when '=', '~'
parse = true
end
flattened = (action == '~')
warn(FLAT_WARNING) if flattened && !defined?(Test::Unit)
value_exists = !value.empty?
attributes_hash = "{nil}" if attributes_hash.nil? || @options[:suppress_eval]
object_ref = "nil" unless object_ref
if !attributes.empty? && '.#'.include?(attributes)
raise SyntaxError.new("Illegal element: classes and ids must have values. Use %div instead.")
end
if @block_opened
if atomic
raise SyntaxError.new("Illegal Nesting: Nesting within an atomic tag is illegal.")
elsif action == '=' || value_exists
raise SyntaxError.new("Illegal Nesting: Nesting within a tag that already has content is illegal.")
end
elsif atomic && value_exists
raise SyntaxError.new("Atomic tags can't have content.")
elsif parse && !value_exists
raise SyntaxError.new("No tag content to parse.")
end
if !@block_opened && !value_exists && !atomic && @options[:autoclose].include?(tag_name)
atomic = true
end
push_silent "_hamlout.open_tag(#{tag_name.inspect}, #{@output_tabs}, #{atomic.inspect}, #{value_exists.inspect}, #{attributes.inspect}, #{object_ref}, #{flattened.inspect}, #{attributes_hash[1...-1]})", true
unless atomic
push_and_tabulate([:element, tag_name])
@output_tabs += 1
if value_exists
if parse
push_script(value, flattened)
else
push_text(value)
end
close
elsif flattened
start_flat(true)
end
end
end
unless matched
raise SyntaxError.new("Invalid tag: \"#{line}\"")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_next_line\n @line_starts_with_tick = false\n @self_closing = false\n @inner_text = nil\n \n line = \"\"\n \n if @text[\"\\n\"] != nil\n line_break_index = @text.index \"\\n\"\n line = @text[0..line_break_index].strip\n @text = @text[line_break_index+1..-1]\n else\... | [
"0.64749706",
"0.64696074",
"0.63828695",
"0.63318014",
"0.6166421",
"0.60901386",
"0.60091233",
"0.5963275",
"0.5938371",
"0.59117115",
"0.58381355",
"0.58269465",
"0.5791088",
"0.5788106",
"0.5783602",
"0.5775907",
"0.57649666",
"0.5748609",
"0.5725134",
"0.5721816",
"0.568... | 0.62073547 | 4 |
Renders a line that creates an XHTML tag and has an implicit div because of . or . | def render_div(line)
render_tag('%div' + line)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_template(ul = 'unmarked', ur = 'unmarked', ll = 'unmarked', lr = 'unmarked')\n html = <<-eol\n <div class=\"fam-tree-line-container\">\n <div class=\"fam-tree-line-level\">\n <div class=\"fam-tree-#{ul}\"></div>\n <div class=\"fam-tree-#{ur}\"></div>\n #{clear}\n </div... | [
"0.6406736",
"0.6185538",
"0.6000912",
"0.59898984",
"0.59598356",
"0.59598356",
"0.5945666",
"0.59105486",
"0.59042203",
"0.5849481",
"0.5833329",
"0.5790682",
"0.5744301",
"0.5728771",
"0.5721635",
"0.57168335",
"0.57168335",
"0.57168335",
"0.56972003",
"0.56892806",
"0.568... | 0.7438915 | 1 |
Renders an XHTML comment. | def render_comment(line)
conditional, content = line.scan(COMMENT_REGEX)[0]
content.strip!
if @block_opened && !content.empty?
raise SyntaxError.new('Illegal Nesting: Nesting within a tag that already has content is illegal.')
end
try_one_line = !content.empty?
push_silent "_hamlout.open_comment(#{try_one_line}, #{conditional.inspect}, #{@output_tabs})"
@output_tabs += 1
push_and_tabulate([:comment, !conditional.nil?])
if try_one_line
push_text content
close
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comment(text)\n @xml << \"<!-- #{text} -->\"\n nil\n end",
"def comment(text)\n @out << \"<!-- #{text} -->\"\n nil\n end",
"def comment(text)\n@out << \"<!-- #{text} -->\"\nnil\nend",
"def render_comment(line)\n conditional, line = balance(line, ?[, ?]) if line[0] == ?[\n line.str... | [
"0.6972211",
"0.68353784",
"0.664606",
"0.65648526",
"0.6547957",
"0.6442048",
"0.643657",
"0.6405185",
"0.6359052",
"0.63429844",
"0.6300855",
"0.6300855",
"0.6300855",
"0.6300855",
"0.6279409",
"0.6221752",
"0.61423546",
"0.61423546",
"0.61423546",
"0.61423546",
"0.61423546... | 0.6480621 | 5 |
Renders an XHTML doctype or XML shebang. | def render_doctype(line)
if @block_opened
raise SyntaxError.new("Illegal Nesting: Nesting within a header command is illegal.")
end
line = line[3..-1].lstrip.downcase
if line[0...3] == "xml"
encoding = line.split[1] || "utf-8"
wrapper = @options[:attr_wrapper]
doctype = "<?xml version=#{wrapper}1.0#{wrapper} encoding=#{wrapper}#{encoding}#{wrapper} ?>"
else
version, type = line.scan(DOCTYPE_REGEX)[0]
if version == "1.1"
doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'
else
case type
when "strict"
doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
when "frameset"
doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">'
else
doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
end
end
end
push_text doctype
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doctype_\n start_ht5\n ht5 << \"<!DOCTYPE html>\"\n end",
"def doctype\n %|<!DOCTYPE HTML>|\n end",
"def html( attrs = {}, &block )\n @buffer << \"<!DOCTYPE html>\"\n @buffer << \"\\n\" if @pretty_print\n make( :html, attrs, &block )\n flush\n end",
"def head(*args, &... | [
"0.610117",
"0.5895817",
"0.58681273",
"0.5742302",
"0.5681844",
"0.56803715",
"0.5539289",
"0.53681093",
"0.53409433",
"0.53409433",
"0.53409433",
"0.53409433",
"0.53184855",
"0.53126806",
"0.52829826",
"0.52577454",
"0.52441955",
"0.5242432",
"0.5242432",
"0.51993805",
"0.5... | 0.66253597 | 0 |
Starts a flattened block. | def start_flat(in_tag)
# @flat_spaces is the number of indentations in the template
# that forms the base of the flattened area
if in_tag
@to_close_stack.push([:flat, true])
else
push_and_tabulate([:flat])
end
@flat_spaces = @template_tabs * 2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_new_block\n if (@block_buffer)\n add_block(@block_buffer)\n @block_buffer = nil\n end\n end",
"def begin_layer(&block)\n @p.begin_layer(self, &block)\n end",
"def start &block\n @actions[:start] = block\n end",
"def start(&block)\n @start_ti... | [
"0.62154305",
"0.59506047",
"0.5815491",
"0.5722676",
"0.56598663",
"0.5651165",
"0.563346",
"0.5628483",
"0.55713767",
"0.55536234",
"0.5445379",
"0.5252914",
"0.5249737",
"0.5239238",
"0.52259207",
"0.5213327",
"0.5209124",
"0.5205721",
"0.51810944",
"0.51809585",
"0.518095... | 0.64052606 | 0 |
Starts a filtered block. | def start_filtered(filter)
unless @block_opened
raise SyntaxError.new('Filters must have nested text.')
end
push_and_tabulate([:filtered, filter])
@flat_spaces = @template_tabs * 2
@filter_buffer = String.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def block\n @grpc.block_all_filter = true\n self\n end",
"def start_filtered(name)\n raise Error.new(\"Invalid filter name \\\":#{name}\\\".\") unless name =~ /^\\w+$/\n raise Error.new(\"Filter \\\"#{name}\\\" is not defined.\") unless filter = Filters.defined[name]\n\n ... | [
"0.6802673",
"0.6730879",
"0.66814655",
"0.667944",
"0.6628093",
"0.65755785",
"0.6474184",
"0.64119947",
"0.6330326",
"0.6297295",
"0.6280994",
"0.6198957",
"0.6159172",
"0.6106006",
"0.60810095",
"0.60590965",
"0.6044604",
"0.604053",
"0.60251623",
"0.6012176",
"0.6000157",... | 0.75100034 | 0 |
Counts the tabulation of a line. | def count_soft_tabs(line)
spaces = line.index(/[^ ]/)
if line[spaces] == ?\t
return nil if line.strip.empty?
raise SyntaxError.new("Illegal Indentation: Only two space characters are allowed as tabulation.")
end
[spaces, spaces/2]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_level line\n line.match(/^[ \\t]*/)[0].gsub(\"\\t\", \" \").split('').length\n end",
"def count_soft_tabs(line)\n line.index(/[^ ]/) ? [line.index(/[^ ]/)/2, line.strip] : []\n end",
"def line_count\n\t\tlines.size\n\tend",
"def line_count\n\t\tlines.size\n\tend",
"def num_lines() ... | [
"0.72603583",
"0.6999758",
"0.6513321",
"0.6513321",
"0.6344724",
"0.61746013",
"0.6169395",
"0.613988",
"0.60478956",
"0.60365224",
"0.5986871",
"0.59785765",
"0.5971224",
"0.5927795",
"0.59226066",
"0.5906097",
"0.58279824",
"0.5818224",
"0.5811349",
"0.5799142",
"0.577276"... | 0.66758645 | 2 |
method that prints out the argument to the terminal | def print_all(f)
puts f.read
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def puts! args, label=\"\"\n puts \"+++ +++ #{label}\"\n puts args.inspect\nend",
"def puts! arg, label=''\n puts \"+++ +++ #{label}\"\n puts arg.inspect\nend",
"def show(arg)\n print (\"Result = #{arg.s}\\n\")\nend",
"def out(*args) print(*(args + [\"\\r\\n\"])) end",
"def print( *args )\n @outp... | [
"0.7871603",
"0.7828742",
"0.7728306",
"0.75692385",
"0.75633645",
"0.75238246",
"0.73615056",
"0.7307732",
"0.72779447",
"0.72758114",
"0.7260827",
"0.71741325",
"0.71265155",
"0.7117185",
"0.7115838",
"0.71084774",
"0.71084774",
"0.71084774",
"0.71084774",
"0.70983136",
"0.... | 0.0 | -1 |
This method looks for the first byte in a file. This method resets reading the file abck to the start hence why its called rewind | def rewind(f)
f.seek(0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rewind(f)\n # '.seek()' command moves to the start of the file\n f.seek(0)\nend",
"def rewind(f)\n f.seek(0) # .seek looks for an indexed part of the file, could use any number to place within a file.\nend",
"def rewind(f)\n #seeks for f at line 0\n f.seek(0)\n end",
"def rewind(f)\n# takes... | [
"0.6934228",
"0.68449765",
"0.68206036",
"0.682019",
"0.6814964",
"0.68133754",
"0.6795899",
"0.67820597",
"0.67820597",
"0.67654973",
"0.6760251",
"0.675386",
"0.675386",
"0.675386",
"0.675386",
"0.675386",
"0.675386",
"0.675386",
"0.67499745",
"0.67391676",
"0.6738217",
"... | 0.662894 | 58 |
Prints the chosen line and the number associated with that line | def print_a_line(line_count, f)
puts "#{line_count}, #{f.gets.chomp}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line(number); end",
"def line(number)\n end",
"def line\n 1\n end",
"def line(line_no)\n @line[line_no]\n end",
"def line(line_no)\n @line[line_no]\n end",
"def line(line_no)\n @line[line_no]\n end",
"def line(line_no)\n @line[line_no]\n end",
"def lin... | [
"0.7196311",
"0.7121682",
"0.70219505",
"0.6858044",
"0.6858044",
"0.6858044",
"0.6858044",
"0.6858044",
"0.6848208",
"0.6835228",
"0.680446",
"0.680446",
"0.680446",
"0.6789636",
"0.6764275",
"0.67321104",
"0.6717161",
"0.67062086",
"0.66870147",
"0.66870147",
"0.66711015",
... | 0.6595908 | 31 |
find the sum of the evenvalued terms. | def fibonacci
results, first, second, current = 0, 1, 2, 2
while current <= 4000000
if current % 2 == 0
results += current
end
current = first + second
first, second = second, current
end
return results
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_even\n sum = 0\n @even_array.each do |i|\n sum += i\n end\n sum\n end",
"def sum_even(nums)\n nums.select { |n| n.even? }.inject(&:+)\nend",
"def sum_even_odd(fake_num); end",
"def sum_of_even(input_array)\n\teven_array = []\n\tinput_array.each do |number|\n\t\tif number%2 == 0\n\t... | [
"0.7657528",
"0.7544075",
"0.75307095",
"0.74591076",
"0.7304176",
"0.70708805",
"0.6990866",
"0.69372034",
"0.6868805",
"0.6843829",
"0.6830816",
"0.6812766",
"0.6783919",
"0.6774539",
"0.67728573",
"0.67728573",
"0.67664397",
"0.67096823",
"0.6686934",
"0.66814333",
"0.6680... | 0.0 | -1 |
Show all of the locations | def index
locations = Location.all
render json: locations
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_locations\n query = create_query(:Location, :all, by: default_sort_order)\n show_selected_locations(query, link_all_sorts: true)\n end",
"def list_locations # :nologin:\n query = create_query(:Location, :all, :by => :name)\n show_selected_locations(query, :link_all_sorts => true)\n end",
... | [
"0.8073052",
"0.79951644",
"0.7629181",
"0.7629181",
"0.7629181",
"0.7629181",
"0.7629181",
"0.7629181",
"0.7629181",
"0.7629181",
"0.7629181",
"0.7629181",
"0.7629181",
"0.7623318",
"0.7581821",
"0.75382096",
"0.753507",
"0.7451105",
"0.7385957",
"0.73480463",
"0.7344098",
... | 0.66711104 | 87 |
GET /diets/1 GET /diets/1.json | def show
render json: @diet, status: 200, root: true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @diets = @profile.diets\n respond_with @diets\n end",
"def food_info(food_id)\n get(\"/foods/#{food_id}.json\")\n end",
"def show\n @pet = Pet.find_by(id: params[:id])\n if @pet\n render json: @pet\n else\n render json: {}, status: 404\n end\n end",
"def show... | [
"0.6809462",
"0.6443195",
"0.6392288",
"0.63914454",
"0.6274971",
"0.6200679",
"0.6199658",
"0.6172385",
"0.61719906",
"0.6168654",
"0.6165466",
"0.61487067",
"0.6147363",
"0.6121893",
"0.6112091",
"0.60837597",
"0.6072198",
"0.606658",
"0.606658",
"0.6051755",
"0.60480267",
... | 0.6462713 | 1 |
POST /diets POST /diets.json | def create
@diet = Diet.new(diet_params)
@diet.user = @current_user
if @diet.save
render json: @diet, status: 201, location: @diet, root: true
else
render json: @diet.errors, status: 422
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @diet = Diet.new(diet_params)\n\n respond_to do |format|\n if @diet.save\n format.html { redirect_to @diet, notice: 'Diet was successfully created.' }\n format.json { render :show, status: :created, location: @diet }\n else\n format.html { render :new }\n fo... | [
"0.6174128",
"0.6057072",
"0.592708",
"0.5796898",
"0.57808834",
"0.5715972",
"0.5695065",
"0.56903356",
"0.56558675",
"0.5601649",
"0.55391276",
"0.5533135",
"0.55088323",
"0.54840845",
"0.5483884",
"0.5482134",
"0.54554623",
"0.5433978",
"0.5419214",
"0.5407438",
"0.5392576... | 0.6232623 | 0 |
PATCH/PUT /diets/1 PATCH/PUT /diets/1.json | def update
if @diet.update(diet_params)
head :no_content, status: 204
else
render json: @diet.errors, status: 422
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 patch!\n request! :patch\n end",
"def api_patch(path, data = {}... | [
"0.657433",
"0.64232934",
"0.63656986",
"0.62525153",
"0.6227839",
"0.61822045",
"0.6158356",
"0.6145381",
"0.6128327",
"0.61066717",
"0.61028403",
"0.6093343",
"0.6093142",
"0.6070152",
"0.6057754",
"0.6037865",
"0.6027722",
"0.60166204",
"0.5994965",
"0.59912056",
"0.597379... | 0.658604 | 0 |
DELETE /diets/1 DELETE /diets/1.json | def destroy
if @diet.destroy
head :no_content, status: 200
else
render json: @diet.errors, status: 405
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @diet.destroy\n respond_to do |format|\n format.html { redirect_to diets_url, notice: 'Diet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete endpoint\n do_request :delete, e... | [
"0.73800695",
"0.70304716",
"0.7023228",
"0.69931316",
"0.6978811",
"0.6936874",
"0.69289565",
"0.69211626",
"0.6916709",
"0.6885735",
"0.68365943",
"0.68249744",
"0.68140674",
"0.67767507",
"0.67536867",
"0.6733729",
"0.6728393",
"0.6725041",
"0.67066985",
"0.6703846",
"0.66... | 0.70303583 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_diet
@diet = Diet.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 diet_params
params.require(:diet).permit(:name, :comment, :diet_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.69780594",
"0.678054",
"0.6742781",
"0.67387927",
"0.67346025",
"0.6590683",
"0.6501642",
"0.6495788",
"0.6479752",
"0.64763314",
"0.645457",
"0.6437739",
"0.6377168",
"0.6372484",
"0.6363871",
"0.63179374",
"0.62981373",
"0.6297456",
"0.62916917",
"0.6290227",
"0.628954",... | 0.0 | -1 |
if test? is true so is development? | def test?
RUBYMOTION_ENV == 'test'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test?\n true\n end",
"def test?\n !production?\n end",
"def dev_or_test?\n development? || test?\n end",
"def testing?\n !!@test\n end",
"def test?\n false\n end",
"def test?\n @test\n end",
"def test?\n @@mode == :test\n end",
"def deve... | [
"0.7904451",
"0.7765098",
"0.7602",
"0.7587526",
"0.75404954",
"0.74705064",
"0.7370158",
"0.7326433",
"0.72781295",
"0.72280794",
"0.72036743",
"0.7202601",
"0.71508205",
"0.70939636",
"0.7038367",
"0.7020719",
"0.69983506",
"0.69678164",
"0.69669396",
"0.69457144",
"0.69390... | 0.7029024 | 15 |
Show invalid properties with the reasons. Usually used together with valid? | def list_invalid_properties
invalid_properties = Array.new
return invalid_properties
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil.... | [
"0.76497203",
"0.76497203",
"0.76497203",
"0.76497203",
"0.7637422",
"0.7637422",
"0.7637422",
"0.7637422",
"0.7637422",
"0.7637422",
"0.7637422",
"0.7637422",
"0.7356452",
"0.7334807",
"0.72685325",
"0.7238964",
"0.7231359",
"0.72258264",
"0.7208294",
"0.71760833",
"0.717024... | 0.0 | -1 |
Check to see if the all the properties in the model are valid | def valid?
status_validator = EnumAttributeValidator.new('String', ["ACTIVE", "INACTIVE"])
return false unless status_validator.valid?(@status)
country_validator = EnumAttributeValidator.new('String', ["ZZ", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW"])
return false unless country_validator.valid?(@country)
currency_validator = EnumAttributeValidator.new('String', ["UNKNOWN_CURRENCY", "AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BOV", "BRL", "BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLF", "CLP", "CNY", "COP", "COU", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LVL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MUR", "MVR", "MWK", "MXN", "MXV", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "SSP", "STD", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "USN", "USS", "UYI", "UYU", "UZS", "VEF", "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XOF", "XPD", "XPF", "XPT", "XTS", "XXX", "YER", "ZAR", "ZMK", "ZMW", "BTC"])
return false unless currency_validator.valid?(@currency)
type_validator = EnumAttributeValidator.new('String', ["PHYSICAL", "MOBILE"])
return false unless type_validator.valid?(@type)
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_properties\n true\n end",
"def validate_properties\n true\n end",
"def validate\n super\n\n check_optional_property :collection, String\n check_optional_property :create, String\n check_optional_property :delete, String\n check_optional_property :... | [
"0.78992486",
"0.78992486",
"0.70971805",
"0.70782334",
"0.7032205",
"0.7031276",
"0.69510347",
"0.6869891",
"0.6858077",
"0.6858077",
"0.68287027",
"0.6823878",
"0.6820306",
"0.68144894",
"0.6794656",
"0.6752167",
"0.66843414",
"0.6676546",
"0.6667755",
"0.66296124",
"0.6618... | 0.0 | -1 |
Custom attribute writer method checking allowed values (enum). | def status=(status)
validator = EnumAttributeValidator.new('String', ["ACTIVE", "INACTIVE"])
unless validator.valid?(status)
fail ArgumentError, "invalid value for 'status', must be one of #{validator.allowable_values}."
end
@status = status
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_attribute_with_enum(attr, value)\n write_attribute_without_enum attr, converted_enum(attr, value)\n end",
"def attr_enum(name, enum, options={}, &block)\n raise ArgumentError, 'enum' unless enum && enum.respond_to?(:values)\n\n options = {\n :enum => enum,\n ... | [
"0.708665",
"0.64815474",
"0.6430428",
"0.62273705",
"0.6143358",
"0.5810546",
"0.5751798",
"0.57437557",
"0.5736785",
"0.5708007",
"0.57005537",
"0.56784636",
"0.5604504",
"0.55957437",
"0.55478054",
"0.5540019",
"0.55362576",
"0.5528979",
"0.54357195",
"0.5430939",
"0.54195... | 0.0 | -1 |
Custom attribute writer method checking allowed values (enum). | def country=(country)
validator = EnumAttributeValidator.new('String', ["ZZ", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW"])
unless validator.valid?(country)
fail ArgumentError, "invalid value for 'country', must be one of #{validator.allowable_values}."
end
@country = country
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_attribute_with_enum(attr, value)\n write_attribute_without_enum attr, converted_enum(attr, value)\n end",
"def attr_enum(name, enum, options={}, &block)\n raise ArgumentError, 'enum' unless enum && enum.respond_to?(:values)\n\n options = {\n :enum => enum,\n ... | [
"0.708665",
"0.64815474",
"0.6430428",
"0.62273705",
"0.6143358",
"0.5810546",
"0.5751798",
"0.57437557",
"0.5736785",
"0.5708007",
"0.57005537",
"0.5604504",
"0.55957437",
"0.55478054",
"0.5540019",
"0.55362576",
"0.5528979",
"0.54357195",
"0.5430939",
"0.54195267",
"0.53817... | 0.56784636 | 11 |
Custom attribute writer method checking allowed values (enum). | def currency=(currency)
validator = EnumAttributeValidator.new('String', ["UNKNOWN_CURRENCY", "AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BOV", "BRL", "BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLF", "CLP", "CNY", "COP", "COU", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LVL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MUR", "MVR", "MWK", "MXN", "MXV", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "SSP", "STD", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "USN", "USS", "UYI", "UYU", "UZS", "VEF", "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XOF", "XPD", "XPF", "XPT", "XTS", "XXX", "YER", "ZAR", "ZMK", "ZMW", "BTC"])
unless validator.valid?(currency)
fail ArgumentError, "invalid value for 'currency', must be one of #{validator.allowable_values}."
end
@currency = currency
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_attribute_with_enum(attr, value)\n write_attribute_without_enum attr, converted_enum(attr, value)\n end",
"def attr_enum(name, enum, options={}, &block)\n raise ArgumentError, 'enum' unless enum && enum.respond_to?(:values)\n\n options = {\n :enum => enum,\n ... | [
"0.7088127",
"0.64820594",
"0.6429773",
"0.6227689",
"0.61418885",
"0.5809922",
"0.57507086",
"0.5743216",
"0.5736045",
"0.5708027",
"0.57014966",
"0.56777334",
"0.5601988",
"0.55947953",
"0.55464065",
"0.55371004",
"0.55344343",
"0.5528221",
"0.5434983",
"0.54312384",
"0.541... | 0.52683413 | 34 |
Custom attribute writer method checking allowed values (enum). | def type=(type)
validator = EnumAttributeValidator.new('String', ["PHYSICAL", "MOBILE"])
unless validator.valid?(type)
fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
end
@type = type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_attribute_with_enum(attr, value)\n write_attribute_without_enum attr, converted_enum(attr, value)\n end",
"def attr_enum(name, enum, options={}, &block)\n raise ArgumentError, 'enum' unless enum && enum.respond_to?(:values)\n\n options = {\n :enum => enum,\n ... | [
"0.7088127",
"0.64820594",
"0.6429773",
"0.6227689",
"0.61418885",
"0.5809922",
"0.57507086",
"0.5743216",
"0.5736045",
"0.5708027",
"0.57014966",
"0.56777334",
"0.5601988",
"0.55947953",
"0.55464065",
"0.55371004",
"0.55344343",
"0.5528221",
"0.5434983",
"0.54312384",
"0.541... | 0.0 | -1 |
Checks equality by comparing each attribute. | def ==(o)
return true if self.equal?(o)
self.class == o.class &&
id == o.id &&
name == o.name &&
address == o.address &&
timezone == o.timezone &&
capabilities == o.capabilities &&
status == o.status &&
created_at == o.created_at &&
merchant_id == o.merchant_id &&
country == o.country &&
language_code == o.language_code &&
currency == o.currency &&
phone_number == o.phone_number &&
business_name == o.business_name &&
type == o.type &&
website_url == o.website_url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other)\n attributes == other.attributes\n end",
"def ==(other) # :nodoc:\n @attrs == other.attrs\n end",
"def eql?(other)\n return true if self == other\n @@ATTRIBUTES.each do |att|\n return false unless self.send(att).eql?(other.send(att))\n end\n true\n en... | [
"0.72932124",
"0.7189842",
"0.70406866",
"0.7007727",
"0.68881786",
"0.68621296",
"0.67085785",
"0.66622394",
"0.661674",
"0.6586541",
"0.65844727",
"0.65818226",
"0.65561724",
"0.6545535",
"0.6508076",
"0.64813215",
"0.64577025",
"0.64179385",
"0.6414028",
"0.6414028",
"0.64... | 0.0 | -1 |
Calculates hash code according to all attributes. | def hash
[id, name, address, timezone, capabilities, status, created_at, merchant_id, country, language_code, currency, phone_number, business_name, type, website_url].hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash\n code = 17\n code = 37*code + @x.hash\n code = 37*code + @y.hash\n ... | [
"0.7120726",
"0.7038658",
"0.7038658",
"0.7038658",
"0.7038658",
"0.7038658",
"0.7038658",
"0.7038658",
"0.6894208",
"0.6783233",
"0.670583",
"0.66984636",
"0.6687399",
"0.6668047",
"0.64878535",
"0.6460521",
"0.6460521",
"0.6443962",
"0.641047",
"0.63965374",
"0.63888764",
... | 0.0 | -1 |
Builds the object from hash | def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.swagger_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build(hash)\n obj = new\n hash.each_pair do |k,v|\n obj[k] = v if variables[k]\n end\n return obj\n end",
"def build_from_hash(attributes)\n\n end",
"def build_from_hash(hash)\n instance = self.new\n\n # Add the instance attributes dynamically ... | [
"0.8011074",
"0.7470833",
"0.7457607",
"0.7256629",
"0.72455454",
"0.70060325",
"0.6973257",
"0.6955014",
"0.69459796",
"0.69398683",
"0.69363195",
"0.6917627",
"0.6872358",
"0.6796184",
"0.6783521",
"0.67575246",
"0.67575246",
"0.67560464",
"0.67514306",
"0.67136854",
"0.666... | 0.0 | -1 |
Deserializes the data based on type | def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :BOOLEAN
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
temp_model = SquareConnect.const_get(type).new
temp_model.build_from_hash(value)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s... | [
"0.7330926",
"0.7274019",
"0.72504056",
"0.7245751",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
... | 0.0 | -1 |
Returns the string representation of the object | def to_s
to_hash.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n @object.to_s\n end",
"def to_s\n object.to_s\n end",
"def serialize(object)\n object.to_s\n end",
"def to_s\n self.inspect\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"de... | [
"0.9010481",
"0.8950689",
"0.84703803",
"0.8340893",
"0.83363867",
"0.83363867",
"0.8331558",
"0.82545733",
"0.81452745",
"0.814375",
"0.8135387",
"0.8126432",
"0.80925727",
"0.8086306",
"0.80725205",
"0.803857",
"0.8030969",
"0.80052185",
"0.80052185",
"0.80052185",
"0.80052... | 0.0 | -1 |
to_body is an alias to to_hash (backward compatibility) | def to_body
to_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_body\r\n to_hash\r\n end",
"def to_body\n to_hash\nend",
"def to_body\n to_hash\nend"
] | [
"0.8428728",
"0.83457416",
"0.83457416"
] | 0.0 | -1 |
Returns the object in the form of hash | def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hash\n object\n end",
"def hash\r\n return to_s.hash\r\n end",
"def hash\n to_a.hash\n end",
"def hash\n [_hash, name, owner].hash\n end",
"def hash\n return to_s.hash\n end",
"def hash\n @hash\n end",
"def hash\n @hash.hash\n end",
"def hash\n ... | [
"0.8270299",
"0.78767854",
"0.78726953",
"0.7802364",
"0.7789188",
"0.77806795",
"0.7775915",
"0.7767511",
"0.7760525",
"0.7760525",
"0.77559966",
"0.7731286",
"0.7713916",
"0.7713916",
"0.7713916",
"0.7713916",
"0.7713916",
"0.7713916",
"0.7713916",
"0.7713916",
"0.7713916",... | 0.0 | -1 |
Outputs nonarray value in the form of hash For object, use to_hash. Otherwise, just return the value | def _to_hash(value)
if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n [value].hash\n end",
"def hash\n [value].hash\n end",
"def hash\n\t\tvalue.hash\n\tend",
"def hash\n value.hash\n end",
"def hash\n @value.hash\n end",
"def hash\r\n return to_s.hash\r\n end",
"def to_hash\n @value\n end",
"def to_hash\n @va... | [
"0.6719518",
"0.6719518",
"0.666832",
"0.66565555",
"0.6586841",
"0.6452931",
"0.6414911",
"0.6414911",
"0.6382046",
"0.6346188",
"0.6302933",
"0.62237245",
"0.6151989",
"0.6101756",
"0.60795677",
"0.60795677",
"0.60717124",
"0.6035991",
"0.6021168",
"0.5936472",
"0.5903488",... | 0.0 | -1 |
GET /list_sells GET /list_sells.json | def index
@list_sells = current_user.list_sells.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @sells = Sell.all\n\n render json: @sells\n end",
"def selling_list(opts={})\r\n opts[:output] = 'json'\r\n opts[:callback] = 'callback'\r\n Yahoo::Request.get(\"http://auctions.yahooapis.jp/AuctionWebService/V2/sellingList\", Yahoo::Api.merge(opts))\r\n end",... | [
"0.81126535",
"0.73788583",
"0.7035662",
"0.698716",
"0.6938088",
"0.6894251",
"0.689371",
"0.6868068",
"0.6856613",
"0.68197495",
"0.68059504",
"0.67893094",
"0.66366696",
"0.652159",
"0.6520973",
"0.64540803",
"0.6364109",
"0.6361106",
"0.63525915",
"0.63360757",
"0.627921"... | 0.75054246 | 1 |
GET /list_sells/1 GET /list_sells/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @sells = Sell.all\n\n render json: @sells\n end",
"def show\n @sell = Sell.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sell }\n end\n end",
"def index\n @list_sells = current_user.list_sells.all\n end",
"d... | [
"0.81270915",
"0.73180825",
"0.72603667",
"0.7235003",
"0.7016749",
"0.70014745",
"0.6954622",
"0.68479615",
"0.6834168",
"0.6831165",
"0.6822774",
"0.67210346",
"0.65962124",
"0.6561269",
"0.65410507",
"0.6536362",
"0.6516896",
"0.65153605",
"0.64794755",
"0.6454236",
"0.645... | 0.0 | -1 |
POST /list_sells POST /list_sells.json | def create
@list_sell = current_user.list_sells.new(list_sell_params)
respond_to do |format|
if @list_sell.save
format.html { redirect_to list_sells_url, notice: 'List sell was successfully created.' }
format.json { render :show, status: :created, location: @list_sell }
else
format.html { render :new }
format.json { render json: @list_sell.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @sells = Sell.all\n\n render json: @sells\n end",
"def create\n @sell = Sell.new(sell_params)\n\n if @sell.save\n render json: @sell, status: :created, location: @sell\n else\n render json: @sell.errors, status: :unprocessable_entity\n end\n end",
"def set_list_sell\n ... | [
"0.74579376",
"0.715181",
"0.6782261",
"0.6751506",
"0.66202205",
"0.6503092",
"0.64537954",
"0.6396458",
"0.63155633",
"0.62733424",
"0.6254891",
"0.6254891",
"0.6238285",
"0.61784154",
"0.61354977",
"0.61027604",
"0.6087352",
"0.6064894",
"0.6046492",
"0.6035927",
"0.603107... | 0.70169663 | 2 |
PATCH/PUT /list_sells/1 PATCH/PUT /list_sells/1.json | def update
respond_to do |format|
if @list_sell.update(list_sell_params)
format.html { redirect_to list_sells_url, notice: 'List sell was successfully updated.' }
format.json { render :show, status: :ok, location: @list_sell }
else
format.html { render :edit }
format.json { render json: @list_sell.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @sell.update(sell_params)\n head :no_content\n else\n render json: @sell.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @sell.update(sell_params)\n format.html { redirect_to sells_path, notice: 'Sell was successfull... | [
"0.73035127",
"0.71475416",
"0.6862595",
"0.68150526",
"0.6699556",
"0.6635604",
"0.66218585",
"0.6558355",
"0.6508908",
"0.6439633",
"0.64333487",
"0.6408453",
"0.6374326",
"0.6367816",
"0.6352514",
"0.6352514",
"0.6322944",
"0.63179284",
"0.63109523",
"0.6304401",
"0.629282... | 0.7615573 | 0 |
DELETE /list_sells/1 DELETE /list_sells/1.json | def destroy
@list_sell.destroy
respond_to do |format|
format.html { redirect_to list_sells_url, notice: 'List sell was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n sellID = params[:sell_id]\n\n uri = URI(\"http://107.170.7.58:4567/api/delete/sell\")\n parameters = {\"ext\" => \"json\", \"id\" => sellID}\n response = Net::HTTP.post_form(uri, parameters)\n list = JSON.parse(response.body)\n\n @response = list[0][\"kind\"]\n end",
"def destroy\... | [
"0.7728636",
"0.75742054",
"0.7326431",
"0.72332823",
"0.7171546",
"0.7078559",
"0.70329535",
"0.7011861",
"0.7008357",
"0.70018303",
"0.70018303",
"0.69794065",
"0.69794065",
"0.68778765",
"0.6827429",
"0.68260306",
"0.6816231",
"0.68080753",
"0.6802146",
"0.6789231",
"0.676... | 0.76519924 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_list_sell
@list_sell = ListSell.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.61637366",
"0.60446453",
"0.59452957",
"0.591511",
"0.58885515",
"0.5834122",
"0.57761765",
"0.5702554",
"0.5702554",
"0.5652102",
"0.5619581",
"0.5423898",
"0.5409782",
"0.5409782",
"0.5409782",
"0.5394745",
"0.53780794",
"0.5356209",
"0.5338898",
"0.53381324",
"0.5328622... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def list_sell_params
params.require(:list_sell).permit(:address, :unit, :city, :state, :zip, :price, :virtual_tour_link, :home_type, :no_bed, :no_f_bath, :no_q_bath, :no_h_bath, :finished_sq, :lot_size, :year_built, :remodel_year, :hoa_dues, :basement_area, :garage_area, :description, :website, :my_views, :email, :ph_no, room_details_attributes: [:id, :dish_washer, :rang_oven, :dryer, :refrigerator, :freezer, :trash_compactor, :garbage_disposal, :washer, :microwave, :basement_type, :floor_type, :room_type, :_destroy], sell_visit_times_attributes: [:id, :date, :start_time, :end_time, :_destroy], rental_images_attributes:[:id, :url, :_destroy] )
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 |
Use callbacks to share common setup or constraints between actions. | def set_product
@product = Product.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.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 product_params
params.require(:product).permit(:name, :image)
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.69780594",
"0.678054",
"0.6742781",
"0.67387927",
"0.67346025",
"0.6590683",
"0.6501642",
"0.6495788",
"0.6479752",
"0.64763314",
"0.645457",
"0.6437739",
"0.6377168",
"0.6372484",
"0.6363871",
"0.63179374",
"0.62981373",
"0.6297456",
"0.62916917",
"0.6290227",
"0.628954",... | 0.0 | -1 |
Requesting a email validation with the appropriate code | def validate_email
@user = User.find(params[:id])
if @user.check_verification(params[:code])
render :json => {:message => :validation_success }
else
render :json => {:message => :validation_failed}, :status => :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email_validation\n user = User.first\n email_validation_code = rand_validation_code\n UserMailer.email_validation(user, email_validation_code)\n end",
"def email_required?; false end",
"def email_validation(user, email_validation_code)\n @user = user\n @email_validation_code = email_validat... | [
"0.7421474",
"0.7287447",
"0.726069",
"0.71846306",
"0.7130471",
"0.70982575",
"0.70924413",
"0.7083255",
"0.7025379",
"0.70157886",
"0.70155066",
"0.70121443",
"0.7009572",
"0.7003826",
"0.69874036",
"0.6916432",
"0.68934566",
"0.68934566",
"0.68934566",
"0.68934566",
"0.689... | 0.71825904 | 4 |
GET /tap_log_records/1 GET /tap_log_records/1.xml | def show
@tap_log_record = current_account.tap_log_records.find(params[:id])
authorize! :view, @tap_log_record
@current_activity = @tap_log_record.current_activity
@during_this = @tap_log_record.during_this
@previous_activity = @tap_log_record.previous.activity.first
@previous_entry = @tap_log_record.previous.first
@next_activity = @tap_log_record.next.activity.first
@next_entry = @tap_log_record.next.first
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @tap_log_record }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @log = @client.logs.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @log }\n end\n end",
"def show\n @measurement_log = current_account.measurement_logs.find(params[:id])\n\n respond_to do |format|\n format.html #... | [
"0.6156339",
"0.6011641",
"0.6000989",
"0.59989357",
"0.59879506",
"0.5981014",
"0.593862",
"0.593862",
"0.59380955",
"0.59274995",
"0.59119225",
"0.5907236",
"0.5869905",
"0.58511746",
"0.58078784",
"0.5799229",
"0.579398",
"0.5762209",
"0.57472336",
"0.57110727",
"0.5701046... | 0.63025546 | 0 |
GET /tap_log_records/new GET /tap_log_records/new.xml | def new
@tap_log_record = current_account.tap_log_records.new
authorize! :create, @tap_log_record
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @tap_log_record }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @log = Log.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @log }\n end\n end",
"def new\n @log = Log.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @log }\n end\n end",
"def... | [
"0.69668865",
"0.69668865",
"0.69668865",
"0.68919235",
"0.68353826",
"0.67895424",
"0.67220193",
"0.6534272",
"0.6499548",
"0.64193034",
"0.64190996",
"0.64160675",
"0.64116377",
"0.64053595",
"0.6395771",
"0.63714886",
"0.62514746",
"0.6251073",
"0.6226448",
"0.6226351",
"0... | 0.7009149 | 0 |
POST /tap_log_records POST /tap_log_records.xml | def create
@tap_log_record = current_account.tap_log_records.new(params[:tap_log_record])
authorize! :create, @tap_log_record
respond_to do |format|
if @tap_log_record.save
format.html { redirect_to(@tap_log_record, :notice => 'Tap log record was successfully created.') }
format.xml { render :xml => @tap_log_record, :status => :created, :location => @tap_log_record }
else
format.html { render :action => "new" }
format.xml { render :xml => @tap_log_record.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def record_result_to_tsdb()\n log_time_sec=@time_now.to_i-120\n @pv_response_time.each do |uri,response_time|\n send_metric(\"jpaas_app_responsetime\",log_time_sec,response_time,{\"uri\"=>uri,\"router\"=>@hostname})\n end\n @pv_response_code.each do |uri,response_code_hash|\n... | [
"0.56779075",
"0.5565212",
"0.55483454",
"0.5488093",
"0.54851794",
"0.547889",
"0.5463886",
"0.5414578",
"0.5359674",
"0.53217274",
"0.526908",
"0.52642053",
"0.52639276",
"0.525309",
"0.5252212",
"0.5222838",
"0.52226543",
"0.5218578",
"0.5209868",
"0.5206883",
"0.5200727",... | 0.6282009 | 0 |
PUT /tap_log_records/1 PUT /tap_log_records/1.xml | def update
@tap_log_record = current_account.tap_log_records.find(params[:id])
authorize! :update, @tap_log_record
respond_to do |format|
if @tap_log_record.update_attributes(params[:tap_log_record])
format.html { redirect_to(@tap_log_record, :notice => 'Tap log record was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @tap_log_record.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{conte... | [
"0.59190017",
"0.58341765",
"0.56240606",
"0.5527818",
"0.5515295",
"0.5514005",
"0.54670435",
"0.54525185",
"0.542644",
"0.54117316",
"0.5386971",
"0.53820276",
"0.5378451",
"0.53694093",
"0.5353133",
"0.53294414",
"0.5325028",
"0.5302048",
"0.5300203",
"0.5285779",
"0.52299... | 0.6123483 | 0 |
DELETE /tap_log_records/1 DELETE /tap_log_records/1.xml | def destroy
@tap_log_record = current_account.tap_log_records.find(params[:id])
authorize! :delete, @tap_log_record
@tap_log_record.destroy
respond_to do |format|
format.html { redirect_to(tap_log_records_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @action_log = ActionLog.find(params[:id])\n @action_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(action_logs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @audit_log = AuditLog.find(params[:id])\n @audit_log.destroy\n\n respond_... | [
"0.6436008",
"0.6391237",
"0.6367711",
"0.634903",
"0.63102925",
"0.6286208",
"0.6275821",
"0.6252044",
"0.6190179",
"0.6138236",
"0.60964257",
"0.60253966",
"0.60221237",
"0.602092",
"0.6012343",
"0.5987359",
"0.5983938",
"0.5944961",
"0.59183323",
"0.5912639",
"0.58958554",... | 0.70346534 | 0 |
GET /places GET /places.json | def index
@places = Place
.all
.includes(:words)
.order(:name)
.paginate(page: params[:page], per_page: 50)
.load
# Set @map_places to a hash with data for the map with all places
@map_places = map_places
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n render json: @places\n end",
"def index\n @places = Place.all\n\n respond_to do |format|\n format.html\n format.json { render json: @places }\n end\n end",
"def index\n @places = @site.places.all\n\n respond_to do |format|\n format.html # index.html.erb\n ... | [
"0.7838841",
"0.7674822",
"0.76263106",
"0.74539286",
"0.7435028",
"0.7305268",
"0.7239809",
"0.7199714",
"0.7181742",
"0.7168511",
"0.7167044",
"0.71359336",
"0.7121046",
"0.7121046",
"0.7121046",
"0.7099418",
"0.70794225",
"0.70783067",
"0.7068342",
"0.7066142",
"0.70651954... | 0.6275185 | 70 |
Get a random place and go to its show page | def random
redirect_to_random(Place)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_random\n Defcli.open_in_browser random_url(:api => false)\n end",
"def random_page\n c = @wiki.pages.count\n begin\n @page = @wiki.pages.find(:first, offset: rand(c))\n end while @page.links.count < 1\n\n redirect_to [@wiki, @page]\n end",
"def random\n redirect_to_random(... | [
"0.6699892",
"0.6417466",
"0.63502514",
"0.6325642",
"0.62695223",
"0.6267673",
"0.6267538",
"0.626452",
"0.6226179",
"0.6163438",
"0.61476004",
"0.61175936",
"0.6041432",
"0.60173976",
"0.5971041",
"0.5962578",
"0.5940742",
"0.5878277",
"0.5867874",
"0.58280694",
"0.5813076"... | 0.7677287 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_place
@place = Place.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.61637366",
"0.60446453",
"0.59452957",
"0.591511",
"0.58885515",
"0.5834122",
"0.57761765",
"0.5702554",
"0.5702554",
"0.5652102",
"0.5619581",
"0.5423898",
"0.5409782",
"0.5409782",
"0.5409782",
"0.5394745",
"0.53780794",
"0.5356209",
"0.5338898",
"0.53381324",
"0.5328622... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def place_params
params.fetch(:place, {})
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 |
Reads the database credentials from the local config/database.yml file +db+ the name of the environment to get the credentials for Returns username, password, database | def database_config( db )
database = local_database_config_hash
return database["#{db}"]['username'], database["#{db}"]['password'], database["#{db}"]['database'], database["#{db}"]['host']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def database_config(db)\n database = YAML::load_file('config/database.yml')\n return database[\"#{db}\"]['username'], database[\"#{db}\"]['password'], database[\"#{db}\"]['database'], database[\"#{db}\"]['host']\n end",
"def remote_database_config(db)\n env = rails_env || db\n config = cap... | [
"0.814866",
"0.80317867",
"0.79937065",
"0.79899055",
"0.7960045",
"0.76936764",
"0.76936764",
"0.7689373",
"0.7581691",
"0.7581613",
"0.71051705",
"0.6924732",
"0.683816",
"0.68224645",
"0.6776796",
"0.6770902",
"0.67083424",
"0.66926974",
"0.6682562",
"0.6563802",
"0.655544... | 0.8075344 | 1 |
Reads the database credentials from the remote config/database.yml file +db+ the name of the environment to get the credentials for Returns username, password, database | def remote_database_config( db )
remote_config = capture("cat #{shared_path}/config/database.yml")
database = YAML::load( remote_config )
return database["#{db}"]['username'], database["#{db}"]['password'], database["#{db}"]['database'], database["#{db}"]['host']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remote_database_config(db)\n env = rails_env || db\n config = capture \"cat #{latest_release}/config/database.yml\"\n database = YAML::load(config)\n return database[\"#{env}\"]['username'], database[\"#{env}\"]['password'], database[\"#{env}\"]['database'], database[\"#{env}\"]['host']\n ... | [
"0.85502285",
"0.81571287",
"0.79268926",
"0.7844336",
"0.76685023",
"0.7539639",
"0.7530949",
"0.74034035",
"0.7315285",
"0.7315285",
"0.7205428",
"0.6916607",
"0.6889001",
"0.6764719",
"0.6712065",
"0.66990316",
"0.6671865",
"0.6480826",
"0.63489544",
"0.6341808",
"0.633115... | 0.86038566 | 0 |
GET /questions GET /questions.json | def search_result
@questions = Question.search(params[:search]).for_index_set.page(params[:page]).per(10).order(:id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def questions\n self.class.get(\"/2.2/questions\", @options)\n end",
"def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end",
"def index\n @questions = Question.all\n\n respond_to do |f... | [
"0.81611127",
"0.7624654",
"0.7563469",
"0.75616515",
"0.7240497",
"0.7192332",
"0.71919006",
"0.7082844",
"0.7081661",
"0.7081661",
"0.7081661",
"0.7077666",
"0.70654213",
"0.7030367",
"0.7017587",
"0.7017587",
"0.70008534",
"0.69796693",
"0.6950044",
"0.69486165",
"0.690268... | 0.0 | -1 |
GET /questions/1 GET /questions/1.json | def show
not_found unless for_public?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_one\n question_data = Question.new.get_one( params[:id] )\n return render json: question_data\n end",
"def questions\n self.class.get(\"/2.2/questions\", @options)\n end",
"def show\n \t\tquestion = Question.find(params[:id])\n \t\tputs \"QUESTION: #{question.name}\"\n \t\trender js... | [
"0.7683254",
"0.7540626",
"0.737101",
"0.7303245",
"0.7251743",
"0.7231343",
"0.7230414",
"0.7230414",
"0.7230414",
"0.7194254",
"0.7174909",
"0.7174909",
"0.7168331",
"0.7120867",
"0.70868975",
"0.704648",
"0.69566995",
"0.693518",
"0.6902902",
"0.68723387",
"0.6862595",
"... | 0.0 | -1 |
POST /questions POST /questions.json | def create
@question = current_user.create_questions.build(question_params)
@question.input = StringIO.new(params[:question][:i_data].read).read.gsub(/\R/, "\n") if params[:question][:i_data]
@question.output = StringIO.new(params[:question][:o_data].read).read.gsub(/\R/, "\n") if params[:question][:o_data]
@question.origin_level = params[:question][:question_level].to_i
if @question.save
post = current_user.posts.build(category: 0)
@question.posts << post
current_user.save
num = current_user.created_question_number + 1
current_user.update_attribute(:created_question_number, num)
redirect_to @question, flash: { notice: 'Question was successfully created.' }
else
render :new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @question = Question.new(question_params)\n\n if @question.save\n render json: @question\n else\n render status: 400, nothing: true\n end\n end",
"def create\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index ... | [
"0.7366109",
"0.72979563",
"0.7059195",
"0.7000753",
"0.6956294",
"0.68727475",
"0.67733675",
"0.6729471",
"0.67116046",
"0.6706642",
"0.6705714",
"0.6689426",
"0.6647686",
"0.6635359",
"0.662669",
"0.662669",
"0.662669",
"0.662669",
"0.662669",
"0.662669",
"0.662669",
"0.6... | 0.0 | -1 |
PATCH/PUT /questions/1 PATCH/PUT /questions/1.json | def update
@question.input = StringIO.new(params[:question][:i_data].read).read.gsub(/\R/, "\n") if params[:question][:i_data]
@question.output = StringIO.new(params[:question][:o_data].read).read.gsub(/\R/, "\n") if params[:question][:o_data]
if @question.update(question_params)
redirect_to @question, flash: {notice: 'Question was successfully updated.' }
else
render :edit
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to api_v1_question_path(@question), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n ... | [
"0.7184518",
"0.70821404",
"0.6958625",
"0.6924202",
"0.689133",
"0.6880938",
"0.6880576",
"0.6822718",
"0.6822718",
"0.6822718",
"0.6822718",
"0.6822718",
"0.68155974",
"0.6814455",
"0.6812028",
"0.6739193",
"0.6735723",
"0.6732284",
"0.6724706",
"0.6695924",
"0.66802907",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_question
@question = Question.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.61637366",
"0.60446453",
"0.59452957",
"0.591511",
"0.58885515",
"0.5834122",
"0.57761765",
"0.5702554",
"0.5702554",
"0.5652102",
"0.5619581",
"0.5423898",
"0.5409782",
"0.5409782",
"0.5409782",
"0.5394745",
"0.53780794",
"0.5356209",
"0.5338898",
"0.53381324",
"0.5328622... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.