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
DELETE /post228s/1 DELETE /post228s/1.xml
def destroy @post228 = Post228.find(params[:id]) @post228.destroy respond_to do |format| format.html { redirect_to(post228s_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def destroy\n @post156 = Post156.find(params[:id])\n @post156.destroy\n\n respond_to do |format|\n format.html { redirect_to(post156s_url) }\n format.xml { head :ok }\n end\n end", "def destro...
[ "0.7153177", "0.7057219", "0.7028367", "0.6979591", "0.6967724", "0.6962562", "0.6962029", "0.6955468", "0.6952842", "0.69514656", "0.6938496", "0.69283885", "0.6925673", "0.6920111", "0.69102424", "0.6898963", "0.68976635", "0.68857026", "0.6881234", "0.6881061", "0.6878626"...
0.67570055
51
white list the recipe parameters passed through to create action here the syntax for manytomany relationship with ingredients to expect a list of ingredient ids to be passed through is "ingredient_ids: []"
def recipe_params params.require(:recipe).permit(:name,:description, ingredient_ids: []) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ingredient_params\n params.require(:ingredient).permit(:name, :recipe_ids => [])\n end", "def create\n @recipe = Recipe.new(recipe_params)\n if params['ingredients']\n params['ingredients'].each do |ingredient_name|\n @recipe.ingredients << Ingredient.find_by(name: ingredient_name)\...
[ "0.7576485", "0.71516526", "0.7025868", "0.69687855", "0.6921045", "0.67717236", "0.6743461", "0.6732759", "0.66984874", "0.6691954", "0.6660688", "0.6640937", "0.6630657", "0.66062915", "0.6543296", "0.65312654", "0.65147346", "0.6507802", "0.6504975", "0.6500262", "0.648910...
0.74446493
1
GET /observations GET /observations.json
def index @observations = Observation.all() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_observations # :nologin:\n query = create_query(:Observation, :all, by: :date)\n show_selected_observations(query)\n end", "def list_observations\n query = create_query(:Observation, :all, by: :date)\n show_selected_observations(query)\n end", "def extract_observations(url)\n\n JSON.l...
[ "0.72471005", "0.72091323", "0.71020776", "0.7026508", "0.6835884", "0.68109834", "0.6501149", "0.64963126", "0.64825726", "0.6399886", "0.6395455", "0.6358507", "0.6311764", "0.6274264", "0.62137246", "0.6152796", "0.6129124", "0.61269915", "0.6094133", "0.6091257", "0.60853...
0.71982825
2
GET /observations/1 GET /observations/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @observations = Observation.all()\n end", "def extract_observations(url)\n\n JSON.load(open(url))\n\n end", "def show\n @observation = Observation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observation }\n end\...
[ "0.67711335", "0.67475224", "0.6717042", "0.65535736", "0.65496236", "0.6516681", "0.64280385", "0.63851666", "0.63757455", "0.61541724", "0.61337066", "0.6056076", "0.60321456", "0.5999285", "0.5979333", "0.59619814", "0.595239", "0.595239", "0.5942247", "0.5939914", "0.5832...
0.0
-1
POST /observations POST /observations.json
def create uploaded_photo = params[:photo] logger.debug uploaded_photo #TODO better nameing convention new_file_name = "#{SecureRandom.uuid.gsub("-","")}#{File.extname(uploaded_photo.original_filename)}" #new_file_name = Time.now.to_s + "." + uploaded_photo.original_filename.split('.').last final_name = File.join(photo_dir,new_file_name) File.open(final_name, 'wb') do |file| file.write(uploaded_photo.read) end @observation = Observation.new(obersvation_params) location = Location.new(locations_params) @observation.location = location @observation.photos = [Photo.new(:path => new_file_name)] @observation.feed_id = current_user.feed.id if @observation.save redirect_to :controller => 'feeds', :action => 'index', :fid => current_user.feed.id else #TODO error handling end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n # Handle the case of a single obs\n params[:observations] = [['0', params[:observation]]] if params[:observation]\n \n if params[:observations].blank? && params[:observation].blank?\n respond_to do |format|\n format.html do\n flash[:error] = t(:no_observations_submitte...
[ "0.6814218", "0.6384385", "0.60876113", "0.60742337", "0.6029716", "0.5996486", "0.5885024", "0.58501863", "0.568934", "0.56842864", "0.56814116", "0.56796193", "0.56463814", "0.5642572", "0.56388414", "0.56270355", "0.56195897", "0.56144387", "0.56144387", "0.5613605", "0.55...
0.0
-1
PATCH/PUT /observations/1 PATCH/PUT /observations/1.json
def update respond_to do |format| if @observations.update(obersvation_params) format.html { redirect_to @obersvation, notice: 'Obersvation was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @obersvation.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @observation = Observation.find(params[:id])\n\n respond_to do |format|\n if @observation.update_attributes(params[:observation])\n format.html { redirect_to @observation, notice: 'Observation was successfully updated.' }\n format.json { head :no_content }\n else\n ...
[ "0.6699972", "0.65704095", "0.634537", "0.62470764", "0.6106513", "0.6089612", "0.6083484", "0.59945583", "0.5990159", "0.59592104", "0.5952517", "0.5946065", "0.5930554", "0.5919522", "0.5909219", "0.59068066", "0.59062684", "0.58735484", "0.5860375", "0.5855865", "0.5837326...
0.6142346
4
DELETE /observations/1 DELETE /observations/1.json
def destroy @observations.destroy respond_to do |format| format.html { redirect_to observations_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @observation = Observation.find(params[:id])\n @observation.destroy\n\n respond_to do |format|\n format.html { redirect_to observations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @observation.wait_for_index_refresh = true\n @observation.destro...
[ "0.71679884", "0.70662516", "0.6777801", "0.6772828", "0.6739188", "0.6704908", "0.6695091", "0.66723424", "0.65656424", "0.65312195", "0.64650345", "0.646201", "0.645995", "0.6450792", "0.64245844", "0.642367", "0.6395409", "0.6394913", "0.6374511", "0.63703805", "0.63648456...
0.75186217
0
Use callbacks to share common setup or constraints between actions.
def set_obersvation @observations = Observation.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 obersvation_params params.require(:observation).permit(:right_ascension, :declination, :magnitude, :seen) 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
Returns whether a song is accessible by an user via the frontend, so if its status is "public" or "private". Being +published?+ triggers additional validation (presence of title, associated user, minimum 1 track)
def published? [:public, :private].include?(self.status) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def publishable?(user)\n user.present? && !public?\n end", "def is_public?\n return true if self.statut == \"public\"\n end", "def public?\n self.privacy == PUBLIC\n end", "def is_public?\n @status == \"public\"\n end", "def is_public?\n @status == \"public\"\n end", "...
[ "0.7468684", "0.6865369", "0.67657393", "0.6731506", "0.6731506", "0.6702186", "0.6702186", "0.6702186", "0.6702186", "0.6702186", "0.6687135", "0.66736394", "0.6626447", "0.6625566", "0.662304", "0.6616976", "0.66062087", "0.6571065", "0.65569264", "0.65566856", "0.65552425"...
0.7174699
1
Song edit policy: a private song is accessible by its creator and all the users that have been added to the featurings list. A public song is accessible by anyone. TODO: Implement only track addition for featurings, and not complete editing
def editable_by?(user) if self.status == :private self.user == user || self.featurings.map(&:user).include?(user) elsif status == :temporary true # XXX FIXME SECURITY HOLE RIGHT HERE: ANY USER CAN MODIFY TEMP SONGS FIXME elsif status == :public false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n authorize Song\n end", "def edit\n @song = Song.find(params[:id])\n if @song.private? && @song.editable_by?(current_user)\n load_user_stuff\n current_user.enter_multitrack!\n render :action => 'index'\n elsif @song.public?\n @remix = @song.create_remix_by(current_user)...
[ "0.64244634", "0.60781366", "0.5904308", "0.5889482", "0.5858405", "0.5762948", "0.5761088", "0.5733115", "0.5609579", "0.55760133", "0.55675", "0.5521235", "0.54989624", "0.5471946", "0.5456667", "0.54478896", "0.5440012", "0.54047924", "0.54035205", "0.5402598", "0.53987277...
0.5575521
10
Returns an array of all instruments used into this song.
def instruments @instruments ||= Instrument.find self.tracks.count(:include => :instrument, :group => 'instrument_id').map(&:first) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def instruments\n return @instruments if defined? @instruments\n\n reset_instruments!\n end", "def instruments_names\n instruments_s = \"\"\n\n instruments.each do |instrument|\n instruments_s += instrument.name + \", \"\n end\n\n return instruments_s.first(instrum...
[ "0.7955475", "0.64435905", "0.6292401", "0.626321", "0.619373", "0.619373", "0.6186192", "0.61817145", "0.61049324", "0.60686064", "0.60640204", "0.6044743", "0.60378987", "0.60349214", "0.6004739", "0.5982738", "0.5957244", "0.59132034", "0.5908692", "0.5901741", "0.5901741"...
0.73625326
1
Returns mixable songs, that share at least one track with this one.
def mixables(options = {}) track_ids = self.tracks.map(&:id) Song.public.find(:all, :include => :mixes, :conditions => ['mixes.track_id IN (?) AND mixes.song_id <> ?', track_ids, self.id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_mixable_with?(song)\n mixables.include?(song)\n end", "def songs\n Song.all.select {|song| song.artist == self }\n end", "def songs\n Song.all.select {|song| song.artist == self}\n end", "def songs\n Song.all.select{|song| song.artist == self}\n end", "def songs\n ...
[ "0.64634484", "0.63390964", "0.63358164", "0.63292027", "0.6319624", "0.6319624", "0.63060325", "0.6297358", "0.62568694", "0.62483376", "0.6234319", "0.6226239", "0.6173849", "0.61716455", "0.6164478", "0.6163437", "0.6161784", "0.6151892", "0.6151892", "0.6151892", "0.61495...
0.71601945
0
Checks whether the passed Song is a direct version of this one.
def is_mixable_with?(song) mixables.include?(song) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def direct?\n @direct\n end", "def direct?\n !direct.empty?\n end", "def direct?\n return data.direct\n end", "def is_direct_object?\n true\n end", "def is_direct_path item\n\t\t!item.nil? and !item[3] and item[1] == @zero_pathitem\n\tend", "def is_enable_direct_url\n ...
[ "0.6672821", "0.6627957", "0.65189314", "0.5990205", "0.5625952", "0.5357106", "0.5297694", "0.5236185", "0.5199959", "0.5198589", "0.51875716", "0.5183513", "0.517311", "0.51531154", "0.51375306", "0.5121672", "0.50996256", "0.50792325", "0.50664383", "0.50359035", "0.502095...
0.4697747
68
Returns the mixables count for this song. The +find_most_collaborated+ method precalculates this counter, in order to optimize frequent calls, so this method first checks whether a collaboration_count attribute is present, if not it queries the database for the +mixables+ array and returns its size.
def collaboration_count (attributes['collaboration_count'] || mixables.size).to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commons_count\n respond_to?(:commonsCount) ? commonsCount.to_i : nil\n end", "def count\n coverable_files.size\n end", "def reactions_count\n object.reaction_kinds.group(:name).count\n end", "def songs_count\n value = 0\n packs.each do |pack|\n value += pack.son...
[ "0.60363615", "0.57334507", "0.5697743", "0.5656104", "0.5599056", "0.5591574", "0.55666476", "0.55432135", "0.55432135", "0.5522932", "0.5522932", "0.55138355", "0.5499043", "0.54842013", "0.5481281", "0.5452433", "0.54193527", "0.540418", "0.5391271", "0.5386852", "0.536521...
0.76454777
0
Increment the listened_times counter. Currently called by PlayersControllershow.
def increment_listened_times increment(:listened_times) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def increment_games_played\n self.games_played += 1\n end", "def update_counters\n player.plays_count.increment\n opponent.plays_count.increment\n true\n end", "def play\n @@plays += 1\n end", "def increment_time\n @time = @time + 1\n end", "def increment!\n self.times += 1...
[ "0.6423315", "0.6397567", "0.6362865", "0.62234044", "0.61666924", "0.6075292", "0.60698295", "0.6048968", "0.59906113", "0.59906113", "0.59906113", "0.59906113", "0.59906113", "0.59906113", "0.59906113", "0.59906113", "0.5979571", "0.5958161", "0.5933211", "0.5929527", "0.59...
0.8182622
0
Returns the prettyprinted length of the current song. See Numericto_runtime for details on the formatting.
def length seconds.to_runtime end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def displayTrackLength()\n if(self.id3Length)\n return [self.id3Length/3600, self.id3Length/60 % 60, self.id3Length % 60].map{|t| t.to_s.rjust(2, '0')}.join(':')\n end\n end", "def length\n to_s.length\n end", "def inspect\n \"#{size} words\"\n end", "def playable_length\n playabl...
[ "0.6796998", "0.6649276", "0.66084623", "0.6597952", "0.6587717", "0.6569733", "0.6551015", "0.65299404", "0.6511558", "0.6484765", "0.64193", "0.62970555", "0.62970555", "0.62670594", "0.6257487", "0.622783", "0.621026", "0.6209799", "0.61874914", "0.61834675", "0.6157896", ...
0.5813085
59
Prints the song title into the breadcrumb (see ApplicationControllerbreadcrumb for details).
def to_breadcrumb self.title end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def breadcrumb_name\n title\n end", "def our_songs\r\n\t@title = \"Our Songs\"\r\n end", "def title\n\t\tbase_title = \"Black Market Books\"\n\t\tif @title.nil?\n\t\t\tbase_title\n\t\telse\n\t\t\t\"#{base_title} | #{@title}\"\n\t\tend\n\tend", "def page_title\n \n page_title = @rendere...
[ "0.74266034", "0.66766125", "0.6615928", "0.6539437", "0.65152705", "0.6472069", "0.64540374", "0.6443034", "0.63965136", "0.6391127", "0.63502604", "0.6339357", "0.6336272", "0.63209105", "0.6295104", "0.62425494", "0.6233119", "0.6224984", "0.6224984", "0.6222322", "0.61830...
0.6749093
1
Checks whether this Song is rateable by the given user. A User Song is not rateable by its creator, a Mband Song is not rateable by its members.
def rateable_by?(user) self.user.rateable_by?(user) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rated_by?(user)\n rating && rating.user_ratings.exists?(:user_id => user)\n end", "def rated_by_user?(user)\n rtn = false\n if user\n self.ratings.each { |b|\n rtn = true if (user.id == b.rater_id && b.rater_type == \"User\")\n }\n end\n ...
[ "0.752554", "0.74585944", "0.7411446", "0.7207005", "0.7170087", "0.7137337", "0.7134624", "0.7096141", "0.7094771", "0.686359", "0.67837405", "0.673416", "0.67255044", "0.67252356", "0.6623355", "0.65301716", "0.6479219", "0.6469369", "0.62872034", "0.62791926", "0.62703186"...
0.828226
1
Set the :deleted status rather than deleting the record, and delete all the mixes and mlabs linked to this track.
def delete Song.transaction do self.status = :deleted self.save! # sets deleted = 0 self.mixes.destroy_all # actually deletes self.mlabs.destroy_all self.featurings.destroy_all end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset\n deleted.all.update marked_deleted: false\n end", "def delete\n del unless new_record?\n set_deleted_properties\n end", "def deleted!\n self.update_attribute(:status, DELETED)\n end", "def destroy\n run_callbacks :destroy do \n self.update_column(:dele...
[ "0.656713", "0.65287226", "0.6438941", "0.6421014", "0.640655", "0.6399499", "0.6388407", "0.6378606", "0.6378606", "0.63673687", "0.63613975", "0.6336945", "0.6336945", "0.6335932", "0.63352185", "0.63160264", "0.62922555", "0.62919575", "0.6266603", "0.6242519", "0.6153097"...
0.70013565
0
Shorthand to remove the temporary status of a song, setting it to the one passed via the first parameter (:private by default)
def preserve!(status = :private) self.status = status if self.temporary? self.save! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_song\n if self.yes?\n Song.decrement_counter(:yes_count, song.id)\n else\n Song.decrement_counter(:no_count, song.id)\n end\n end", "def off\n @music.off\n @playlist.clear\n @song.kill\n end", "def skip\n @song.kill\n @music.off\n end", "def set_status!(status...
[ "0.60124516", "0.5778634", "0.5754412", "0.57250416", "0.5715924", "0.56925243", "0.56712294", "0.56712294", "0.56438243", "0.56317437", "0.55560297", "0.54709053", "0.544666", "0.5424224", "0.5410875", "0.5392012", "0.5388747", "0.53879565", "0.53858423", "0.5384218", "0.536...
0.60182285
0
Shorthand to publish and save a song.
def publish! @new = true if self.private? self.status = statuses.public self.save! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def publish!\r\n publish\r\n save!\r\n end", "def publish!\n publish\n save\n end", "def publish\n\t\tPlaylist.transaction do\n\t\t\tself[:published_at] = Time.now\n\t\t\tsave!(:validate => false)\n\t\t\tDelayed::Job.enqueue PlaylistPublish.new(self.id), :queue => 'schedule'\n\t...
[ "0.68325114", "0.6717988", "0.6497711", "0.64262706", "0.63867736", "0.6329976", "0.63084215", "0.61633056", "0.6079901", "0.6034233", "0.59913474", "0.59590894", "0.59505457", "0.59442925", "0.59442925", "0.59442925", "0.59340733", "0.5933114", "0.5932563", "0.591796", "0.59...
0.0
-1
Returns true if the song has just been created. See the +publish!+ method for details.
def new? @new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def published?\n if self.publish_at < Time.now.utc\n true\n else\n false\n end\n end", "def created?\n synchronize { !!@created }\n end", "def newly_published?\n !!@newly_published\n end", "def publish\n return true if self.published_at\n\n if self.new_record?\n ...
[ "0.72112304", "0.7131833", "0.7019363", "0.68901205", "0.6882008", "0.68531007", "0.6815529", "0.67719865", "0.6722003", "0.6718867", "0.6702306", "0.66734725", "0.6660382", "0.665139", "0.66158193", "0.65795237", "0.65794075", "0.6569506", "0.650114", "0.6498942", "0.6494153...
0.0
-1
Sitemap priority for this instance FIXME: This should change logaritmically using rating_avg
def priority 0.7 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def priority(url)\r\n level = 1.0 - ((url.to_s.split(\"/\").size - 3) / 10.0)\r\n level < 0.1 ? 0.1 : level \r\n end", "def priority_score\n return @priority_score\n end", "def priority\n sites = %w[\n Pixiv Twitter\n ArtStation BCY Deviant\\ Art Hentai\\ Fou...
[ "0.64255124", "0.62896866", "0.6282674", "0.62665796", "0.5994889", "0.5978175", "0.5926877", "0.5915581", "0.586994", "0.5845707", "0.58230215", "0.580599", "0.57964146", "0.5780476", "0.5771757", "0.5769172", "0.5765677", "0.5757438", "0.57559055", "0.5749043", "0.5747498",...
0.60822886
4
A track can be destroyed only if it is already deleted.
def check_if_deleted raise ActiveRecord::ReadOnlyRecord unless deleted? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _destroy\n marked_for_destruction?\n end", "def destroy\n authorize @track\n @track.destroy\n respond_to do |format|\n format.html { redirect_to tracks_url, notice: 'Track was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n if !is...
[ "0.69616234", "0.6940818", "0.6927564", "0.6922529", "0.689229", "0.689229", "0.689229", "0.6793103", "0.6758176", "0.6653982", "0.6651585", "0.66261303", "0.6623108", "0.66168267", "0.6588321", "0.65496933", "0.6542013", "0.65142846", "0.65142846", "0.6499021", "0.6488402", ...
0.0
-1
TODO, slice of the filters from the rules and just pass those in
def apply_filter(filters, content) # anything in the rule arrau form position 2 onwards is a Filter filtered = content # apply each filter in the rules filters.each do |filter_name| filter = FilterStore.get(filter_name) filtered = filter.call(filtered) end filtered end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filters; end", "def filters; end", "def apply_filter\n end", "def filters\n end", "def add_filters(filters); end", "def filters=(_arg0); end", "def filters=(_arg0); end", "def strict_filters; end", "def strict_filters=(_arg0); end", "def filter_parameters; end", "def filter_parameters...
[ "0.7575503", "0.7575503", "0.7396343", "0.7225822", "0.7160553", "0.71605515", "0.71605515", "0.7015479", "0.6991776", "0.6842387", "0.6842387", "0.66710734", "0.66641974", "0.6643584", "0.6643584", "0.6643584", "0.6629684", "0.6478899", "0.647061", "0.6420928", "0.6414062", ...
0.6405005
21
The attributes used for visibility sent as initial params to created FileSets.
def visibility_attributes( attributes ) attributes.slice( :visibility, :visibility_during_lease, :visibility_after_lease, :lease_expiration_date, :embargo_release_date, :visibility_during_embargo, :visibility_after_embargo ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attributes_for_file_sets(env)\n visibility_attributes =\n FileSetVisibilityAttributeBuilder\n .new(work: env.curation_concern)\n .build\n\n env.attributes.merge!(visibility_attributes)\n\n env.attributes.except!(:embargo_release_date) unless\n ...
[ "0.7494802", "0.71351343", "0.70920044", "0.68661207", "0.6779278", "0.67403793", "0.66362995", "0.6602503", "0.64157635", "0.64157635", "0.640933", "0.6388832", "0.63714224", "0.6368848", "0.6330804", "0.62426525", "0.6234828", "0.6218555", "0.62169856", "0.62169856", "0.621...
0.68721396
3
A work with files attached by a proxy user will set the depositor as the intended user that the proxy was depositing on behalf of. See tickets 2764, 2902.
def work_proxy_or_depositor work.on_behalf_of.blank? ? work.depositor : work.on_behalf_of end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def proxy_user; end", "def proxy_owner\n @owner\n end", "def effective_user\r\n self.current_proxy || self.current_user\r\n end", "def setPermissionEdit( other_user )\n return setPermission( other_user, Dfile::PP_MAYEDIT )\n end", "def assign_collaborators_to(work:, collaborators:, repository: ...
[ "0.62206125", "0.57423747", "0.5726154", "0.5648909", "0.555617", "0.55526596", "0.54594797", "0.5177467", "0.5170317", "0.51170486", "0.5083211", "0.50819635", "0.5073469", "0.5042742", "0.5039368", "0.5033068", "0.50206476", "0.501939", "0.5012378", "0.5005328", "0.500403",...
0.58984774
1
for iteration 4: maybe make a merchant analytics module?
def invoices_by_date_hash hash = {} find_shipped_invoice_by_date.each do |invoice| hash[invoice[0].to_s] = [] end hash.each do |key, value| find_shipped_invoice_by_date.each do |invoice| value << invoice[1] if key == invoice[0].to_s end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def service_payment_info_loop\n segments = []\n @clp_05_amount = 0\n eob.service_payment_eobs.each_with_index do |service, index|\n service_klass = Output835.class_for(\"Service\", facility)\n Output835.log.info \"Applying class #{service_klass}\" if index == 0\n service_obj = service_klass...
[ "0.6313151", "0.59720725", "0.59553134", "0.58556336", "0.58520377", "0.576518", "0.5757999", "0.5679126", "0.5672584", "0.5639875", "0.56385195", "0.560878", "0.559866", "0.55958635", "0.5589517", "0.55851996", "0.556872", "0.55166525", "0.5498043", "0.54944175", "0.5475568"...
0.0
-1
This redefinition is unfortunate but test/unit shows us no alternative. Doubly unfortunate: hax to support Mocha's hax.
def run(result) return if @method_name.to_s == "default_test" if using_mocha = respond_to?(:mocha_verify) assertion_counter_klass = if defined?(Mocha::TestCaseAdapter::AssertionCounter) Mocha::TestCaseAdapter::AssertionCounter else Mocha::Integration::TestUnit::AssertionCounter end assertion_counter = assertion_counter_klass.new(result) end yield(Test::Unit::TestCase::STARTED, name) @_result = result begin begin run_callbacks :setup setup __send__(@method_name) mocha_verify(assertion_counter) if using_mocha rescue Mocha::ExpectationError => e add_failure(e.message, e.backtrace) rescue Test::Unit::AssertionFailedError => e add_failure(e.message, e.backtrace) rescue Exception => e raise if PASSTHROUGH_EXCEPTIONS.include?(e.class) add_error(e) ensure begin teardown run_callbacks :teardown, :enumerator => :reverse_each rescue Test::Unit::AssertionFailedError => e add_failure(e.message, e.backtrace) rescue Exception => e raise if PASSTHROUGH_EXCEPTIONS.include?(e.class) add_error(e) end end ensure mocha_teardown if using_mocha end result.add_run yield(Test::Unit::TestCase::FINISHED, name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def spec; end", "def spec; end", "def self_test; end", "def self_test; end", "def test_hack\n assert(true)\n end", "def hunter_stub\n\tend", "def default_test; end", "def __dummy_test__\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def test_setu...
[ "0.62728333", "0.62728333", "0.62141323", "0.62141323", "0.6147925", "0.6099054", "0.58650136", "0.58431804", "0.5827453", "0.5827453", "0.5827453", "0.5827453", "0.5819657", "0.5813039", "0.5803996", "0.5803996", "0.5773616", "0.5773616", "0.5773616", "0.5773616", "0.5773616...
0.0
-1
DB Models in which can be automatically insert new records
def srv_auto_insert [Key,Status] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert(model)\n collection = mapper.collections[model.class]\n DB[collection.name].insert(collection.serialize(model))\n end", "def create\n self.id = connection.insert(\n \"INSERT INTO #{self.class.table_name} \" +\n \"(#{quoted_column_names.join(', ')}) \" +\n \"VAL...
[ "0.6713935", "0.6576255", "0.6547748", "0.6394662", "0.63589895", "0.6348889", "0.62830645", "0.62804055", "0.6275072", "0.62661314", "0.62515646", "0.622081", "0.622081", "0.6207441", "0.61819357", "0.616734", "0.6166228", "0.61327857", "0.6127882", "0.6114945", "0.6109892",...
0.0
-1
Handle upgrade command from outside (webif or rake)
def srv_upgrade(hex_file, version = nil, sid = 2047, forced = true) v_msg = version.nil? ? ("* No version supplied. Guessing from filename!".ljust(59) + "*") : ("* Version: #{version}".ljust(59) + "*") s_msg = sid.to_i == 2047 ? ("* Node: Broadcast(2047)".ljust(59) + "*") : ("* Node sid: #{sid}".ljust(59) + "*") logger.info("*"*60) logger.info("* Upgrade command received:".ljust(59) + "*") logger.info("* Firmware to read from: #{hex_file}".ljust(59) + "*") logger.info(v_msg) logger.info(s_msg) logger.info("*"*60) @upgrade_hash = file_parse(hex_file) @upgrade_hash["start"] = Time.now @upgrade_hash["version"] = version if version @upgrade_hash["forced"] = forced @upgrade_hash["nodes"] = Array.new @upgrade_hash["nodes_dead"] = Array.new @upgrade_hash["b_sid"] = sid.to_i @upgrade_hash["sync_error"] = Hash.new @upgrade_hash["sync_noresp"]= Array.new @upgrade_hash["sync_retry"] = 3 srv_handle_outgoing(UPG_REQUEST,@upgrade_hash) Thread.new do sleep(0.5) if @upgrade_hash["nodes"].empty? logger.info("Upgrade aborted! Reason:") logger.info("\tWe have not received an acceptance from any node!") logger.info("Clearing upgrade_hash...") @upgrade_hash.clear else logger.info("Received acceptance for sid: #{@upgrade_hash["nodes"].join(', ')}") logger.info("Starting upgrade...") @upgrade_hash["c_sid"] = @upgrade_hash["b_sid"] data_blocks_send data_blocks_finish end if @upgrade_hash.empty? then terminate end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def action_upgrade\n run_package_action(:upgrade)\n end", "def upgrade\n add option: \"-upgrade\"\n end", "def upgrade(options={})\n update\n send(run_method, %{sh -c \"#{APT_GET} -qy upgrade\"}, options)\n end", "def upgrade(version)\n \n end", "def dist_upgrade(options={})\n ...
[ "0.72675395", "0.7240118", "0.71253175", "0.70274955", "0.6723647", "0.6709167", "0.66925645", "0.66653985", "0.66017693", "0.6577407", "0.64515567", "0.64477587", "0.64466053", "0.6390839", "0.63646656", "0.6346388", "0.6270379", "0.6237482", "0.6192645", "0.6145113", "0.611...
0.55251294
59
recursively transform values that contain a data structure, return the value if it isn't a hash
def transform_value(value, &block) if value.respond_to?(:each_index) value.map do |elem| elem.transform_keys(&block) rescue elem end else value.transform_keys(&block) rescue value end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recursive_hash_normalize_keys val\n if val.is_a? Hash\n deep_hash_normalize val\n else\n val\n end\n end", "def thaw_value(value, recurse)\n return value unless value.frozen? || recurse\n case value\n when Array\n # thaws the array itself but ...
[ "0.6195885", "0.60717094", "0.59595203", "0.5888312", "0.57723445", "0.57462895", "0.5711573", "0.57111984", "0.56757635", "0.56144124", "0.55847037", "0.5548395", "0.55397284", "0.5539235", "0.5536972", "0.5535582", "0.55006945", "0.5498632", "0.5476656", "0.5466814", "0.545...
0.0
-1
Rails method, find at activesupport/lib/active_support/core_ext/hash/keys.rb, line 50
def symbolize_keys transform_keys { |key| key.to_sym rescue key } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stringified_keys; end", "def missing_keys; end", "def key_coercions; end", "def stringify_keys; end", "def stringify_keys; end", "def stringify_keys; end", "def hash_key(name); end", "def symbolize_keys; end", "def to_key; nil end", "def key_data; end", "def key_data; end", "def key_types...
[ "0.7145791", "0.69690526", "0.6945366", "0.6913223", "0.6913223", "0.6913223", "0.6750275", "0.67317927", "0.66921645", "0.6589261", "0.6589261", "0.658854", "0.658854", "0.6587688", "0.6526029", "0.652571", "0.6522881", "0.6522881", "0.65225744", "0.64937633", "0.64911294", ...
0.0
-1
transform camel_case (symbol) keys to RedoxCase string keys
def redoxify_keys transform_keys do |key| key = key[0..-1] next 'IDType' if %w[id_type IDType].include? key next key if key =~ /^([A-Z]{1}[a-z]+)+/ next key.upcase if key =~ /^[A-Za-z]{2,3}$/ key.split('_').map(&:capitalize).join end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rubyize_keys\n transform_keys do |key|\n key\n .to_s\n .gsub(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2')\n .gsub(/([a-z\\d])([A-Z])/, '\\1_\\2')\n .downcase\n .to_sym\n end\n end", "def keys_to_camelcase(hash)\n hash.transform_keys do |key|\n key.to_s\n ....
[ "0.81342024", "0.7780204", "0.7635175", "0.76339555", "0.7591292", "0.74125504", "0.73734295", "0.73039603", "0.72944427", "0.726963", "0.7170335", "0.7170335", "0.7130944", "0.7104158", "0.7070364", "0.69554824", "0.692595", "0.6865668", "0.6822264", "0.6817818", "0.68055266...
0.641494
43
transform RedoxCase string keys to ruby symbol keys
def rubyize_keys transform_keys do |key| key .to_s .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .downcase .to_sym end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_keys\n transform_keys { |key| key.downcase.to_sym rescue key }\n end", "def deep_camelize_keys\n deep_transform_keys { |key| key.to_s.camelize(:lower) }\n end", "def keyify(str)\n str.gsub(' ','_').downcase.to_sym\n end", "def stringified_keys; end", "def camelize_keys!(first_...
[ "0.75067466", "0.71079296", "0.7103555", "0.7034783", "0.6970107", "0.6943359", "0.6937459", "0.69361866", "0.69353575", "0.6893297", "0.685372", "0.682991", "0.6827101", "0.6818595", "0.6813868", "0.6792", "0.6792", "0.678306", "0.678306", "0.67697275", "0.6744126", "0.672...
0.8368261
0
Methods for Eligibility related items
def eligibility_eng @eligibility_eng ||= Participants::Eligibility.new( locale: 'english', current_smoker: 'Yes', thinking_of_quitting: 'Yes', age: 25 ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eligibility\n eligibilities.find(:first) || Eligibility.new\n end", "def renewal_eligiblity_determination\n end", "def eligibility(params = {})\n scope 'default'\n post('eligibility/', params)\n end", "def calculate_item_liability(item_attributes)\n calculate_item_gross(item_attribut...
[ "0.6620701", "0.63648576", "0.6278084", "0.6253212", "0.595243", "0.5914158", "0.5899476", "0.58868355", "0.58559215", "0.58442676", "0.58197856", "0.56807584", "0.5653542", "0.5647646", "0.56098574", "0.56047344", "0.5510273", "0.5479161", "0.5470745", "0.544933", "0.5441358...
0.5718647
11
Methods for Stop Smoking Guide related items
def stop_smoking_guide_eng @stop_smoking_guide_eng ||= Participants::StopSmokingGuide.new( locale: 'english' ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stop()\n return MicrosoftGraph::IdentityGovernance::AccessReviews::Definitions::Item::Instances::Item::Stop::StopRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def stop\n action('stop')\n end", "def stop\n ...
[ "0.615053", "0.60891724", "0.60748214", "0.5969973", "0.5935058", "0.5877856", "0.58775693", "0.58775693", "0.5786071", "0.57549256", "0.5732228", "0.57282275", "0.5713363", "0.5711982", "0.5680485", "0.5668124", "0.5658013", "0.56483644", "0.5635162", "0.56349355", "0.563493...
0.0
-1
Methods for Cigarette Counter related items
def cigarette_counter_eng @cigarette_counter_eng ||= Participants::CigaretteCounter.new( locale: 'english' ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def counter_cache; end", "def update_category_counter\r\n end", "def items_count\n counter = 0\n self.line_items.each do |item|\n if item.sellable && item.sellable.respond_to?(:quantity)\n counter += item.sellable.quantity\n else\n counter += 1\n end\n end\n counter\n ...
[ "0.6501807", "0.64956003", "0.62752104", "0.62583107", "0.6144657", "0.6117998", "0.6035759", "0.60281926", "0.6024114", "0.60178626", "0.60122603", "0.59888107", "0.5965684", "0.5934378", "0.59338444", "0.5931619", "0.5881533", "0.5881533", "0.5881533", "0.58681345", "0.5853...
0.58570564
21
Methods for Quit Date related items
def quit_date_eng @quit_date_eng ||= Participants::QuitDate.new(locale: 'english') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def single_sell_in_day_remover(item)\r\n item.sell_in -= 1\r\n end", "def set_day_if_discarded; end", "def remove_date_submenu\n\t\tputs \"Enter number of task to remove due date:\"\n\t\tchoice = get_choice.to_i\n\t\t@todo_list.remove_due_date choice\n\t\tprint_menu\n\tend", "def clear_calendar\n end"...
[ "0.61215866", "0.6087497", "0.5991277", "0.57639754", "0.5739056", "0.5630017", "0.55879414", "0.5551437", "0.5531817", "0.54857135", "0.54827124", "0.5464276", "0.5441693", "0.5398167", "0.53782713", "0.5357778", "0.5353461", "0.53414714", "0.53414714", "0.53219223", "0.5293...
0.0
-1
GET /mystocks GET /mystocks.json
def index @mystocks = initialize_grid(Mystock.where(user_id: current_user)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @users = User.all\n binding.pry\n require 'net/http'\n result = Net::HTTP.get('makesys.net', '/')\n p result\n end", "def index\n @symptoms = Symptom.all\n\n render json: @symptoms\n end", "def get_json(state, city)\n HTTParty.get(\"http://api.wundergro...
[ "0.58430696", "0.5841997", "0.58189166", "0.5744344", "0.5740534", "0.57317406", "0.56898946", "0.567711", "0.56736386", "0.5667061", "0.5658123", "0.56545365", "0.56545365", "0.56364286", "0.56252545", "0.56192636", "0.5613742", "0.56122446", "0.56096363", "0.55981356", "0.5...
0.0
-1
GET /mystocks/1 GET /mystocks/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n puts JSON.pretty_generate(result)\n result\nend", "def index\n @mirrors = Mirror.all\n\n respond_to do |format|\n format....
[ "0.57143617", "0.5682442", "0.5669255", "0.5637519", "0.5637519", "0.5615217", "0.55961895", "0.5575152", "0.5570278", "0.5541372", "0.55376816", "0.54777217", "0.5473185", "0.54666066", "0.5463927", "0.5457568", "0.54531515", "0.5446949", "0.54425126", "0.54303765", "0.54295...
0.0
-1
POST /mystocks POST /mystocks.json
def create @mystock = Mystock.new(mystock_params) @existmystock=Mystock.find_by(stock_id:params[:mystock][:stock_id],user_id:current_user) respond_to do |format| if !@existmystock.nil? format.html { redirect_to new_mystock_path, notice: '您已经关注该股票~' } elsif @mystock.save format.html { redirect_to mystocks_path, notice: 'mystock was successfully created.' } format.json { render :show, status: :created, location: @mystock } else format.html { render :new } format.json { render json: @mystock.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end", "def create\n megam_rest.post_node(to_hash)\n end", "def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end", "d...
[ "0.6078904", "0.578442", "0.5595394", "0.5487444", "0.54404604", "0.5423079", "0.54208225", "0.5419098", "0.54086", "0.5404211", "0.53998685", "0.53989303", "0.53871965", "0.5382147", "0.5355179", "0.535439", "0.5351099", "0.53393096", "0.5318164", "0.53118825", "0.5280658", ...
0.0
-1
PATCH/PUT /mystocks/1 PATCH/PUT /mystocks/1.json
def update respond_to do |format| if @mystock.update(mystock_params) format.html { redirect_to @mystock, notice: 'mystock was successfully updated.' } format.json { render :show, status: :ok, location: @mystock } else format.html { render :edit } format.json { render json: @mystock.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch!\n request! :patch\n end", "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 put!\n request! :put\n...
[ "0.6565791", "0.6298435", "0.6271273", "0.61492944", "0.6112871", "0.60498714", "0.6028928", "0.6024211", "0.5999613", "0.58913124", "0.5867511", "0.5854976", "0.5854976", "0.5834706", "0.58331555", "0.5830538", "0.58189064", "0.58189064", "0.57917345", "0.5782172", "0.578217...
0.5817168
18
DELETE /mystocks/1 DELETE /mystocks/1.json
def destroy @mystock.destroy respond_to do |format| format.html { redirect_to mystocks_path, notice: 'mystock was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n client.delete(\"/#{id}\")\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.js...
[ "0.7087331", "0.7026076", "0.6797875", "0.67827886", "0.67226183", "0.66696316", "0.66689205", "0.66252345", "0.65868586", "0.6584305", "0.65593237", "0.6555768", "0.65452397", "0.65063626", "0.65020514", "0.65020514", "0.65020514", "0.65020514", "0.64952236", "0.64938295", "...
0.6755711
4
Use callbacks to share common setup or constraints between actions.
def set_mystock @mystock = Mystock.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.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.5...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def mystock_params params.require(:mystock).permit(:user_id,:stock_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
TODO > I think both methods given below can be implemented in payment model.
def redeem_loyalty_points(amount = nil) loyalty_points_redeemed = loyalty_points_for(total, 'redeem') loyalty_points_redeemed = loyalty_points_for(amount) if amount if loyalty_points_used? && redeemable_loyalty_points_balance?(total) create_debit_transaction(loyalty_points_redeemed) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def payment_instruction\n end", "def guard_process_payment_from_created; true; end", "def guard_process_payment_from_created; true; end", "def payment_class\n raise NotImplementedError\n end", "def payment_term; end", "def pre_pay_offered\n end", "def payments_for(_other_user)\n fail Not...
[ "0.6904849", "0.6736847", "0.6736847", "0.66156095", "0.6524196", "0.6401614", "0.63707006", "0.63176334", "0.6316741", "0.62672377", "0.6257068", "0.62511003", "0.62414205", "0.6187304", "0.6167063", "0.6153689", "0.6141159", "0.6140731", "0.6120243", "0.61112773", "0.606448...
0.0
-1
TODO > Some methods like this can be moved in separate module as they are not related to order.
def loyalty_points_for(amount, purpose = 'award') loyalty_points = if purpose == 'award' && eligible_for_loyalty_points?(amount) (amount * Spree::Config.loyalty_points_awarding_unit).floor elsif purpose == 'redeem' (amount / Spree::Config.loyalty_points_conversion_rate).ceil else 0 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def order; end", "def order; end", "def private; end", "def original_order\n end", "def order=(_arg0); end", "def entry_order; end", "def order\n end", "def entry_order=(_arg0); end", "def processOrder\n \n end", "def test_order; end", "def probers; end", "def railties_order=(_arg...
[ "0.7221352", "0.7221352", "0.7030247", "0.6496829", "0.637456", "0.62965566", "0.62851614", "0.6228777", "0.6220667", "0.62116456", "0.61746", "0.6113391", "0.6113391", "0.6107194", "0.60418236", "0.5952764", "0.5952764", "0.5952764", "0.5952764", "0.5939692", "0.5920299", ...
0.0
-1
GET /shifts GET /shifts.json
def index @shifts_old = Shift.find_all_by_business_id(current_user.id) @shifts = [] @count = [] 7.times do |day| @shifts[day] = Shift.order("start desc").where(business_id: current_user.id, day: day) @count[day] = @shifts[day].count end @count = @count.max respond_to do |format| format.html # index.html.erb format.json { render json: @shifts } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @shifts = @group.shifts\n @shift = current_user.shifts.new(group: @group)\n\n respond_to do |format|\n format.html { render :index }\n format.json { render json: Shift.fullcalendar_format(@shifts) }\n end\n end", "def index\n vehicle_id = params[:vehicle_id]\n shi...
[ "0.74831414", "0.7304392", "0.7194605", "0.7194605", "0.7174168", "0.7168445", "0.7106341", "0.6936567", "0.6915253", "0.69110984", "0.67604834", "0.67576295", "0.6756194", "0.673346", "0.67300206", "0.67251104", "0.67133194", "0.66900015", "0.66493857", "0.6607614", "0.65260...
0.5959941
38
GET /shifts/1 GET /shifts/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @shifts = @group.shifts\n @shift = current_user.shifts.new(group: @group)\n\n respond_to do |format|\n format.html { render :index }\n format.json { render json: Shift.fullcalendar_format(@shifts) }\n end\n end", "def index\n vehicle_id = params[:vehicle_id]\n shi...
[ "0.7267684", "0.7038533", "0.7025564", "0.70191276", "0.70191276", "0.6999389", "0.6997069", "0.69317496", "0.69302684", "0.6908772", "0.68209356", "0.6818895", "0.67972", "0.67871237", "0.6784983", "0.67315125", "0.663346", "0.65801406", "0.6560926", "0.65169907", "0.6512719...
0.0
-1
GET /shifts/new GET /shifts/new.json
def new @shift = Shift.new respond_to do |format| format.html # new.html.erb format.json { render json: @shift } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @template_shift = TemplateShift.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @template_shift }\n end\n end", "def create\n @title = t('view.shifts.new_title')\n @shift = Shift.new(params[:shift].merge(user_id: current_user.id))\n\n ...
[ "0.77558804", "0.75139624", "0.7418467", "0.72653687", "0.717371", "0.7173515", "0.7095125", "0.7095125", "0.7095125", "0.6927381", "0.6919985", "0.6911842", "0.68593854", "0.6850708", "0.6785722", "0.6777333", "0.67631114", "0.6737262", "0.66965973", "0.66479635", "0.6636306...
0.7813823
0
POST /shifts POST /shifts.json
def create days = params[:day] saved = true days.each do |d| @shift = Shift.new(params[:shift]) @shift.business_id = current_user.id @shift.day = d[0] if !@shift.save saved = false end end respond_to do |format| if saved format.html { redirect_to shifts_path, notice: 'Shift was successfully created.' } format.json { render json: shifts_path, status: :created, location: @shift } else format.html { render action: "new" } format.json { render json: @shift.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @shift = current_user.shifts.new shift_params.merge(group: @group)\n\n respond_to do |format|\n if @shift.save\n format.html { redirect_to group_shifts_url }\n format.json { render :show, status: :created, location: @shift }\n else\n format.html { render \"groups/#...
[ "0.71749306", "0.709679", "0.7018566", "0.69380456", "0.68573415", "0.68130326", "0.68027", "0.6766381", "0.6732007", "0.66540116", "0.6652076", "0.665134", "0.6621391", "0.6563689", "0.6522205", "0.6479981", "0.64796627", "0.64348567", "0.63611346", "0.63429964", "0.6330738"...
0.68919057
4
PUT /shifts/1 PUT /shifts/1.json
def update @shift = Shift.find(params[:id]) respond_to do |format| if @shift.update_attributes(params[:shift]) @shift.day = params[:day] format.html { redirect_to shifts_path, notice: 'Shift was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @shift.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n params[:shift].delete(:employee)\n @shift = Shift.find(params[:id])\n @shift.attributes = params[:shift]\n @shift.date = Chronic.parse(params[:shift][:date])\n\n respond_to do |format|\n if @shift.save\n format.html { redirect_to @shift, notice: 'Shift was successfully updat...
[ "0.69431645", "0.6901543", "0.6881732", "0.67798877", "0.67798877", "0.67798877", "0.67798877", "0.67569286", "0.67189175", "0.6718055", "0.6670596", "0.6653072", "0.65945894", "0.6574798", "0.6574798", "0.6552007", "0.6545913", "0.6532335", "0.6517407", "0.6513359", "0.64967...
0.66952527
10
DELETE /shifts/1 DELETE /shifts/1.json
def destroy @shift = Shift.find(params[:id]) @shift.destroy respond_to do |format| format.html { redirect_to shifts_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @template_shift = TemplateShift.find(params[:id])\n @template_shift.destroy\n\n respond_to do |format|\n format.html { redirect_to template_shifts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @shift.destroy\n respond_to do |format|\n format...
[ "0.7395083", "0.7377175", "0.7377175", "0.7376252", "0.7369236", "0.7348779", "0.732202", "0.7300296", "0.72815865", "0.7273325", "0.7273325", "0.7273325", "0.72646326", "0.7225952", "0.7162687", "0.71411264", "0.71411264", "0.71411264", "0.7137383", "0.70061135", "0.7001538"...
0.7390665
2
returns [deleted_node, new_root, is_rebalance_needed]
def delete(key) ret = self case key <=> @key when -1 deleted, left, rebalance = @left.delete(key) ret = ret.with_left(left) if rebalance ret, rebalance = ret.rebalance_for_left_delete end when 0 deleted = self ret, rebalance = delete_node when 1 deleted, right, rebalance = @right.delete(key) ret = ret.with_right(right) if rebalance ret, rebalance = ret.rebalance_for_right_delete end else raise TypeError, "cannot compare #{key} and #{@key} with <=>" end [deleted, ret, rebalance] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rebalance_for_left_delete\n\t\t\trebalance = false\n\t\t\t[if black?\n\t\t\t\tif @right.black?\n\t\t\t\t\tif @right.children_color?(:black)\n\t\t\t\t\t\t# make whole sub-tree 1 level lower and ask rebalance\n\t\t\t\t\t\trebalance = true\n\t\t\t\t\t\twith_right(@right.with_color(:red))\n\t\t\t\t\telse\n\t\t\t\t...
[ "0.62307787", "0.6096375", "0.60409594", "0.5960572", "0.58125365", "0.5730148", "0.56846946", "0.557356", "0.5569713", "0.55655634", "0.55334294", "0.5488326", "0.5485938", "0.54661363", "0.54419434", "0.53947616", "0.53611296", "0.53476346", "0.53440446", "0.534225", "0.530...
0.0
-1
trying to rebalance when the left subtree is 1 level lower than the right
def rebalance_for_left_delete rebalance = false [if black? if @right.black? if @right.children_color?(:black) # make whole sub-tree 1 level lower and ask rebalance rebalance = true with_right(@right.with_color(:red)) else # move 1 black from the right to the left by single/double rotation balanced_rotate_left end else # flip this sub-tree into another type of 3-children node ret = rotate_left # try to rebalance in sub-tree left, rebalance = ret.left.rebalance_for_left_delete raise 'should not happen' if rebalance ret.with_left(left) end else # red if @right.children_color?(:black) # make right sub-tree 1 level lower with_right(@right.with_color(color)).with_color(@right.color) else # move 1 black from the right to the left by single/double rotation balanced_rotate_left end end, rebalance] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rebalance\n @root = build_tree(self.level_order_traversal) if !self.balanced?\n end", "def rebalance\n order = self.level_order\n return build_tree(order)\n end", "def rebalance!\n # Short-circut if already balanced.\n return @root if balanced?\n\n @root = build_tree(inorder)\...
[ "0.7822496", "0.7424292", "0.7311932", "0.7208089", "0.6881604", "0.6815274", "0.67037946", "0.6618166", "0.6492371", "0.6437521", "0.64372736", "0.6404786", "0.6266277", "0.62259173", "0.6207052", "0.6197343", "0.61901474", "0.61857945", "0.61425257", "0.614072", "0.6128129"...
0.7695992
1
trying to rebalance when the right subtree is 1 level lower than the left See rebalance_for_left_delete.
def rebalance_for_right_delete rebalance = false [if black? if @left.black? if @left.children_color?(:black) rebalance = true with_left(@left.with_color(:red)) else balanced_rotate_right end else ret = rotate_right right, rebalance = ret.right.rebalance_for_right_delete raise 'should not happen' if rebalance ret.with_right(right) end else # red if @left.children_color?(:black) with_left(@left.with_color(color)).with_color(@left.color) else balanced_rotate_right end end, rebalance] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rebalance_for_left_delete\n\t\t\trebalance = false\n\t\t\t[if black?\n\t\t\t\tif @right.black?\n\t\t\t\t\tif @right.children_color?(:black)\n\t\t\t\t\t\t# make whole sub-tree 1 level lower and ask rebalance\n\t\t\t\t\t\trebalance = true\n\t\t\t\t\t\twith_right(@right.with_color(:red))\n\t\t\t\t\telse\n\t\t\t\t...
[ "0.84935206", "0.7415427", "0.7087095", "0.70672786", "0.67721415", "0.67356706", "0.66288006", "0.65800595", "0.6501718", "0.62824345", "0.6236252", "0.6147968", "0.6118334", "0.6096301", "0.60633785", "0.60618323", "0.60034525", "0.5974858", "0.59721124", "0.59354526", "0.5...
0.76892304
1
move 1 black from the right to the left by single/double rotation
def balanced_rotate_left ret = self if @right.left.red? and @right.right.black? ret = with_right(@right.rotate_right) end ret = ret.rotate_left ret = ret.with_left(ret.left.with_color(:black)) ret = ret.with_right(ret.right.with_color(:black)) ret end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def right\n rotate(1)\n end", "def rebalance_for_left_insert\n\t\t\t# move 1 black from the left to the right by single/double rotation\n\t\t\tif @left.right.red?\n\t\t\t\twith_left(@left.rotate_left)\n\t\t\telse\n\t\t\t\tself\n\t\t\tend.rotate_right\n\t\tend", "def rotateLeft()\n twoTypeRotate()\n end...
[ "0.7431809", "0.7394546", "0.73313797", "0.71565324", "0.71409565", "0.70410293", "0.70332325", "0.6993134", "0.6974452", "0.6834735", "0.6823837", "0.6784931", "0.675881", "0.67258084", "0.66786194", "0.66656256", "0.66451037", "0.6641528", "0.66033554", "0.66009706", "0.658...
0.68403214
9
move 1 black from the left to the right by single/double rotation
def balanced_rotate_right ret = self if @left.right.red? and @left.left.black? ret = with_left(@left.rotate_left) end ret = ret.rotate_right ret = ret.with_left(ret.left.with_color(:black)) ret = ret.with_right(ret.right.with_color(:black)) ret end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rebalance_for_left_insert\n\t\t\t# move 1 black from the left to the right by single/double rotation\n\t\t\tif @left.right.red?\n\t\t\t\twith_left(@left.rotate_left)\n\t\t\telse\n\t\t\t\tself\n\t\t\tend.rotate_right\n\t\tend", "def rotateLeft()\n twoTypeRotate()\n end", "def right\n rotate(1)\n end...
[ "0.73496544", "0.7294807", "0.71041596", "0.6951446", "0.6894187", "0.68818694", "0.6835737", "0.6812482", "0.6791218", "0.676865", "0.675955", "0.6745097", "0.6703736", "0.67009443", "0.6700683", "0.66838795", "0.6683331", "0.6587869", "0.6565572", "0.6489003", "0.6462068", ...
0.6124121
58
Right single rotation (b a (D c E)) where D and E are red > (d (B a c) E) b d / \ / \ a D > B E / \ / \ c E a c
def rotate_left root = @right root = root.with_left(with_right(root.left)) root.with_left(root.left.with_color(root.color)).with_color(root.left.color) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotateRight()\n twoTypeRotate()\n end", "def right(values) # turn left\n multiple(values).each { |degree| rotate(-degree) }\n end", "def right\n rotate(1)\n end", "def rot #@\n a = pop\n b = pop\n c = pop\n push a\n push c\n push b\n end", "def rotate_right\n\t\t\troot = ...
[ "0.68585426", "0.68221223", "0.6702712", "0.66991735", "0.66850525", "0.63487315", "0.6338148", "0.6288738", "0.6262769", "0.62456584", "0.6236615", "0.61670464", "0.6159564", "0.614364", "0.6119147", "0.6114931", "0.610981", "0.6082348", "0.60796326", "0.60205024", "0.600890...
0.5701088
43
Left single rotation (d (B A c) e) where A and B are red > (b A (D c e)) d b / \ / \ B e > A D / \ / \ A c c e
def rotate_right root = @left root = root.with_right(with_left(root.right)) root.with_right(root.right.with_color(root.color)).with_color(root.right.color) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotate_left\n\t\t\troot = @right\n\t\t\troot = root.with_left(with_right(root.left))\n\t\t\troot.with_left(root.left.with_color(root.color)).with_color(root.left.color)\n\t\tend", "def rotateLeft()\n twoTypeRotate()\n end", "def balanced_rotate_left\n\t\t\tret = self\n\t\t\tif @right.left.red? and @rig...
[ "0.7023258", "0.696167", "0.68442565", "0.6684043", "0.6616354", "0.6604947", "0.65220654", "0.6507433", "0.6483288", "0.6481736", "0.6443606", "0.63911295", "0.63752604", "0.63744575", "0.6319282", "0.6315431", "0.63045514", "0.6297478", "0.62903684", "0.62828153", "0.626805...
0.6052096
30
Pull up red nodes (b (A C)) where A and C are red > (B (a c)) b B / \ > / \ A C a c
def pullup_red if black? and children_color?(:red) self .with_left(@left.with_color(:black)) .with_right(@right.with_color(:black)) .with_color(:red) else self end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bradth_first_search_colors(start_vertex, stop_vertex)\n queue = Array.new()\n queue << search_vertex(start_vertex)\n until queue.empty?\n temp_vertex = queue.shift()\n break if temp_vertex.value == stop_vertex #found stop condition\n vertex_edges = temp_vertex.edges.head\n until ve...
[ "0.6211305", "0.6044388", "0.59958106", "0.5869245", "0.55200404", "0.54922926", "0.54641795", "0.54592115", "0.5454157", "0.5424629", "0.5424629", "0.5424629", "0.5415026", "0.5393133", "0.5387538", "0.5369777", "0.53525007", "0.53238845", "0.53191185", "0.5309129", "0.52895...
0.5705979
4
trying to rebalance when the left subtree is 1 level higher than the right
def rebalance_for_left_insert # move 1 black from the left to the right by single/double rotation if @left.right.red? with_left(@left.rotate_left) else self end.rotate_right end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rebalance\n @root = build_tree(self.level_order_traversal) if !self.balanced?\n end", "def rebalance_for_left_delete\n\t\t\trebalance = false\n\t\t\t[if black?\n\t\t\t\tif @right.black?\n\t\t\t\t\tif @right.children_color?(:black)\n\t\t\t\t\t\t# make whole sub-tree 1 level lower and ask rebalance\n\t\t\t...
[ "0.78712916", "0.77382064", "0.74593663", "0.73431283", "0.7187748", "0.68918395", "0.68376696", "0.67275155", "0.67128545", "0.6575647", "0.6502814", "0.6468967", "0.6302808", "0.62986994", "0.6256126", "0.6228179", "0.62175906", "0.6209053", "0.6201165", "0.6177824", "0.617...
0.6421763
12
trying to rebalance when the right subtree is 1 level higher than the left See rebalance_for_left_insert.
def rebalance_for_right_insert if @right.left.red? with_right(@right.rotate_right) else self end.rotate_left end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rebalance_for_left_delete\n\t\t\trebalance = false\n\t\t\t[if black?\n\t\t\t\tif @right.black?\n\t\t\t\t\tif @right.children_color?(:black)\n\t\t\t\t\t\t# make whole sub-tree 1 level lower and ask rebalance\n\t\t\t\t\t\trebalance = true\n\t\t\t\t\t\twith_right(@right.with_color(:red))\n\t\t\t\t\telse\n\t\t\t\t...
[ "0.7847813", "0.71376055", "0.7063886", "0.6945651", "0.6832934", "0.68292713", "0.66300875", "0.6568706", "0.65426767", "0.64573854", "0.6297762", "0.6280453", "0.62099767", "0.6186664", "0.61574036", "0.61488694", "0.61382973", "0.6113784", "0.6100483", "0.60863274", "0.608...
0.78713375
0
returns [deleted_node, new_root, is_rebalance_needed]
def delete(key) [self, self, false] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rebalance_for_left_delete\n\t\t\trebalance = false\n\t\t\t[if black?\n\t\t\t\tif @right.black?\n\t\t\t\t\tif @right.children_color?(:black)\n\t\t\t\t\t\t# make whole sub-tree 1 level lower and ask rebalance\n\t\t\t\t\t\trebalance = true\n\t\t\t\t\t\twith_right(@right.with_color(:red))\n\t\t\t\t\telse\n\t\t\t\t...
[ "0.6228211", "0.60935915", "0.6038389", "0.5958039", "0.58135515", "0.57320046", "0.5684231", "0.5575381", "0.55705225", "0.5567542", "0.5533082", "0.5487792", "0.5483143", "0.54649687", "0.5441352", "0.5394745", "0.53617644", "0.53479755", "0.5347343", "0.5341605", "0.530758...
0.0
-1
Generate and save a token for session login
def remember self.remember_token = User.new_token self.update_attribute(:remember_digest, User.digest(self.remember_token)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_session_token!\n update_attribute(:session_token, self.class.generate_token(:session_token)) unless session_token\n session_token\n end", "def generate_login_token!\n new_login_token = SecureRandom.hex(24)\n salt = SecureRandom.hex(24)\n hash = token_hash(new_login_token,...
[ "0.81292397", "0.7804292", "0.7744607", "0.76644033", "0.76316917", "0.753115", "0.7472859", "0.7454598", "0.7443707", "0.74135727", "0.74116284", "0.7407889", "0.73860854", "0.73796034", "0.7374404", "0.7373664", "0.736813", "0.7354616", "0.7340505", "0.7339963", "0.7323983"...
0.0
-1
Forget user's token for session login
def forget self.remember_token = nil self.update_attribute(:remember_digest, nil) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_out\n current_user\n @current_user.auth_token = nil\n @current_user.save!\n @current_user = nil\n end", "def sign_out\n return unless current_user\n current_user.update_attribute(:session_token, nil)\n session.delete(:token)\n end", "def log_out\n current_user.reset_session_...
[ "0.79882973", "0.7918967", "0.7856073", "0.7853796", "0.78418654", "0.7809965", "0.7791699", "0.7790444", "0.7774179", "0.77711314", "0.7769899", "0.769286", "0.7645385", "0.7602226", "0.7601305", "0.75902855", "0.7574542", "0.75720435", "0.75720435", "0.75566363", "0.7540650...
0.0
-1
General autheticate method: return true if the given token match the digest
def autheticate?(key, token) digest_s = send("#{key.to_s.downcase}_digest") return false if digest_s.nil? BCrypt::Password.new(digest_s).is_password?(token) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticated?(digest, token)\n digest = send(\"#{digest}_digest\")\n # Use metaprogramming to select the appropriate token attribute based on\n # the parameter digest.\n return false if digest.nil? # Digest does not exist in the database.\n BCrypt::Password.new(digest).is_password?(token)\n ...
[ "0.7646236", "0.73847604", "0.73458225", "0.7340617", "0.7340617", "0.7156156", "0.71372294", "0.70584327", "0.70322794", "0.7019449", "0.70000684", "0.69616807", "0.6948799", "0.6942918", "0.6935834", "0.69255996", "0.69068456", "0.6887714", "0.688746", "0.68860507", "0.6878...
0.7504594
1
Send password reset email
def send_passwordreset_email UserMailer.password_reset(self).deliver_now end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_password_reset_email\n\t\tUserMailer.password_reset(id, self.reset_token).deliver_later\n \tend", "def password_reset(user)\n mail_to user, password_reset_subject\n end", "def send_password_reset_email\n \t\tUserMailer.password_reset(self).deliver_now\n \tend", "def send_password_reset_email\r\...
[ "0.87050885", "0.8538759", "0.8519959", "0.8510297", "0.8500065", "0.8500065", "0.8500065", "0.8497979", "0.84949267", "0.8488065", "0.84844804", "0.84772575", "0.8475632", "0.84753233", "0.8469188", "0.8466721", "0.8466721", "0.846197", "0.846197", "0.8440772", "0.8438158", ...
0.8472813
14
Return true if current user is following the other user
def following?(other_user) following.include?(other_user) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def following?(other_user)\n following.include?(other_user)\n end", "def following?(other_user)\n following.include?(other_user)\n end", "def following?(other_user)\n following.include?(other_user)\n end", "def following?(other_user)\n following.include?(other_user)\n ...
[ "0.8604708", "0.8546088", "0.8546088", "0.8546088", "0.8506931", "0.8501601", "0.8501175", "0.8494672", "0.8494672", "0.8494672", "0.8494672", "0.8494672", "0.8494672", "0.8494672", "0.8494672", "0.8494672", "0.8494672", "0.8494672", "0.8494672", "0.8494672", "0.8494672", "...
0.85639316
4
def cap_name self.name = name.capitalize end
def full_name "#{name} (#{urname})" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def capitalize_name\n self.name = self.name.split.collect(&:capitalize).join(' ') if self.name && !self.name.blank?\n end", "def capitalize_name\n self.name = name.sub(/\\S/, &:upcase) unless name.nil?\n end", "def name=(name)\r\n @name = name.capitalize\r\n end", "def name\n @name.capitalize\...
[ "0.892453", "0.8632073", "0.8598712", "0.84600043", "0.84600043", "0.83651996", "0.83263063", "0.82646173", "0.8190378", "0.8135183", "0.8127681", "0.8051332", "0.80110824", "0.79692", "0.79416424", "0.79410094", "0.7837473", "0.7832676", "0.7778657", "0.773759", "0.77370685"...
0.0
-1
puts factorial_r(3) puts factorial_r(5) puts factorial_r(10)
def factorial_n(num) result = 1 num.times { |i| result *= i + 1 } result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def factorial_r(n)\n return 1 if n.zero?\n n * factorial(n-1)\nend", "def factorial(n)\nend", "def ncr(n, r)\n factorial = lambda do |e|\n e == 1 ? (return 1) : (return e * factorial.call(e - 1))\n end\n puts factorial.call(n) / (factorial.call(n - r) * factorial.call(r))\nend", "def factorial(number...
[ "0.7849796", "0.7730369", "0.766255", "0.7617377", "0.7576795", "0.7576795", "0.75738716", "0.75634956", "0.7557336", "0.75566745", "0.7556598", "0.75229365", "0.7492757", "0.74838525", "0.74838525", "0.7483625", "0.7469024", "0.7467077", "0.74396455", "0.7434756", "0.7415323...
0.75299853
11
puts factorial_n(3) puts factorial_n(5) puts factorial_n(10)
def sumdig_r(num, result = 0) if num < 10 result += num else result += num % 10 result = sumdig_r(num / 10, result) end result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def factorial(n)\nend", "def factorial(n)\n for i in (1...n)\n n = n * i\n # puts n\n end\n puts n\nend", "def factorial(n)\n\t\n\tif n == 0\n\t\tputs(1)\n\t\treturn 1\n\tend\n\t\n\tfactored = n\n\tidx = 0\n\t\n\twhile idx < n\n\t\tfactored = n*(n - idx)\n\t\tidx += 1\n\t\tputs(factored)\n...
[ "0.83837664", "0.81440026", "0.8104133", "0.8070312", "0.8068149", "0.806699", "0.8058627", "0.8055137", "0.8053639", "0.8049287", "0.80462694", "0.8019539", "0.8001124", "0.7983479", "0.7961538", "0.79601526", "0.79586524", "0.79586524", "0.7953248", "0.7945328", "0.79305106...
0.0
-1
puts sumdig_r(103) puts sumdig_r(232480) puts sumdig_n(103) puts sumdig_n(232480)
def palindrome_r(word) if word.length == 1 or word.length == 0 true else if word[0] == word[-1] palindrome_r(word[1..-2]) else false end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sumdig_r(n)\n\n # puts \"#{n} and n /10 is #{n/10} and n%10 is #{n%10}\"\n\n if (n<10) \n return n\n else\n return n%10 + sumdig_r(n/10)\n end\nend", "def sumdig_r(n)\n return n if n < 10\n (n%10) + sumdig_r(n/10)\nend", "def sumdig_r(n)\n if n.is_a? Integer\n sumdig_r(n.to_s)\n elsif n.em...
[ "0.7288461", "0.7230059", "0.7117475", "0.7083463", "0.7047498", "0.7035164", "0.6914094", "0.6849141", "0.6829346", "0.68215156", "0.6686565", "0.6650013", "0.6618475", "0.6601813", "0.6601813", "0.65602636", "0.65337694", "0.6533379", "0.6521993", "0.64858824", "0.6474795",...
0.0
-1
GET /rates GET /rates.json
def index @capitaria_rates = Rate.where(provider: 'Capitaria').order(created_at: :desc).limit(20) @yahoo_rates = Rate.where(provider: 'Yahoo').order(created_at: :desc).limit(20) @bloomberg_rates = Rate.where(provider: 'Bloomberg').order(created_at: :desc).limit(20) @capitaria_last_day_records = Rate.where(provider: 'Capitaria').where('created_at >= ?', 1.day.ago).count @yahoo_last_day_records = Rate.where(provider: 'Yahoo').where('created_at >= ?', 1.day.ago).count @bloomberg_last_day_records = Rate.where(provider: 'Bloomberg').where('created_at >= ?', 1.day.ago).count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_rates(options={})\n post 'rates/full', options\n end", "def retrieve_rates(date)\n path = \"http://openexchangerates.org/api/historical/#{date.to_s}.json?app_id=#{$app_id}\"\n response = Net::HTTP.get_response(URI.parse path)\n # TODO: error handling\n response.body\nend", "def index\n ...
[ "0.8344988", "0.7524491", "0.7316692", "0.7316692", "0.7316692", "0.7316692", "0.7283847", "0.7235492", "0.7118768", "0.70982623", "0.70658576", "0.6975384", "0.69591737", "0.6901802", "0.6901802", "0.686592", "0.68418103", "0.6808352", "0.67117864", "0.66926205", "0.66534084...
0.0
-1
GET /rates/1 GET /rates/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_rates(options={})\n post 'rates/full', options\n end", "def retrieve_rates(date)\n path = \"http://openexchangerates.org/api/historical/#{date.to_s}.json?app_id=#{$app_id}\"\n response = Net::HTTP.get_response(URI.parse path)\n # TODO: error handling\n response.body\nend", "def get_rate...
[ "0.7984309", "0.7515229", "0.7470758", "0.7162541", "0.7162541", "0.7162541", "0.7162541", "0.6971502", "0.69671905", "0.6946672", "0.69297755", "0.6875909", "0.68355215", "0.67793715", "0.67728627", "0.67728627", "0.66860044", "0.66568625", "0.66017497", "0.6567657", "0.6561...
0.0
-1
POST /rates POST /rates.json
def create @rate = Rate.new(rate_params) respond_to do |format| if @rate.save format.html { redirect_to @rate, notice: 'Rate was successfully created.' } format.json { render :show, status: :created, location: @rate } else format.html { render :new } format.json { render json: @rate.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_rates(options={})\n post 'rates/full', options\n end", "def create\n @rate = Rate.new(rate_params)\n\n respond_to do |format|\n if @rate.save\n format.html { redirect_to @rate, notice: \"Rate was successfully created.\" }\n format.json { render :show, status: :created...
[ "0.729802", "0.71823835", "0.7122677", "0.69582325", "0.69225514", "0.6839394", "0.6608555", "0.6455903", "0.6386331", "0.6221252", "0.62046933", "0.6204487", "0.6152905", "0.60762006", "0.6036734", "0.60316", "0.5990832", "0.5990832", "0.5990832", "0.5990832", "0.59877336", ...
0.7185949
3
PATCH/PUT /rates/1 PATCH/PUT /rates/1.json
def update respond_to do |format| if @rate.update(rate_params) format.html { redirect_to @rate, notice: 'Rate was successfully updated.' } format.json { render :show, status: :ok, location: @rate } else format.html { render :edit } format.json { render json: @rate.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @rate.update(rate_params)\n format.html { redirect_to @rate, notice: 'Rate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rate.errors, stat...
[ "0.70509726", "0.7002979", "0.6638165", "0.6600082", "0.6594059", "0.6522167", "0.65126455", "0.64546824", "0.6421903", "0.63644576", "0.6354856", "0.63404804", "0.6273681", "0.6260687", "0.6257235", "0.62257534", "0.616257", "0.6157499", "0.6143535", "0.61383575", "0.6131534...
0.70037067
3
DELETE /rates/1 DELETE /rates/1.json
def destroy @rate.destroy respond_to do |format| format.html { redirect_to rates_url, notice: 'Rate was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @rate.destroy\n respond_to do |format|\n format.html { redirect_to rates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rate = Rate.find(params[:id])\n @rate.destroy\n\n respond_to do |format|\n format.html { redirect_to(rates_url) }\n ...
[ "0.77900356", "0.77002066", "0.7613073", "0.73322934", "0.7326656", "0.72486", "0.7243729", "0.71499616", "0.7091559", "0.7062138", "0.70191", "0.7012238", "0.6988189", "0.6968732", "0.6936847", "0.6885701", "0.687631", "0.6859727", "0.6844851", "0.67827874", "0.6734854", "...
0.76177055
4
Use callbacks to share common setup or constraints between actions.
def set_rate @rate = Rate.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.6165422", "0.60457647", "0.5946384", "0.5916027", "0.58905005", "0.583495", "0.5777223", "0.56995213", "0.56995213", "0.56532377", "0.5621348", "0.5422839", "0.54118705", "0.54118705", "0.54118705", "0.53935355", "0.5379617", "0.53577393", "0.53407264", "0.53398263", "0.53...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def rate_params params.require(:rate).permit(:provider, :usdclp, :eurclp, :gbpclp) 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
GET /inquries GET /inquries.json
def index @pid = params[:pid] @inquries = Inqury.where("pbuyer_id = ?", @pid).all #@inquries = Inqury.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @enquries = Enqury.all\n end", "def index\n @injuries = Injury.all\n end", "def index\n @specialties = Specialty.all\n\n render json: @specialties\n end", "def index\n render :json => UserInterest.all\n end", "def index\n @insurance_queries = InsuranceQuery.all\n\n resp...
[ "0.66131496", "0.63133556", "0.623409", "0.6069513", "0.5984998", "0.5978237", "0.5967606", "0.59155965", "0.59148866", "0.5896513", "0.58587134", "0.5847601", "0.58176607", "0.5799509", "0.57675517", "0.57550526", "0.57507414", "0.57492244", "0.5722636", "0.5681058", "0.5680...
0.57645714
15
GET /inquries/1 GET /inquries/1.json
def show @pid = params[:pid] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @specialties = Specialty.all\n\n render json: @specialties\n end", "def index\n @enquries = Enqury.all\n end", "def index\n @injuries = Injury.all\n end", "def show\n @county = County.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n forma...
[ "0.645034", "0.6316617", "0.6229689", "0.61557245", "0.60623854", "0.6049335", "0.59794104", "0.59721047", "0.5965314", "0.59531105", "0.5900764", "0.5893888", "0.58795494", "0.584703", "0.58358777", "0.5834503", "0.5830214", "0.5821659", "0.58102566", "0.5790586", "0.5790279...
0.0
-1
POST /inquries POST /inquries.json
def create @pid = inqury_params[:pbuyer_id] @inqury = Inqury.new(inqury_params) respond_to do |format| if @inqury.save format.html { redirect_to inqury_path(@inqury, :pid=>@pid), notice: 'Inqury was successfully created.' } format.json { render :show, status: :created, location: @inqury } else format.html { render :new } format.json { render json: @inqury.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @injury = Injury.new(injury_params)\n\n respond_to do |format|\n if @injury.save\n format.html { redirect_to injuries_url, notice: 'Injury was successfully created.' }\n # format.json { render :show, status: :created, location: @injury }\n else\n format.html { rende...
[ "0.5769896", "0.55163586", "0.54664207", "0.54123425", "0.52813786", "0.5267917", "0.5248755", "0.5238406", "0.5224689", "0.52196085", "0.5152864", "0.51117843", "0.5064075", "0.5063653", "0.50555015", "0.50513846", "0.50188833", "0.50123805", "0.49597752", "0.49360043", "0.4...
0.54323304
3
PATCH/PUT /inquries/1 PATCH/PUT /inquries/1.json
def update if (!(current_user.realtor?)) @pid = inqury_params[:pbuyer_id] respond_to do |format| if @inqury.update(inqury_params) format.html { redirect_to inqury_path(@inqury, :pid => @pid), notice: 'Inqury was successfully updated.' } format.json { render :show, status: :ok, location: @inqury } else format.html { render :edit } format.json { render json: @inqury.errors, status: :unprocessable_entity } end end end /**if (current_user.realtor?) @inqury = Inqury.find(params[:id]) if @inqury.update_attributes(inqury_params) flash[:success] = "Profile updated" redirect_to @inqury else render 'edit' end end*/ end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end", "def update\n respond_to do |format|\n if @uriy.update(uriy_params)\n format.html { redirect_to @uriy, notice: 'Uriy was successfully updated.' }\n format.json { head :no_content }\n else\n ...
[ "0.63902766", "0.6085555", "0.6084294", "0.60322624", "0.6012304", "0.6004167", "0.5963282", "0.5951966", "0.5936229", "0.59349144", "0.59273493", "0.59239167", "0.58974373", "0.5891171", "0.5866616", "0.586212", "0.5839973", "0.58276016", "0.5827197", "0.5819218", "0.5794345...
0.0
-1
DELETE /inquries/1 DELETE /inquries/1.json
def destroy @pid = params[:pid] @inqury.destroy respond_to do |format| format.html { redirect_to inquries_url(:pid => @pid), notice: 'Inqury was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @uriy.destroy\n respond_to do |format|\n format.html { redirect_to uriys_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def delete\...
[ "0.6853919", "0.68511385", "0.6809801", "0.67972875", "0.6706587", "0.6659393", "0.6653117", "0.66238266", "0.6606473", "0.6603025", "0.65637416", "0.6562006", "0.6561544", "0.65339106", "0.6475558", "0.6475423", "0.6457241", "0.6454116", "0.6451615", "0.644", "0.64310515", ...
0.66528684
7
Use callbacks to share common setup or constraints between actions.
def set_inqury @inqury = Inqury.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6162554", "0.60452986", "0.5945278", "0.59169763", "0.58877826", "0.5834763", "0.5775349", "0.5704972", "0.5704972", "0.56543803", "0.5621491", "0.5427202", "0.54093206", "0.54093206", "0.54093206", "0.53975695", "0.53776276", "0.53562194", "0.5340594", "0.5337824", "0.532...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def inqury_params params.require(:inqury).permit(:subject, :content, :pbuyer_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69795185", "0.6782116", "0.6745877", "0.6742722", "0.67368543", "0.65932566", "0.65048057", "0.6497429", "0.6481512", "0.6478456", "0.6455591", "0.64391", "0.6379068", "0.6376498", "0.636542", "0.632084", "0.630046", "0.62998945", "0.62943697", "0.6293775", "0.629097", "...
0.0
-1
Check if there has been an indexed help command.
def help? return true if @commands[:help] false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_help?\n help.present?\n end", "def has_help_hint?\n help_hint.present?\n end", "def help?()\n return @help\n end", "def asking_for_help?\n if !block_given?\n return @j_del.java_method(:isAskingForHelp, []).call()\n end\n raise ArgumentError, \"Invalid...
[ "0.8005471", "0.74653965", "0.742436", "0.7169469", "0.71450305", "0.71088636", "0.70916194", "0.6918469", "0.6915729", "0.68982905", "0.68893516", "0.6858351", "0.6726921", "0.6607152", "0.6579255", "0.6573395", "0.6459582", "0.6387652", "0.6374699", "0.63608044", "0.6357261...
0.77110386
1
Explicitly remove the default help menu from the application.
def remove_default_help_menu @remove_default_help_menu = true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_help_menu_removed?\n @remove_default_help_menu || false\n end", "def show_help\n system 'clear'\n puts HELP_COMMANDS\n end", "def dont_exit_on_help=(val) #:nodoc:\n @@exit = true\n end", "def on_help(menu)\n end", "def strip_help_param!\n @help_given = ARGV.dele...
[ "0.7317207", "0.6429828", "0.6375395", "0.62767553", "0.61779124", "0.60938317", "0.6055401", "0.60403943", "0.5981513", "0.5930365", "0.59223294", "0.5920561", "0.5879494", "0.58084774", "0.5792159", "0.5769346", "0.5769346", "0.57290876", "0.5707901", "0.56885195", "0.56768...
0.90124583
0
Check if the default help menu for the application has been explicitly removed.
def default_help_menu_removed? @remove_default_help_menu || false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_default_help_menu\n @remove_default_help_menu = true\n end", "def has_help?\n help.present?\n end", "def dump_help_if_requested\n return unless self[:help]\n dump_help\n exit\n end", "def exit_on_help? #:nodoc:\n @@exit rescue false\n end", "def shown_in...
[ "0.7943798", "0.67748535", "0.66487366", "0.65371704", "0.6390415", "0.6357322", "0.63495505", "0.63258666", "0.6251276", "0.6203068", "0.6200303", "0.6163361", "0.6139171", "0.6128357", "0.61171126", "0.60751224", "0.6064661", "0.60535103", "0.60381764", "0.603572", "0.60180...
0.8834316
0
An application usually has multiple commands. == Example app = CommandLion::App.build meta information command :example1 do more code end command :example2 do more code end end app.commands.map(&:name) => [:example1, :example2]
def command(index, &block) if index.is_a? Command cmd = index else cmd = Command.new cmd.index= index cmd.instance_eval(&block) end @commands = {} unless @commands @flags = [] unless @flags if cmd.flags? @flags << cmd.flags.short if cmd.flags.short? @flags << cmd.flags.long if cmd.flags.long? elsif cmd.index # just use index @flags << cmd.index.to_s else raise "No index or flags were given to use this command." end if cmd.options? cmd.options.each do |_, option| if option.flags? @flags << option.flags.short if option.flags.short? @flags << option.flags.long if option.flags.long? else # just use index @flags << option.index.to_s end @commands[option.index] = option end end @commands[cmd.index] = cmd cmd end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_commands\n puts template(:all, {\n app: File.basename(@app),\n\n cmds: ::WeatherSage::CLI::Help::COMMANDS.values.map { |cmd|\n template(:cmd, cmd)\n }.join(\"\\n\"),\n\n envs: ::WeatherSage::CLI::Env::VARS.map { |row|\n template(:env, row)\n }.join(\"\\n\\n\"),\n ...
[ "0.6955833", "0.680299", "0.6764362", "0.6711139", "0.6681364", "0.6599017", "0.6591512", "0.6584164", "0.6569689", "0.65275705", "0.65231335", "0.6499361", "0.64773625", "0.6464795", "0.6424038", "0.63727534", "0.6370562", "0.6351306", "0.6335029", "0.63316035", "0.6327137",...
0.0
-1
Plugin a command that's probably been built outside of the application's run or build block. This is helpful for sharing or reusing commands in applications.
def plugin(command) command(command) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def command(*args,&block)\n return @working_command if @working_command\n name, options = _parse_name_and_options(args,self.name)\n @working_command = cmd = Command.new({:plugin=>self,:name=>name}.merge(options))\n yield(cmd) if block\n bot.add_command(cmd)\n @working_command=nil \n @commands ...
[ "0.63474846", "0.6209791", "0.61912227", "0.6177977", "0.60983837", "0.5978801", "0.59744924", "0.5962719", "0.59527546", "0.58497006", "0.58242816", "0.5822889", "0.5758717", "0.5754095", "0.5744098", "0.56647706", "0.56429684", "0.5628665", "0.5593234", "0.55669546", "0.556...
0.7029909
0
Direct access to the various flags an application has. Helpfulp for debugging.
def flags @flags end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flags \n @flags ||= {}\n end", "def flags #:nodoc:\n @flags ||= {}\n end", "def flags; end", "def std_flags\n # FIXME: this is bogus\n m = method(:help_text)\n boolean :help, :flag => \"h\", :doc => \"display this help\"\n boolean :verbose, :flag => \"v\", :doc...
[ "0.7353415", "0.7183023", "0.7173637", "0.68560433", "0.6846262", "0.6840549", "0.6769763", "0.675647", "0.675647", "0.67374086", "0.66644615", "0.66583014", "0.6615931", "0.66092026", "0.66055197", "0.66055197", "0.65801096", "0.65606654", "0.6560483", "0.64981496", "0.64904...
0.7552747
1
Direct access to the various commands an application has. Helpful for debugging.
def commands @commands.reject { |_, v| v.is_a? CommandLion::Option } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commands\n COMMANDS\n end", "def commands; end", "def commands\r\n @help_commands\r\n end", "def commands\n self.class.commands\n end", "def get_commands\n return nil\n end", "def commands\n abstract!\n end", "def commands\n {\n 'help' => 'H...
[ "0.7513509", "0.73652244", "0.7098825", "0.7096183", "0.7019345", "0.69694364", "0.6958181", "0.69295967", "0.6896132", "0.6865836", "0.6856643", "0.68357974", "0.68249327", "0.6811033", "0.67682725", "0.6757741", "0.67364925", "0.67364925", "0.67364925", "0.67364925", "0.673...
0.0
-1
Parse arguments off of ARGV.
def parse @commands.each do |_, cmd| if cmd.flags? # or for the || seems to not do what I want it to do... next unless argv_index = ARGV.index(cmd.flags.short) || ARGV.index(cmd.flags.long) else next unless argv_index = ARGV.index(cmd.index.to_s) end cmd.given = true unless argv_index.nil? if cmd.type.nil? yield cmd if block_given? else if parsed = parse_cmd(cmd, flags) cmd.arguments = parsed || cmd.default yield cmd if block_given? elsif cmd.default cmd.arguments = cmd.default yield cmd if block_given? end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse argv\n parse_args argv do |argv, remaining_args, arg|\n remaining_args << arg\n end\n end", "def parse\n @opts = OptionParser.new { |opts| process_opts(opts) }\n @opts.parse!(@args)\n\n process_args\n\n @options\n end", "def parse_arguments\n @arguments...
[ "0.7543042", "0.75206524", "0.73760444", "0.72035027", "0.71372074", "0.7134906", "0.7117602", "0.7089817", "0.7073194", "0.6995288", "0.6993077", "0.69710016", "0.69603455", "0.6957026", "0.6941961", "0.690406", "0.689077", "0.6811794", "0.6793345", "0.678118", "0.6764574", ...
0.0
-1
Parse a given command with its given flags.
def parse_cmd(cmd, flags) if cmd.flags? args = Raw.arguments_to(cmd.flags.short, flags) if args.nil? || args.empty? args = Raw.arguments_to(cmd.flags.long, flags) end else args = Raw.arguments_to(cmd.index.to_s, flags) end unless cmd.type.to_s =~ /stdin/ return nil if args.nil? end case cmd.type when :stdin args = STDIN.gets.strip when :stdin_stream args = STDIN when :stdin_string args = STDIN.gets.strip when :stdin_strings args = [] while arg = STDIN.gets next if arg.nil? arg = arg.strip args << arg end args when :stdin_integer args = STDIN.gets.strip.to_i when :stdin_integers args = [] while arg = STDIN.gets next if arg.nil? arg = arg.strip parse = arg.to_i if parse.to_s == arg args << parse end end args when :stdin_bool args = STDIN.gets.strip.downcase == "true" when :single, :string args = args.first when :strings, :multi if cmd.delimiter? if args.count > 1 args = args.first.split(cmd.delimiter) else args = args.map { |arg| arg.split(cmd.delimiter) }.flatten end end args when :integer args = args.first.to_i when :integers if cmd.delimiter? if args.count > 1 args = args.join args = args.select { |arg| arg if arg.include?(cmd.delimiter) } args = args.map { |arg| arg.split(cmd.delimiter) }.flatten else args = args.map { |arg| arg.split(cmd.delimiter) }.flatten end end args = args.map(&:to_i) when :bool, :bools if cmd.delimiter? if args.count > 1 args = args.join args = args.select { |arg| arg if arg.include?(cmd.delimiter) } args = args.map { |arg| arg.split(cmd.delimiter) }.flatten else args = args.map { |arg| arg.split(cmd.delimiter) }.flatten end end args = args.map { |arg| arg == "true" } end rescue => e# this is dangerous puts e nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_command\n log_and_exit read_template('help') if @input.empty?\n @command = @input.shift\n \n while @input.any?\n opt = @input.shift\n \n if opt =~ /^--(\\w+)(=(\"[^\"]+\"|[\\w]+))*/\n name = $1\n value = $3 ? $3.gsub(/\"/, \"\") : true\n ...
[ "0.69158053", "0.6642431", "0.6623775", "0.6598312", "0.6587462", "0.65561235", "0.643085", "0.6416031", "0.6354811", "0.6326861", "0.632034", "0.6150497", "0.6145646", "0.61436474", "0.61384386", "0.6123003", "0.6117516", "0.6105158", "0.607328", "0.6071375", "0.6047857", ...
0.73165506
0
Use callbacks to share common setup or constraints between actions.
def set_complaint @complaint = Complaint.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.6165422", "0.60457647", "0.5946384", "0.5916027", "0.58905005", "0.583495", "0.5777223", "0.56995213", "0.56995213", "0.56532377", "0.5621348", "0.5422839", "0.54118705", "0.54118705", "0.54118705", "0.53935355", "0.5379617", "0.53577393", "0.53407264", "0.53398263", "0.53...
0.0
-1
Only allow a list of trusted parameters through.
def complaint_params params.require(:complaint).permit(:user, :invoice, :order, :issue_date, :notes, :qa_notes, :status, :with_vendor, :dc, :customer_code, :lot, :po_number, :rep_id, :rep_name, complaint_parts_attributes: [ :id, :part_code, :part_desc, :uom, :invoice_qty, :issue1, :issue1_description, :issue2, :issue2_description, :qty, :each_check, :lot_numb, :lot_expiry_date, :part_status ], complaint_images_attributes: [ :id, :image ] ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.69490993", "0.6812977", "0.6801889", "0.67950445", "0.6745037", "0.6740698", "0.65270424", "0.6519444", "0.6492448", "0.6430671", "0.6430671", "0.6430671", "0.63992614", "0.6355569", "0.6354901", "0.63456345", "0.63430274", "0.63376623", "0.6327184", "0.6327184", "0.632718...
0.0
-1