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
In the event that we're not using cursors, define cursor to proxy to find_each.
def cursor CursorProxy.new(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_each(options = {})\n rows = retrieve_records(options) #private method\n\n rows.each do |row|\n init_object_from_row(row)\n end\n end", "def each(&block)\n find_each(&block)\n end", "def each\n find.each { |found| yield(found) }\n end", "def each( & block )\n \n ...
[ "0.6762657", "0.67579806", "0.6680226", "0.6597433", "0.6588257", "0.65515673", "0.6430347", "0.6373623", "0.6364553", "0.6298065", "0.6255314", "0.61929685", "0.61694837", "0.60990596", "0.60416853", "0.6035235", "0.6023177", "0.60105115", "0.5918038", "0.5887194", "0.586265...
0.63429177
9
TODO : change to fit story searching and ownership
def allow_to # owner of story can do anything? editing? super :owner, :all => true # approved users can create new stories super :user, :only => [:show, :index, :search, :new, :create] # everybody can list and watch super :all, :only => [:show, :index, :search] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_story\n stories=self.community.stories.order(\"created_at DESC\")\n if stories.size>0\n new_last=stories[0].id\n new_stories=[]\n time=[]\n stories.each do |story|\n if story.id!=self.last_examined_story\n if story.content?\n if story.content.include?((...
[ "0.6384793", "0.6238101", "0.5986232", "0.596742", "0.596742", "0.5910782", "0.5901907", "0.5875402", "0.5874939", "0.5871677", "0.5862201", "0.5857731", "0.58080566", "0.5793118", "0.5786073", "0.578209", "0.57701963", "0.5718381", "0.5701871", "0.5701871", "0.5699789", "0...
0.0
-1
Accepts an array of values between 0 and 100 to represent the combo progress values. As there is a limit to the number of colors, only the first five elements of the array will be used. An error will be raised if the values passed in are greater than 100 when summed. An options hash may also be passed to the method, with a boolean option available for :tiny
def combo_progress_bar percentages, *opts validate_percentages(percentages[0..4]) options = opts.extract_options! html_classes = setup_default_container_classes if options[:tiny] && options[:tiny] == true handle_tiny_classes(html_classes) end mortice_html = content_tag(:div, :class => html_classes[:mortice_classes].join(' ')) do percentages[0..4].each_with_index do |p, i| concat(bar_div((html_classes[:bar_classes] + [bar_colors[i]]), bar_style(p))) end end content_tag :div, mortice_html, :class => html_classes[:container_classes].join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def progress(arr, options = {})\n bar = ProgressBar.new arr.length, options\n bar.show\n arr.each { |v| bar.increment yield(v) }\n end", "def color(*values); end", "def color(*values); end", "def color_gauge_values(type = 'adobeRGB')\n # rubocop:disable Layout/SpaceInsideArrayLiteralBracke...
[ "0.5877021", "0.56489974", "0.56489974", "0.5608083", "0.555596", "0.5382999", "0.5350682", "0.53466624", "0.52819926", "0.5270297", "0.5194839", "0.516366", "0.5153548", "0.51339585", "0.5079455", "0.50292885", "0.50032586", "0.49948052", "0.49895036", "0.49720922", "0.49442...
0.5899774
0
Raising errors was kind of stupid for single progress bars, so instead return the percentage amount if it's betwee 0 and 100. If it's > 100, return 100. If it's < 0, return 0.
def scrub_percentage percentage p = percentage.to_i return p if (0..100).to_a.include?(p) p > 100 ? 100 : 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remaining_percent\n (remaining_pints.to_f)/(124.to_f)\n end", "def undeliverable_percent\n total, fails = total_count, messages_given_up_on_count\n if total == 0\n return 0\n elsif fails == 0\n return 0\n else\n return (fails / total) * 100\n end\n end", "def percentage_n...
[ "0.7310228", "0.7222596", "0.71419644", "0.71419644", "0.71357924", "0.7109722", "0.7099424", "0.70935285", "0.70506716", "0.7009375", "0.69942665", "0.6988994", "0.6947659", "0.69463736", "0.69089967", "0.6902227", "0.68745464", "0.6830455", "0.6830455", "0.6828938", "0.6809...
0.6774254
22
TODO make people controller use this method too The challenge for that is the devise connections
def create_user(user_hash, community_id, invitation_id = nil) raise ArgumentError.new("Email #{user_hash[:email]} is already in use.") unless Email.email_available?(user_hash[:email], community_id) begin puts "kunal#{user_hash}" username = generate_username(user_hash[:given_name], user_hash[:family_name], community_id) locale = user_hash[:locale] || APP_CONFIG.default_locale # don't access config like this, require to be passed in in ctor person = Person.new( given_name: user_hash[:given_name], family_name: user_hash[:family_name], password: user_hash[:password], username: username, locale: locale, is_admin: user_hash[:is_admin] || 0, test_group_number: 1 + rand(4), community_id: community_id) email = Email.new(person: person, address: user_hash[:email].downcase, send_notifications: true, community_id: community_id) person.emails << email person.inherit_settings_from(Community.find(community_id)) if community_id ActiveRecord::Base.transaction do person.save! person.set_default_preferences user = from_model(person) # The first member will be made admin make_user_a_member_of_community(user[:id], community_id, invitation_id) email = Email.find_by_person_id!(user[:id]) community = Community.find(community_id) # send email confirmation (unless disabled for testing environment) if APP_CONFIG.skip_email_confirmation || community.people.count <= 1 email.confirm! begin Delayed::Job.enqueue(SendWelcomeEmail.new(user[:id], community_id), priority: 5) rescue end else Email.send_confirmation(email, community) end Result::Success.new(user) end rescue Result::Error.new("Failed to create a new user") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def devise_controller?; end", "def fetch_details_from_devise\n self.username = 'devise_user'\n self.save\n end", "def meraki_auth_users\r\n MerakiAuthUsersController.instance\r\n end", "def devise_mappings; end", "def warden; end", "def warden; end", "def warden; end", "def user \n ...
[ "0.64830965", "0.61673886", "0.6147793", "0.6057395", "0.59164476", "0.59164476", "0.59164476", "0.59098035", "0.5878319", "0.5875658", "0.5875658", "0.5875658", "0.58727974", "0.584031", "0.58354616", "0.58354616", "0.5835315", "0.5784957", "0.57689327", "0.57689327", "0.575...
0.0
-1
helper_method :current_user def current_user
def configure_permitted_parameters update_attrs = [:first_name, :last_name, :schooldistrict_id, :email, :password, :password_confirmation, :current_password] create_attrs = [:first_name, :last_name, :schooldistrict_id, :role, :school_id, :email, :password, :password_confirmation] devise_parameter_sanitizer.permit(:sign_up) do |user_params| user_params.permit(create_attrs) end devise_parameter_sanitizer.permit(:account_update) do |user_params| user_params.permit(update_attrs) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_method\n current_user\n end", "def current_user\n user.user\n end", "def current_user\n User.current\n end", "def current_user\n\t\tview_context.current_user\n\tend", "def current_user(user)\n @current_user = user\n end", "def current_user\n @current_user\n end", "def cur...
[ "0.8338086", "0.8178084", "0.81779456", "0.8163153", "0.8161514", "0.8150546", "0.8150546", "0.8150546", "0.8150546", "0.8077711", "0.79567856", "0.7956693", "0.7956693", "0.7956693", "0.7956693", "0.7956693", "0.7956693", "0.7956693", "0.7956693", "0.79408836", "0.7939905", ...
0.0
-1
Shrink the master pane by 10%
def master_shrink(text) center = text.layout.options[:center] text.layout.options[:center] -= 0.1 if center > 0.1 text.layout.apply end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resize_active_pane(new_size, type)\n pane = Tmux.call \"list-panes | grep active | cut -d: -f1\"\n if type == :horizontal\n Tmux.call \"resize-pane -t #{pane} -x #{new_size}\"\n else\n Tmux.call \"resize-pane -t #{pane} -y #{new_size}\"\n end\n end", "def master_grow(text...
[ "0.559964", "0.5591719", "0.55326676", "0.5502995", "0.5364476", "0.53505766", "0.5244963", "0.5175016", "0.5113098", "0.5090932", "0.5071935", "0.50649446", "0.5055303", "0.5047347", "0.50461555", "0.5034706", "0.49728248", "0.4945745", "0.49063337", "0.48864195", "0.4883391...
0.5910559
0
Grow the master pane by 10%
def master_grow(text) center = text.layout.options[:center] text.layout.options[:center] += 0.1 if center < 0.9 text.layout.apply end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def grow \n\t\t@height += 1\n\tend", "def grow\n @is_growing =true\n end", "def refresh()\n # Filling the parent that is at the root of the screen is apparently broken :/.\n @holder.set_height(@parent.get_height_fit - @holder.get_y)\n set_height(@holder.get_height - get_y)\n end", "def ...
[ "0.64365834", "0.63282377", "0.58170515", "0.55492795", "0.55389875", "0.52946496", "0.52905273", "0.5211081", "0.5186682", "0.5180422", "0.51751", "0.5159772", "0.51279086", "0.5087583", "0.50681627", "0.5036694", "0.5027364", "0.49304378", "0.48926258", "0.48769155", "0.486...
0.63033503
2
Center the split between masters and slaves
def master_equal(text) text.layout.options[:center] = 0.5 text.layout.apply end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def center\n end", "def center!\n @ob.center\n self\n end", "def center\n move(90)\n end", "def become_master\n @master = Master.new\n @number = 0\n @master.nodes[0] = self\n @master.configure_cloud\n configure\n end", "def center\n\t\ttop_right_vert / ...
[ "0.63977724", "0.59636515", "0.58603925", "0.5718247", "0.5712929", "0.56923974", "0.5577073", "0.5562767", "0.5472187", "0.547094", "0.54604954", "0.54604954", "0.5458528", "0.54416615", "0.54121554", "0.540424", "0.5369792", "0.5350975", "0.53363484", "0.5296027", "0.528927...
0.4827507
100
Provide a root path helper for the gem root dir Returns Pathname
def root Pathname.new(File.dirname(__dir__)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def root_path\n Pathname.new(File.expand_path(File.join(__dir__, '..', '..')))\nend", "def gem_root\n Pathname.new(__FILE__).dirname.parent.parent.expand_path\n end", "def root\n Pathname.new File.expand_path('../../', File.dirname(__FILE__))\n end", "def root_path(path) File.join(root, path) ...
[ "0.7436459", "0.7322013", "0.72549", "0.7165925", "0.71344924", "0.709488", "0.7086737", "0.70294297", "0.695704", "0.6949951", "0.68637913", "0.6838938", "0.68011105", "0.67884684", "0.6783093", "0.67743087", "0.67658746", "0.6734301", "0.67222947", "0.671724", "0.6715869", ...
0.74096614
1
Initialize a new ApiResource with an optional config. Will default to the global [Iterable::Config] via `Iterable.config`
def initialize(conf = nil) @conf = conf || default_config end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(api_key:, resource:)\n super(api_key: api_key)\n @resource = resource\n end", "def api(options = {})\n @api ||= case url.host\n when String then RestClient::Resource.new(url.host, options)\n else RestClient::Resource.new(API_ENDPOINT.host, options)\n end\n end", ...
[ "0.6146835", "0.6097135", "0.5912882", "0.58994675", "0.5873603", "0.58548105", "0.5792122", "0.5789683", "0.5764336", "0.5757974", "0.571967", "0.5714886", "0.5714048", "0.5711845", "0.5711845", "0.57021767", "0.5690878", "0.5690878", "0.56349987", "0.5606117", "0.55738133",...
0.0
-1
Global Iterable config accessor for instance
def default_config self.class.default_config end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each(&block)\n @_config.each(&block)\n end", "def config\n yield self\n end", "def config\n yield self\n end", "def config\n yield self\n end", "def config\n yield @@config_options\n end", "def config\n yield self\n end", "def method_missing(symbol, *args...
[ "0.6934758", "0.67618203", "0.67618203", "0.67618203", "0.67460567", "0.6724708", "0.665893", "0.6503496", "0.642626", "0.6386267", "0.63570464", "0.6345508", "0.6329865", "0.62827444", "0.6259192", "0.6256901", "0.6256901", "0.62550175", "0.6253194", "0.6252209", "0.62406695...
0.0
-1
the form will focus on the first focusable field
def form_data [{ cells: [ { title: "Title", name: :title, type: :text }, { title: "Due Date", name: :due_date, type: :datetime }, { title: "Completed", name: :completed, type: :check } ] }] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def focus\n return if !@focusable\n if @form.validate_field != -1\n @form.select_field @id\n end\n end", "def set_focus first_last\n if !@form.nil?\n # move to first field of existing form\n #@current_form = @current_tab.form # 2010-02-27 20:22 \n ...
[ "0.8236754", "0.7919015", "0.7835072", "0.78249294", "0.72967243", "0.71320134", "0.7054047", "0.6997363", "0.6962964", "0.6914291", "0.6897369", "0.6871618", "0.6871618", "0.67071265", "0.6667618", "0.6621294", "0.65751815", "0.6509886", "0.650439", "0.6493531", "0.6426247",...
0.0
-1
"private" means that the methods defined here are methods internal to the object. (You can feed your dragon, but you can't ask him if he's hungry.)
def hungry? # Method names can end with "?". # Usually, we only do this if the method # returns true or false, like this: @stuffInBelly <= 2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def a_private_method\n\tend", "def a_private_method\n end", "def private_method; end", "def private_method\n end", "def private_method\n\tend", "def private_method\n\tend", "def private_methods(all=true) end", "def internal_methods; end", "def private_method\n end", "def private=(_); end",...
[ "0.8718584", "0.8604007", "0.8582299", "0.83688104", "0.83175075", "0.83175075", "0.77348936", "0.77124715", "0.76738614", "0.7410212", "0.7372984", "0.7353842", "0.7249416", "0.722881", "0.72106165", "0.71932214", "0.71783614", "0.71733326", "0.71371937", "0.7091135", "0.707...
0.0
-1
assuming the block has BlockFace
def contacting_block(block) face = block.state.data.facing unless face warn "block #{block}'s face is nil" nil end block.location.clone.tap {|loc| loc.subtract(face.mod_x, face.mod_y, face.mod_z) }.block end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getBlockType posX posY\n\t\t# true: lugar vazio ou com bloco de buff\n\t\t# false: demais ocasioes\n\tend", "def face\n end", "def blck\n MegaBar::Block.find(1)\nend", "def block_type\n @grpc.block_type.to_sym\n end", "def get_blocks\n @blocks\n end", "def get_bl...
[ "0.61602837", "0.6129431", "0.582761", "0.5786694", "0.5721249", "0.5693738", "0.569259", "0.5638199", "0.563022", "0.5627568", "0.5627568", "0.5622886", "0.5607745", "0.56019557", "0.56004745", "0.56004745", "0.55917215", "0.5551348", "0.5545782", "0.5506262", "0.5493497", ...
0.7146579
0
the logic went to neocloft/fastdash def on_player_toggle_sprint(evt) player_update_speed(evt.player, spp: evt.sprinting?) return if evt.player.passenger && Squid === evt.player.passenger if evt.sprinting? && !evt.player.passenger if evt.player.location.clone.add(0, 1, 0).block.type == Material::SAND evt.cancelled = true else
def ctf_sneaking(player) passenger = player.passenger if passenger && Squid === passenger msg = "#{player.name} put a flag on #{player.location.block.type.to_s.downcase}." broadlingr msg player.eject later 0 do vel = player.velocity player.send_message [vel.get_x, vel.get_z].map(&:to_s).to_s passenger.velocity = vel.tap {|v| v.set_x(v.get_x * 1.5) v.set_y(v.get_y + 0.8) v.set_z(v.get_z * 1.5) } end else squid = player.get_nearby_entities(0.8, 0.8, 0.8).find {|e| Squid === e } if squid smoke_effect(squid.location) play_sound(player.location, Sound::EAT, 1.0, 2.0) play_sound(player.location, Sound::EAT, 1.0, 0.0) player.set_passenger squid player.walk_speed = 0.1 end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_player_toggle_sneak(evt)\n player = evt.player\n return unless %w[world world_nether].include?(player.location.world.name)\n\n #if player.name == 'ujm'\n # #location_around(add_loc(player.location, 0, 5, 0), 5).map(&:block).each {|b| b.type = Material::AIR if b.type != Material::AIR }\n # l...
[ "0.6881923", "0.6698587", "0.6087751", "0.6085459", "0.60425705", "0.59879375", "0.59122735", "0.57927305", "0.57480973", "0.571131", "0.5703357", "0.57020754", "0.5696359", "0.56881654", "0.5669516", "0.5665207", "0.5654654", "0.5624266", "0.5624266", "0.5615013", "0.5600148...
0.7058977
0
HARD_BOOTS = [Material::CHAINMAIL_BOOTS, Material::IRON_BOOTS, Material::DIAMOND_BOOTS, Material::GOLD_BOOTS]
def on_player_toggle_sneak(evt) player = evt.player return unless %w[world world_nether].include?(player.location.world.name) #if player.name == 'ujm' # #location_around(add_loc(player.location, 0, 5, 0), 5).map(&:block).each {|b| b.type = Material::AIR if b.type != Material::AIR } # location_around_flat(loc_below(player.location), 5).map(&:block).each {|b| b.type = Material::GRASS if b.type != Material::AIR } # player.perform_command 'dynmap render' #end # Superjump name = player.name @crouching_counter ||= {} @crouching_counter[name] ||= 0 @crouching_countingdown ||= false if evt.sneaking? # counting up @crouching_counter[name] += 1 later sec(2.0) do @crouching_counter[name] -= 1 end if @crouching_counter[name] == 4 play_sound(add_loc(player.location, 0, 5, 0), Sound::BAT_TAKEOFF, 1.0, 0.0) # evt.player.send_message "superjump!" player.fall_distance = 0.0 player.velocity = player.velocity.tap {|v| v.set_y jfloat(1.4) } end # map teleport if player.location.pitch == 90.0 item = player.item_in_hand if item && item.type == Material::MAP map = Bukkit.get_map(item.data.data) loc = block2loc(map.world.get_highest_block_at(map.center_x, map.center_z)) loc = add_loc(loc, 0, 3, 0) loc.pitch = 90.0 loc.yaw = player.location.yaw loc.chunk.load animals = player.get_nearby_entities(2, 2, 2).select {|e| Player === e } move_livings = [player] + animals play_effect(player.location, Effect::ENDER_SIGNAL, nil) play_sound(player.location, Sound::ENDERMAN_TELEPORT , 1.0, 0.5) move_livings.each do |e| e.velocity = e.velocity.tap {|v| v.set_y 1.0 } end later sec(0.5) do move_livings.select(&:valid?).each do |e| e.teleport(loc) e.fall_distance = 0.0 play_effect(player.location, Effect::ENDER_SIGNAL, nil) play_sound(loc, Sound::ENDERMAN_TELEPORT , 1.0, 0.5) end end end end ctf_sneaking(player) if @ctf_players.member?(player) end #player_update_speed(evt.player, snp: evt.sneaking?) #player = evt.player #if player.equipment.boots && HARD_BOOTS.include?(player.equipment.boots.type) # if !evt.player.on_ground? && evt.sneaking? # later 0 do # newloc = player.location # newloc.x = newloc.x.to_i.to_f - 0.5 # newloc.z = newloc.z.to_i.to_f - 0.5 # player.teleport newloc # play_effect(newloc, Effect::ENDER_SIGNAL) # player.velocity = Vector.new(0.0, -1.0, 0.0) # end # loc = (1..4).lazy. # map {|y| evt.player.location.clone.add(0, -y, 0) }. # find {|l| l.block.type != Material::AIR } # later sec(0.2) do # if loc && loc.block.type == Material::STONE # loc.block.break_naturally(ItemStack.new(Material::DIAMOND_PICKAXE)) # end # end # end #end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def material_use\n materials = []\n materials\n end", "def intialize\n @buns = [:wheat, :lettuce, :cheeto, :cotton_candy, :seaweed, :classic]\n end", "def createShieldBooster\n shield1 = ShieldBooster.new(\"S1\",2.0,10)\n shield2 = ShieldBooster.new(\"S2\",3.0,20)\n shield3 = Sh...
[ "0.60246825", "0.57707286", "0.56391776", "0.5426713", "0.54243183", "0.53730077", "0.5339566", "0.53280973", "0.5256143", "0.524604", "0.51950365", "0.5137562", "0.5124282", "0.5119264", "0.51159936", "0.51145196", "0.5112611", "0.5103595", "0.5096368", "0.50939053", "0.5065...
0.0
-1
def player_update_speed(player, spp: player.sprinting?, snp: player.sneaking?) if spp or !snp if evt.player.location.clone.add(0, 1, 0).block.type == Material::SAND evt.cancelled = true else player.walk_speed = 0.5 end else player.walk_speed = 0.2 end end
def later(tick, &block) Bukkit.getScheduler.scheduleSyncDelayedTask(@plugin, block, tick) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def speed\n if @sprinting\n @stage.speed * 2\n else\n @stage.speed\n end\n end", "def set_speed(new_speed:)\n if new_speed > 30\n new_speed = 30\n elsif new_speed < 0\n new_speed = 0\n end\n @curr_speed = new_speed \n end", "def walk\n @speed = 2\n end", "def pe...
[ "0.66928154", "0.65864015", "0.6504858", "0.64949", "0.6492448", "0.64893085", "0.6427586", "0.6352376", "0.6341267", "0.6337221", "0.6275888", "0.62701315", "0.6231618", "0.6195116", "0.61677366", "0.61522406", "0.61347455", "0.6094191", "0.60844755", "0.6080735", "0.6056058...
0.0
-1
Following hardcoded values were taken from this project.
def test_root_hash_when_its_empty assert_equal( 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', MT::Tree.new.root_hash ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def user_os_complex\r\n end", "def constants() end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def extra; end", "def custom; end", "def custom; end", "def internal; end", "def who_we_are\r\n end", "def used_names...
[ "0.74864495", "0.6065764", "0.60199124", "0.6004647", "0.59548813", "0.59548813", "0.59548813", "0.59548813", "0.5939755", "0.5870292", "0.5870292", "0.5771673", "0.57692206", "0.5764669", "0.5757705", "0.5747998", "0.56782013", "0.5666006", "0.56621665", "0.56621665", "0.562...
0.0
-1
(see perform_later) The same as perform_later except always returns the job wrapped in a ::Dry::Monad::Result.
def try_perform_later(...) job = job_or_instantiate(...) result = job.enqueue yield job if block_given? return Failure(job) if result == false Success(job) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_later(*args, &block)\n later(:perform, *args, &block)\n end", "def perform_later(*args, **options)\n __debug_job(__method__) { \"options = #{item_inspect(options)}\" } # TODO: remove\n job_warn { \"ignoring method args #{args.inspect}\" } if args.present?\n enqueue(options)\n en...
[ "0.74722457", "0.73437", "0.6550563", "0.63518304", "0.6250418", "0.62213475", "0.6143387", "0.61314833", "0.6094741", "0.60903823", "0.60884017", "0.5994332", "0.5986819", "0.59626955", "0.5948203", "0.58954", "0.5880405", "0.5824421", "0.57773614", "0.5694596", "0.56505275"...
0.7506096
0
GET /schemas GET /schemas.json
def index @schemas = Schema.all respond_to do |format| format.html # index.html.erb format.json { render json: @schemas } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_schemas\n @schemas\n end", "def schema(name)\n get(\"schemas/#{name}/\", \"schema\")\n end", "def index\n @schemas = Schema.all\n end", "def list_schemas request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n ...
[ "0.7785935", "0.7075703", "0.7000159", "0.694187", "0.68900514", "0.67245686", "0.6670885", "0.6667396", "0.6665426", "0.65922844", "0.65616107", "0.6523897", "0.6522732", "0.64845926", "0.64710695", "0.6447554", "0.6384607", "0.6355451", "0.63078487", "0.6305946", "0.6296037...
0.7503958
1
GET /schemas/1 GET /schemas/1.json
def show @schema = Schema.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @schema } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @schemas = Schema.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @schemas }\n end\n end", "def schema(name)\n get(\"schemas/#{name}/\", \"schema\")\n end", "def get_schemas\n @schemas\n end", "def show\n respond_wi...
[ "0.7336309", "0.71765584", "0.71732247", "0.6926575", "0.6848029", "0.68221635", "0.6514743", "0.6426365", "0.6348491", "0.6344177", "0.63350266", "0.632904", "0.63071024", "0.61941326", "0.6173472", "0.6136425", "0.61362404", "0.61262053", "0.61187613", "0.6099534", "0.60972...
0.68974435
4
GET /schemas/new GET /schemas/new.json
def new @schema = Schema.new respond_to do |format| format.html # new.html.erb format.json { render json: @schema } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @schema = Schema.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @schema }\n end\n end", "def create\n @schema = Schema.new(params[:schema])\n\n respond_to do |format|\n if @schema.save\n format.html { redirect_to @schema...
[ "0.7697514", "0.69616044", "0.6860507", "0.6842365", "0.6755747", "0.6755747", "0.6167935", "0.61543953", "0.6129025", "0.59249604", "0.5918281", "0.5917389", "0.58719", "0.5864813", "0.58603245", "0.58471006", "0.5827676", "0.5755215", "0.5709458", "0.56962794", "0.56924325"...
0.77320236
0
POST /schemas POST /schemas.json
def create @schema = Schema.new(params[:schema]) respond_to do |format| if @schema.save format.html { redirect_to @schema, notice: 'Schema was successfully created.' } format.json { render json: @schema, status: :created, location: @schema } else format.html { render action: "new" } format.json { render json: @schema.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @schema = Schema.new(params[:schema])\n\n respond_to do |format|\n if @schema.save\n format.html { redirect_to @schema, :notice => 'Schema was successfully created.' }\n format.json { render :json => @schema, :status => :created, :location => @schema }\n else\n for...
[ "0.68638325", "0.6744033", "0.6744033", "0.62998176", "0.62864786", "0.61325157", "0.6007038", "0.5936588", "0.58221865", "0.5805748", "0.57501006", "0.5737968", "0.57032865", "0.5690577", "0.5673389", "0.5657231", "0.5637035", "0.5637035", "0.559254", "0.55769324", "0.555659...
0.67851794
1
PUT /schemas/1 PUT /schemas/1.json
def update @schema = Schema.find(params[:id]) respond_to do |format| if @schema.update_attributes(params[:schema]) format.html { redirect_to @schema, notice: 'Schema was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @schema.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update!(**args)\n @json_schemas = args[:json_schemas] if args.key?(:json_schemas)\n @schema = args[:schema] if args.key?(:schema)\n end", "def update\n @schema = Schema.find(params[:id])\n\n respond_to do |format|\n if @schema.update_attributes(params[:schema])\n fo...
[ "0.7065401", "0.6741016", "0.6514748", "0.6514748", "0.6341389", "0.62851983", "0.6284941", "0.6188828", "0.61393", "0.61393", "0.5932914", "0.59237003", "0.58473283", "0.5835803", "0.5835803", "0.5834633", "0.578411", "0.57693976", "0.5749092", "0.5749092", "0.5724216", "0...
0.66959083
2
DELETE /schemas/1 DELETE /schemas/1.json
def destroy @schema = Schema.find(params[:id]) @schema.destroy respond_to do |format| format.html { redirect_to schemas_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @schema.destroy\n respond_to do |format|\n format.html { redirect_to schemas_url, notice: 'Schema was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @schema.destroy\n respond_to do |format|\n format.html { redirect_to schema...
[ "0.74063116", "0.74063116", "0.74063116", "0.687832", "0.6836731", "0.67953867", "0.6793458", "0.66883314", "0.6464844", "0.6335721", "0.6284438", "0.6276053", "0.62403077", "0.6204645", "0.6204245", "0.6199376", "0.619427", "0.61660594", "0.6165754", "0.6164912", "0.61494684...
0.767044
1
This method should be moved into a Mixin that's included into ActionController::Base and ActionView::Base (copy the methods used by render() in both cases).
def render_node(node) instance_variable_set("@#{node.class.name.singularize.underscore}", node) render :template => "#{node.class.name.tableize}/show" rescue ActionView::MissingTemplate render :template => "nodes/show" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render\n raise NotImplementedError\n end", "def render\n raise NotImplementedError\n end", "def render!; raise NotImplementedError end", "def render\n raise NotImplementedError, \"Subclasses must implement a render method\"\n end", "def render\n raise NotImpleme...
[ "0.75151247", "0.7506746", "0.7492783", "0.7422766", "0.74156564", "0.74055415", "0.74055415", "0.74055415", "0.74055415", "0.74055415", "0.7373662", "0.7296936", "0.72116864", "0.7118701", "0.7118701", "0.7118701", "0.7107164", "0.70863885", "0.7056854", "0.7056854", "0.7028...
0.0
-1
GET /ingredients GET /ingredients.json
def index @ingredients = Ingredient.paginate(page: params[:page], per_page: 5) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_ingredients\n rid = params[:id]\n items = Aws.get_ingredients_from_db(rid)\n render :json => items\n end", "def ingredients_by_recipe\n recipe = Recipe.find(params[:id])\n render json: recipe.ingredients\n end", "def ingredient_data\n respond_to do |format|\n format.json { ren...
[ "0.8275298", "0.79046065", "0.73819345", "0.7343373", "0.7311198", "0.7250235", "0.7139022", "0.7129334", "0.7098152", "0.70739114", "0.7063159", "0.7023298", "0.698452", "0.698452", "0.69825983", "0.6942599", "0.6941932", "0.6919147", "0.6855856", "0.6855856", "0.6803994", ...
0.6189371
67
GET /ingredients/1 GET /ingredients/1.json
def show @ingredient_recettes = @ingredient.recettes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_ingredients\n rid = params[:id]\n items = Aws.get_ingredients_from_db(rid)\n render :json => items\n end", "def ingredients_by_recipe\n recipe = Recipe.find(params[:id])\n render json: recipe.ingredients\n end", "def show\n params.require(%i[id])\n render json: Ingredient.find_b...
[ "0.79940003", "0.788936", "0.7566463", "0.7531003", "0.74188334", "0.73733646", "0.7350761", "0.7282355", "0.7211195", "0.71441513", "0.7120503", "0.7106303", "0.70800036", "0.7016235", "0.6978926", "0.6972189", "0.6941257", "0.6941257", "0.6913198", "0.6897089", "0.68653595"...
0.0
-1
POST /ingredients POST /ingredients.json
def create @ingredient = Ingredient.new(ingredient_params) if @ingredient.save flash[:success] = "Ajout de l'ingredient réussi..." redirect_to ingredient_path @ingredient else flash[:success] = "Ajout de l'ingredient réussi..." render :new end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n ingredient = Ingredient.create(ingredient_params)\n render json: ingredient\n end", "def add_ingredients\n rid = params['id']\n name = params['name']\n quant = params['quantity']\n meas = params['measurement']\n\n ingredients = {\n 'name' => name,\n 'quantit...
[ "0.7749055", "0.7590346", "0.7465898", "0.74050695", "0.73933405", "0.7286979", "0.7167695", "0.716602", "0.71002847", "0.7087613", "0.70036024", "0.6972241", "0.69679314", "0.6920982", "0.6916151", "0.68945533", "0.68943995", "0.6876029", "0.68722105", "0.6858264", "0.679180...
0.6150832
87
PATCH/PUT /ingredients/1 PATCH/PUT /ingredients/1.json
def update if @ingredient.update(ingredient_params) flash[:success] = "M.a.j de l'ingredient réussi..." redirect_to ingredient_path @ingredient else render :edit end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end", "def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n params[:recipe][:ingredients].each do |ingredient_id|\n next if ingredient_id.to_i == 0\n ingredient = In...
[ "0.7531993", "0.7479023", "0.72812", "0.72163236", "0.71652097", "0.71519494", "0.714327", "0.70659006", "0.7012339", "0.6954271", "0.69370455", "0.6928726", "0.6905849", "0.6867407", "0.6829218", "0.68042463", "0.6786987", "0.67719764", "0.67654246", "0.6748962", "0.6747415"...
0.5968537
92
DELETE /ingredients/1 DELETE /ingredients/1.json
def destroy @ingredient.destroy flash[:success] = 'Ingredient was successfully destroyed.' redirect_to ingredients_url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @ingredient = Ingredient.find(params[:id])\n @ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to ingredients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n rid = params['id']\n if Aws.delete_recipe(rid) && Aws.delete_all_ing...
[ "0.77837", "0.76880884", "0.762181", "0.75857395", "0.7466892", "0.7466892", "0.7439309", "0.74335265", "0.73938143", "0.737191", "0.73332864", "0.73048156", "0.7302452", "0.7301305", "0.72931135", "0.7272132", "0.7252403", "0.72393656", "0.72384703", "0.7223783", "0.7174711"...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_ingredient @ingredient = Ingredient.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 ingredient_params params.require(:ingredient).permit(:ingredientnom) 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
If the field is part of a repeater, then the after_update callback isn't triggered until the dirty checking data has been reset, so use force = true instead
def reconfigure(force = false) return unless json_config_changed? && !force && image&.asset.present? image.asset.reprocess! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_update\n true\n end", "def before_update; end", "def before_update\n# @line_item.name = \"foo\"\n end", "def after_update(updated)\n # not required\n end", "def before_update_save(record); end", "def adjust_after_update\n # The record is in @record, do what you will, this...
[ "0.6263768", "0.608103", "0.6056231", "0.587441", "0.58605194", "0.5849725", "0.5774145", "0.5746084", "0.56845176", "0.56688046", "0.5641699", "0.5577334", "0.5569485", "0.55595887", "0.55595887", "0.5556141", "0.5551927", "0.5523496", "0.5523496", "0.55000204", "0.5482581",...
0.0
-1
Generates a writer method for this association. Serves as a point for accessing the objects in the association. For example, this method could generate the following: def pirate_attributes=(attributes) assign_nested_attributes_for_one_to_one_association(:pirate, attributes) end This redirects the attempts to write objects in an association through the helper methods defined below. Makes it seem like the nested associations are just regular associations.
def generate_association_writer(association_name, type) generated_association_methods.module_eval <<-eoruby, __FILE__, __LINE__ + 1 if method_defined?(:#{association_name}_attributes=) remove_method(:#{association_name}_attributes=) end def #{association_name}_attributes=(attributes) assign_nested_attributes_for_#{type}_association(:#{association_name}, attributes) end eoruby end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_property_writer(association_name, _type)\n generated_association_methods.module_eval <<-eoruby, __FILE__, __LINE__ + 1\n if method_defined?(:#{association_name}_attributes=)\n remove_method(:#{association_name}_attributes=)\n end\n def #{associati...
[ "0.6416264", "0.60130215", "0.5919125", "0.56993455", "0.5645148", "0.55584234", "0.5490966", "0.54606175", "0.54533947", "0.5453086", "0.5429548", "0.54229575", "0.5406108", "0.5387145", "0.53719646", "0.5367781", "0.5363324", "0.53551716", "0.535509", "0.5347862", "0.532966...
0.67288196
0
Generates a writer method for this association. Serves as a point for accessing the objects in the association. For example, this method could generate the following: def pirate_attributes=(attributes) assign_nested_attributes_for_one_to_one_association(:pirate, attributes) end This redirects the attempts to write objects in an association through the helper methods defined below. Makes it seem like the nested associations are just regular associations.
def generate_property_writer(association_name, _type) generated_association_methods.module_eval <<-eoruby, __FILE__, __LINE__ + 1 if method_defined?(:#{association_name}_attributes=) remove_method(:#{association_name}_attributes=) end def #{association_name}_attributes=(attributes) attribute_will_change!(:#{association_name}) resource.#{association_name}_attributes=(attributes) end eoruby end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_association_writer(association_name, type)\n generated_association_methods.module_eval <<-eoruby, __FILE__, __LINE__ + 1\n if method_defined?(:#{association_name}_attributes=)\n remove_method(:#{association_name}_attributes=)\n end\n def #{associa...
[ "0.6727134", "0.6012714", "0.5919312", "0.570027", "0.56447977", "0.5558683", "0.5493181", "0.5460198", "0.5454961", "0.54549086", "0.5431375", "0.54244447", "0.54083085", "0.53900945", "0.537162", "0.53686076", "0.53661346", "0.53576773", "0.5354681", "0.5347437", "0.5332073...
0.64145094
1
Returns ActiveFedora::Basemarked_for_destruction? It's used in conjunction with fields_for to build a form element for the destruction of this association. See ActionView::Helpers::FormHelper::fields_for for more info.
def _destroy marked_for_destruction? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def marked_for_destruction?\n @marked_for_destruction\n end", "def mark_for_destruction\n @marked_for_destruction = true\n end", "def mark_for_destruction\n @marked_for_destruction = true\n end", "def is_marked_for_delete?\n return @mark_for_delete\n end", "def _dele...
[ "0.7798111", "0.69120854", "0.68844104", "0.6748204", "0.67271155", "0.63412803", "0.63268524", "0.62077856", "0.62052864", "0.62014806", "0.6194774", "0.6192994", "0.6192994", "0.6192994", "0.6189898", "0.6185616", "0.61696833", "0.61407876", "0.6117701", "0.611489", "0.6110...
0.65472513
5
Assigns the given attributes to the association. If an associated record does not yet exist, one will be instantiated. If an associated record already exists, the method's behavior depends on the value of the update_only option. If update_only is +false+ and the given attributes include an :id that matches the existing record's id, then the existing record will be modified. If no :id is provided it will be replaced with a new record. If update_only is +true+ the existing record will be modified regardless of whether an :id is provided. If the given attributes include a matching :id attribute, or update_only is true, and a :_destroy key set to a truthy value, then the existing record will be marked for destruction.
def assign_nested_attributes_for_one_to_one_association(association_name, attributes) options = nested_attributes_options[association_name] attributes = attributes.to_h if attributes.respond_to?(:permitted?) attributes = attributes.with_indifferent_access existing_record = send(association_name) if (options[:update_only] || attributes['id'].present?) && existing_record && (options[:update_only] || existing_record.id.to_s == attributes['id'].to_s) assign_to_or_mark_for_destruction(existing_record, attributes, options[:allow_destroy]) unless call_reject_if(association_name, attributes) elsif attributes['id'].present? raise_nested_attributes_record_not_found!(association_name, attributes['id']) elsif !reject_new_record?(association_name, attributes) assignable_attributes = attributes.except(*UNASSIGNABLE_KEYS) if existing_record&.new_record? existing_record.assign_attributes(assignable_attributes) association(association_name).initialize_attributes(existing_record) else method = "build_#{association_name}" raise ArgumentError, "Cannot build association `#{association_name}'. Are you trying to build a polymorphic one-to-one association?" unless respond_to?(method) send(method, assignable_attributes) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_with(attributes)\n assign_attributes(attributes)\n end", "def update_or_create(attributes = {})\n id = attributes.delete(:id)\n conditions = attributes.delete(:conditions)\n\n returning (id && find_by_id(id)) || find(:first, :conditions => conditions) || new do |record|\n ...
[ "0.59755594", "0.59220827", "0.5918796", "0.58548164", "0.5813882", "0.5782088", "0.57085234", "0.57034403", "0.5666227", "0.56347585", "0.5612369", "0.5605117", "0.55929583", "0.5592597", "0.55895656", "0.55883604", "0.55883604", "0.55883604", "0.55883604", "0.5570591", "0.5...
0.5576294
19
Takes in a limit and checks if the attributes_collection has too many records. It accepts limit in the form of symbol, proc, or numberlike object (anything that can be compared with an integer). Raises TooManyRecords error if the attributes_collection is larger than the limit.
def check_record_limit!(limit, attributes_collection) return unless limit limit = case limit when Symbol send(limit) when Proc limit.call else limit end raise TooManyRecords, "Maximum #{limit} records are allowed. Got #{attributes_collection.size} records instead." if limit && attributes_collection.size > limit end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_records_limit\n if current_user.records_limit_reached?\n flash[:alert] = 'Sorry, you have reached the maximum number of records.'\n redirect_to records_path and return\n end\n end", "def check_limit_per_source\n attr_name = attribute_name.downcase\n if new_record? && An...
[ "0.66130507", "0.64826614", "0.6323564", "0.6311756", "0.62507504", "0.6217686", "0.61830425", "0.6148532", "0.61470157", "0.6117312", "0.605864", "0.5992534", "0.5975766", "0.5950154", "0.5915132", "0.590669", "0.5901852", "0.5869118", "0.5869118", "0.5869118", "0.58593786",...
0.9110953
0
Updates a record with the +attributes+ or marks it for destruction if +allow_destroy+ is +true+ and has_destroy_flag? returns +true+.
def assign_to_or_mark_for_destruction(record, attributes, allow_destroy) record.attributes = attributes.except(*UNASSIGNABLE_KEYS) record.mark_for_destruction if has_destroy_flag?(attributes) && allow_destroy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assign_to_or_mark_for_destruction(record, attributes, allow_destroy)\n if has_destroy_flag?(attributes) && allow_destroy\n record.mark_for_destruction\n else\n record.attributes = attributes.except(*UNASSIGNABLE_KEYS)\n end\n end", "def should_destroy_nested_attributes_record?...
[ "0.7702459", "0.6652276", "0.6542136", "0.64399254", "0.62657785", "0.62613565", "0.60957205", "0.5909574", "0.5865051", "0.58342695", "0.5800415", "0.5800415", "0.5800415", "0.5800415", "0.5791451", "0.5769408", "0.57572526", "0.5749316", "0.5743124", "0.57032764", "0.570327...
0.76485676
1
Determines if a hash contains a truthy _destroy key.
def has_destroy_flag?(hash) Type::Boolean.new.cast(hash['_destroy']) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_destroy_flag?( hash )\n ActiveFedora::Type::Boolean.new.cast( hash['_destroy'] )\n end", "def has_destroy_flag?(hash)\n ActiveFedora::Type::Boolean.new.cast(hash['_destroy'])\n end", "def has_destroy_flag?(hash)\n ActiveFedora::Type::Boolean.new.cast(hash['_destroy'...
[ "0.84387475", "0.84357786", "0.8417373", "0.8417373", "0.840738", "0.78844076", "0.682348", "0.682348", "0.6814438", "0.6814438", "0.64228785", "0.6378702", "0.6326972", "0.63121754", "0.62166107", "0.6191046", "0.6187167", "0.61348635", "0.61300635", "0.6079948", "0.6075143"...
0.8417072
4
Determines if a new record should be rejected by checking has_destroy_flag? or if a :reject_if proc exists for this association and evaluates to +true+.
def reject_new_record?(association_name, attributes) will_be_destroyed?(association_name, attributes) || call_reject_if(association_name, attributes) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reject_new_record?(association_name, attributes)\n has_destroy_flag?(attributes) || call_reject_if(association_name, attributes)\n end", "def check_destroyable\n if self.destroyable?\n true\n else\n ## Some generic message to come here\n self.errors[:base] << 'This record has ass...
[ "0.7134806", "0.6937362", "0.644299", "0.61089003", "0.6097825", "0.6092699", "0.5940008", "0.593639", "0.59110904", "0.58967113", "0.5869166", "0.58482045", "0.5842874", "0.58126456", "0.5807725", "0.5802422", "0.57938325", "0.57916474", "0.57532316", "0.57402307", "0.573953...
0.64935553
2
Determines if a record with the particular +attributes+ should be rejected by calling the reject_if Symbol or Proc (if defined). The reject_if option is defined by +accepts_nested_attributes_for+. Returns false if there is a +destroy_flag+ on the attributes.
def call_reject_if(association_name, attributes) return false if will_be_destroyed?(association_name, attributes) opts = nested_attributes_options[association_name] case callback = opts[:reject_if] when Symbol method(callback).arity.zero? ? send(callback) : send(callback, attributes) when Proc callback.call(attributes) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call_reject_if(attributes)\n case reject_if\n when Symbol\n @collection_form_class.method(reject_if).arity == 0 ? @collection_form_class.send(reject_if) : @collection_form_class.send(reject_if, attributes)\n when Proc\n reject_if.call(attributes)\n else\n false\n e...
[ "0.7225162", "0.67559", "0.6749295", "0.6691719", "0.63452744", "0.6055962", "0.5945106", "0.59042376", "0.5625402", "0.5416591", "0.53961116", "0.53758293", "0.53729236", "0.53729236", "0.5363774", "0.53538615", "0.53483146", "0.5328496", "0.5328496", "0.5305507", "0.5303092...
0.6689979
4
Only take into account the destroy flag if :allow_destroy is true
def will_be_destroyed?(association_name, attributes) allow_destroy?(association_name) && has_destroy_flag?(attributes) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allow_destroy?\n true\n end", "def destroyable?\n true\n end", "def destroyable?\n true\n end", "def before_destroy\n # can_destroyed?\n end", "def before_destroy\n # can_destroyed?\n end", "def before_destroy\n # can_destroyed?\n end", "def is_destroyable?\n\t\t...
[ "0.8165773", "0.77220273", "0.77220273", "0.7717832", "0.7717832", "0.7717832", "0.7695168", "0.7524737", "0.751344", "0.751344", "0.7510125", "0.7475028", "0.7450395", "0.7367046", "0.7353055", "0.7347996", "0.7307721", "0.72684234", "0.72603023", "0.72163856", "0.71924007",...
0.6928291
35
Render body of message with params.
def render_body(params) render_custom(body, params) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def body\n render text: fetch_email(params[:id]).body, content_type: 'text/html'\n end", "def message_render(message)\n render(partial: \"message\", locals: { message: message })\n end", "def render_to_body(options = {})\n\t end", "def render_to_body(options = {})\n end", "def render_body(con...
[ "0.6534825", "0.6426984", "0.6395184", "0.63602424", "0.6332051", "0.63286555", "0.63084966", "0.61794513", "0.6158515", "0.6119645", "0.6116655", "0.6107851", "0.6061245", "0.6024948", "0.6007933", "0.5993782", "0.59669816", "0.5919207", "0.59077555", "0.5879717", "0.5818509...
0.7528532
0
Replaces variables in the template
def render_custom(template, params) if (template != nil) blank = Liquid::Template.parse(template) blank.render(params) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def replaceVariables\n\t\t@template = @template.gsub! \"###namespace###\", @namespace\n\t\t@template = @template.gsub! \"###model-name###\", @modelName\n\t\t@template = @template.gsub! \"###properties###\", @properties\n\tend", "def replaceVariables\n\t\t@template = @template.gsub! \"###namespace###\", @namespac...
[ "0.8166964", "0.7955009", "0.70877594", "0.7051279", "0.6682648", "0.66410613", "0.6512105", "0.6442414", "0.6429124", "0.6429124", "0.6429124", "0.6429124", "0.6429124", "0.6429124", "0.6429124", "0.6429124", "0.6429124", "0.6429124", "0.6429124", "0.6429124", "0.6429124", ...
0.0
-1
Billing related API Endpoints
def account_billing_get(*args) params = Zoom::Params.new(Utils.extract_options!(args)) params.require(:account_id) Utils.parse_response self.class.get("/accounts/#{params[:account_id]}/billing", headers: request_headers) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def billing\n request('billing', :get)\n end", "def purchase billing, number\r\n # the base uri for api requests\r\n query_builder = Configuration.BASE_URI.dup\r\n\r\n # prepare query string for API call\r\n query_builder << \"/tns/{number}\"\r\n\r\n # process optional query para...
[ "0.77159536", "0.70811635", "0.6913816", "0.67656046", "0.66125715", "0.6413112", "0.6370078", "0.63109386", "0.63074654", "0.6260635", "0.6159998", "0.61485666", "0.6120462", "0.6104335", "0.6061585", "0.59800214", "0.5968283", "0.5964857", "0.5963885", "0.5963491", "0.59035...
0.60109305
15
instance methods: save_graph, graph
def test_graph output_message(@test_root_name) test_instance_1 = test_instance_2 = nil # setup VCR.use_cassette("#{@test_root_name}/setup") do status = TestModel.destroy!('instance_1') assert status == true status = TestModel.destroy!('instance_2') assert status == true status = TestModel.destroy!('instance_101') assert status == true status = TestModel.destroy!('instance_102') assert status == true test_instance_1 = TestModel.create!(id: 'instance_1', name: 'test_1a', desc: 'desc_1a') assert test_instance_1 != false test_instance_2 = TestModel.create!(id: 'instance_2', name: 'test_2a', desc: 'desc_2a') assert test_instance_2 != false test_instance_3 = TestModel.create!(id: 'instance_101', name: 'test_101', desc: 'desc_101') assert test_instance_3 != false test_instance_4 = TestModel.create!(id: 'instance_102', name: 'test_102', desc: 'desc_102') assert test_instance_4 != false end # test VCR.use_cassette("#{@test_root_name}/synopsis") do graph_instances = test_instance_1.graph('add_100_or_more') assert graph_instances != nil assert graph_instances.length == 0 graph_instance = test_instance_1.save_graph('add_100_or_more', 'test_models', 'instance_101') assert graph_instance != false assert graph_instance == test_instance_1 graph_instance = test_instance_1.save_graph('add_100_or_more', 'test_models', 'instance_102') assert graph_instance != false assert graph_instance == test_instance_1 graph_instance = test_instance_2.save_graph('add_100_or_more', 'test_models', 'instance_102') assert graph_instance != false assert graph_instance == test_instance_2 graph_instance = test_instance_1.save_graph('add_99_or_less', 'test_models', 'instance_2') assert graph_instance != false assert graph_instance == test_instance_1 graph_instance = test_instance_2.save_graph('add_99_or_less', 'test_models', 'instance_101') assert graph_instance != false assert graph_instance == test_instance_2 graph_instances = test_instance_1.graph('add_100_or_more') assert graph_instances.length == 2 graph_instances = test_instance_1.graph('add_99_or_less') assert graph_instances.length == 1 graph_instances = test_instance_2.graph('add_100_or_more') assert graph_instances.length == 1 graph_instances = test_instance_2.graph('add_99_or_less') assert graph_instances.length == 1 status = test_instance_1.delete_graph('add_100_or_more', 'test_models', 'instance_101') assert status != false status = test_instance_1.delete_graph('add_100_or_more', 'test_models', 'instance_102') assert status != false status = test_instance_2.delete_graph('add_100_or_more', 'test_models', 'instance_102') assert status != false status = test_instance_1.delete_graph('add_99_or_less', 'test_models', 'instance_2') assert status != false status = test_instance_2.delete_graph('add_99_or_less', 'test_models', 'instance_101') assert status != false graph_instances = test_instance_1.graph('add_100_or_more') assert graph_instances != nil assert graph_instances.length == 0 graph_instances = test_instance_2.graph('add_100_or_more') assert graph_instances != nil assert graph_instances.length == 0 graph_instances = test_instance_1.graph('add_99_or_less') assert graph_instances != nil assert graph_instances.length == 0 graph_instances = test_instance_1.graph('add_99_or_less') assert graph_instances != nil assert graph_instances.length == 0 end # cleanup VCR.use_cassette("#{@test_root_name}/cleanup") do status = TestModel.destroy!('instance_1') assert status == true status = TestModel.destroy!('instance_2') assert status == true status = TestModel.destroy!('instance_101') assert status == true status = TestModel.destroy!('instance_102') assert status == true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_graph(kind, to_collection, to_key)\n retval orchio_put_graph(kind, to_collection, to_key)\n end", "def save_graph_values\n @dataset.graph_values.values = @values.fetch(:graph_values)\n @dataset.graph_values.save\n end", "def fill_save_graph( graph )\n raise \"#{self.to_...
[ "0.73993295", "0.7040085", "0.69627774", "0.6959275", "0.6892929", "0.66582507", "0.6480054", "0.6439594", "0.63845444", "0.626853", "0.6169306", "0.61527514", "0.6136423", "0.61224955", "0.60917574", "0.59671503", "0.59671503", "0.59671503", "0.59671503", "0.59671503", "0.59...
0.0
-1
GET /fdn/legend_categories GET /fdn/legend_categories.json
def index @fdn_legend_categories = Fdn::LegendCategory.show.paginate(page: params[:page]||1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_fdn_legend_category\n @fdn_legend_category = Fdn::LegendCategory.find(params[:id])\n end", "def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end", "def create\n @fdn_legend_category = Fdn::LegendCa...
[ "0.7095899", "0.6892624", "0.6832346", "0.6620129", "0.64153713", "0.63560104", "0.63143957", "0.6282771", "0.62540627", "0.61864626", "0.61728764", "0.61419046", "0.6130537", "0.60854214", "0.6051797", "0.60405546", "0.6010551", "0.6010551", "0.59591544", "0.5953371", "0.595...
0.7329176
0
GET /fdn/legend_categories/1 GET /fdn/legend_categories/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_fdn_legend_category\n @fdn_legend_category = Fdn::LegendCategory.find(params[:id])\n end", "def index\n @fdn_legend_categories = Fdn::LegendCategory.show.paginate(page: params[:page]||1)\n end", "def create\n @fdn_legend_category = Fdn::LegendCategory.new(fdn_legend_category_params)\n\n r...
[ "0.7297928", "0.72569877", "0.6917394", "0.6794478", "0.6444498", "0.63377255", "0.63342166", "0.6323612", "0.6263754", "0.6255207", "0.6235546", "0.6208504", "0.6177053", "0.6172825", "0.6142088", "0.6132407", "0.6121702", "0.61059684", "0.60804224", "0.6076005", "0.6075386"...
0.0
-1
POST /fdn/legend_categories POST /fdn/legend_categories.json
def create @fdn_legend_category = Fdn::LegendCategory.new(fdn_legend_category_params) respond_to do |format| if @fdn_legend_category.save format.html { render :js => view_context.close_window_show_tips('parent.MAIN_LAYER_WINDOW', '栏目分类创建成功!') } format.json { render :show, status: :created, location: @fdn_legend_category } else format.html { render :new } format.json { render json: @fdn_legend_category.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_fdn_legend_category\n @fdn_legend_category = Fdn::LegendCategory.find(params[:id])\n end", "def create\n @legend = Legend.new(legend_params)\n\n respond_to do |format|\n if @legend.save\n format.html { redirect_to @legend, notice: 'Legend was successfully created.' }\n format...
[ "0.6892119", "0.6652147", "0.65993756", "0.65559775", "0.6342901", "0.62088877", "0.61876667", "0.6121689", "0.6040845", "0.5986907", "0.5976427", "0.59648114", "0.5945086", "0.59414953", "0.592677", "0.5909997", "0.58841854", "0.586882", "0.5839747", "0.5826665", "0.5822435"...
0.7646925
0
PATCH/PUT /fdn/legend_categories/1 PATCH/PUT /fdn/legend_categories/1.json
def update respond_to do |format| if @fdn_legend_category.update(fdn_legend_category_params) format.html { render :js => view_context.close_window_show_tips('parent.MAIN_LAYER_WINDOW', '栏目分类创建成功!') } format.json { render :show, status: :ok, location: @fdn_legend_category } else format.html { render :edit } format.json { render json: @fdn_legend_category.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @legend.update(legend_params)\n format.html { redirect_to @legend, notice: 'Legend was successfully updated.' }\n format.json { render :show, status: :ok, location: @legend }\n else\n format.html { render :edit }\n format.json { rend...
[ "0.6902458", "0.6899142", "0.6829789", "0.6684713", "0.65649205", "0.63810444", "0.6349942", "0.6314505", "0.62806755", "0.6190413", "0.618593", "0.6147686", "0.6141298", "0.6096266", "0.609095", "0.6057728", "0.60517013", "0.6039093", "0.60335124", "0.60252", "0.60206306", ...
0.73077345
0
DELETE /fdn/legend_categories/1 DELETE /fdn/legend_categories/1.json
def destroy @fdn_legend_category.destroy respond_to do |format| format.html { redirect_to fdn_legend_categories_url, notice: 'Legend category was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @legend.destroy\n respond_to do |format|\n format.html { redirect_to legends_url, notice: 'Legend was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @Legend = Legend.find(params[:id])\n begin\n if(@Legend.destroy)\n r...
[ "0.72962844", "0.70840514", "0.69906455", "0.69049054", "0.68855286", "0.6775628", "0.6772223", "0.67711073", "0.6754538", "0.6722077", "0.6713126", "0.67111707", "0.6696149", "0.6687349", "0.66680294", "0.66596174", "0.6642652", "0.66364574", "0.6636273", "0.663609", "0.6635...
0.7745955
0
Use callbacks to share common setup or constraints between actions.
def set_fdn_legend_category @fdn_legend_category = Fdn::LegendCategory.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 fdn_legend_category_params params.require(:fdn_legend_category).permit(:name, :code, :parent_id, :seq) 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 /creatures/1 GET /creatures/1.json
def show @creature = Creature.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @creature } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def creature\n fetch('books.the_kingkiller_chronicle.creatures')\n end", "def index\n @creatures = current_user.creatures\n end", "def index\n @creatures = Monster.all\n end", "def index\n @creatures = Creature.all\n end", "def index\n @creatures = Creature.all\n end", "de...
[ "0.70982385", "0.70196295", "0.6627478", "0.6574481", "0.6574481", "0.65728605", "0.6053427", "0.59341466", "0.59073424", "0.58449435", "0.58421296", "0.5802575", "0.57825947", "0.57523304", "0.57399654", "0.57299554", "0.57142633", "0.57142633", "0.57141644", "0.5684364", "0...
0.6458437
6
GET /creatures/new GET /creatures/new.json
def new r = Ring.instance @creature = Creature.new(latitude: r.latitude, longitude: r.longitude) respond_to do |format| format.html # new.html.erb format.json { render json: @creature } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @goat = Goat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goat }\n end\n end", "def new\n @lookup = Lookup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lookup }\n end\n end"...
[ "0.6758275", "0.6738769", "0.67206424", "0.67170227", "0.671697", "0.67163926", "0.6695911", "0.6691061", "0.66686946", "0.6642358", "0.6642358", "0.662583", "0.6625261", "0.662161", "0.65800714", "0.656981", "0.65694934", "0.65657717", "0.65606743", "0.65565234", "0.65358365...
0.701673
0
POST /creatures POST /creatures.json
def create @creature = Creature.new(params[:creature]) respond_to do |format| if @creature.save format.html { redirect_to @creature, notice: 'Creature was successfully created.' } format.json { render json: @creature, status: :created, location: @creature } else format.html { render action: "new" } format.json { render json: @creature.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createCharities\n\tcharity_list = [\"Direct Relief\", \"Catholic Medical Mission Board\", \"MAP International\", \"United Nations Foundation\", \"The Rotary Foundation of Rotary International\", \"Samaritan's Purse\", \"Institute of International Education\", \"International Rescue Committee\", \"Compassion In...
[ "0.63926834", "0.63741386", "0.61828107", "0.6080262", "0.5911262", "0.5907369", "0.5894993", "0.5894993", "0.5894993", "0.5870223", "0.5819191", "0.5766427", "0.5721183", "0.5683059", "0.56751597", "0.5650493", "0.5650493", "0.5626335", "0.5625927", "0.55984986", "0.55872697...
0.6019458
4
PUT /creatures/1 PUT /creatures/1.json
def update @creature = Creature.find(params[:id]) respond_to do |format| if @creature.update_attributes(params[:creature]) format.html { redirect_to @creature, notice: 'Creature was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @creature.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @creatures.each { |c| c.update(@map) }\n end", "def update\n \tcreature_id = params[:id]\n \tcreature = Creature.find(id)\n \t# updated data\n \tupdated_attributes = params.require(:creature).permit(:name, :description)\n \t# append\n \tcreature.update_attributes(updated_attributes)\n \t#...
[ "0.6028675", "0.5809016", "0.5787177", "0.56834584", "0.56834584", "0.56834584", "0.56834584", "0.563777", "0.5585643", "0.5571701", "0.55573225", "0.5532313", "0.55250406", "0.551908", "0.547884", "0.5468591", "0.5464085", "0.5463543", "0.54158574", "0.5414299", "0.5411483",...
0.5854381
1
DELETE /creatures/1 DELETE /creatures/1.json
def destroy @creature = Creature.find(params[:id]) @creature.destroy respond_to do |format| format.html { redirect_to creatures_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @creature.destroy\n respond_to do |format|\n format.html { redirect_to creatures_url, notice: 'Creature was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @creature.destroy\n respond_to do |format|\n format.html { redirect_t...
[ "0.68918324", "0.68918324", "0.68918324", "0.68918324", "0.68034047", "0.6748479", "0.6719993", "0.6719586", "0.67067003", "0.6701558", "0.6662626", "0.6607278", "0.65824205", "0.6557222", "0.65384924", "0.6531943", "0.6519516", "0.6511313", "0.64999634", "0.6493597", "0.6490...
0.713929
0
Create a style element with unmergable rules (e.g. :hover) and write it into the body. doc is an Nokogiri document and unmergable_css_rules is a Css::RuleSet.
def write_unmergable_css_rules(doc, unmergable_rules) # :nodoc: styles = unmergable_rules.to_s unless styles.empty? style_tag = "<style type=\"text/css\">\n#{styles}</style>" if body = doc.search('body') if doc.at_css('body').children && !doc.at_css('body').children.empty? doc.at_css('body').children.before(::Nokogiri::XML.fragment(style_tag)) else doc.at_css('body').add_child(::Nokogiri::XML.fragment(style_tag)) end else doc.inner_html = style_tag += doc.inner_html end end doc end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sanitize_css(style); end", "def sanitize_css(style); end", "def sanitize_css(style); end", "def add_uninlinable_styles(parent, blocks, merge_media_queries)\n return if blocks.empty?\n\n parent_node =\n case parent\n when :head\n find_head\n when :root\n do...
[ "0.5204353", "0.5204353", "0.5204353", "0.51694775", "0.5117988", "0.4974125", "0.493652", "0.48359048", "0.48194295", "0.48079127", "0.47803655", "0.4693808", "0.4689223", "0.46654445", "0.46565276", "0.46245772", "0.45944598", "0.45910454", "0.45864323", "0.45815787", "0.45...
0.81472456
0
Converts the HTML document to a format suitable for plaintext email. If present, uses the element as its base; otherwise uses the whole document.
def to_plain_text html_src = '' begin html_src = @doc.at("body").inner_html rescue; end html_src = @doc.to_html unless html_src and not html_src.empty? convert_to_text(html_src, @options[:line_length], @html_encoding) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n document.xml? ? to_xml : to_html\n end", "def trans_html\n @doc.to_html\n end", "def to_s\n if is_xhtml?\n @doc.to_xhtml(:encoding => nil)\n else\n @doc.to_html(:encoding => nil)\n end\n end", "def to_html\n @doc.at(\"body\").childre...
[ "0.6108258", "0.6010463", "0.5984093", "0.59453136", "0.58812165", "0.58087957", "0.5807471", "0.5803968", "0.5760982", "0.57103235", "0.5695114", "0.56047106", "0.55874616", "0.5584143", "0.55557156", "0.55155146", "0.55082536", "0.55023944", "0.5496161", "0.5480872", "0.544...
0.6110102
0
Gets the original HTML as a string.
def to_s if is_xhtml? @doc.to_xhtml(:encoding => nil) else @doc.to_html(:encoding => nil) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def html_string\n @html.join(\"\")\n end", "def html\n self[\"html\"][0].get_outer_html\n end", "def to_html\n __html__.dup.scrub!(:escape).to_html\n end", "def plain_html\n self.class.to_html.to_html(text.dup)\n end", "def html\n @doc.to_s\n end", "def html\n @doc.to...
[ "0.8104221", "0.73193914", "0.7116315", "0.7113196", "0.7073731", "0.7073731", "0.7005529", "0.6959862", "0.6912137", "0.6854752", "0.6840523", "0.68143445", "0.67897135", "0.6765939", "0.67633075", "0.6718013", "0.6679029", "0.6666879", "0.664855", "0.6636231", "0.66118586",...
0.6166602
61
Load the HTML file and convert it into an Nokogiri document.
def load_html(input) # :nodoc: thing = nil # TODO: duplicate options if @options[:with_html_string] or @options[:inline] or input.respond_to?(:read) thing = input elsif @is_local_file @base_dir = File.dirname(input) thing = File.open(input, 'r') else thing = open(input) end if thing.respond_to?(:read) thing = thing.read end return nil unless thing doc = nil # Handle HTML entities if @options[:replace_html_entities] == true and thing.is_a?(String) HTML_ENTITIES.map do |entity, replacement| thing.gsub! entity, replacement end end # Default encoding is ASCII-8BIT (binary) per http://groups.google.com/group/nokogiri-talk/msg/0b81ef0dc180dc74 # However, we really don't want to hardcode this. ASCII-8BIG should be the default, but not the only option. if thing.is_a?(String) and RUBY_VERSION =~ /1.9/ thing = thing.force_encoding(@options[:input_encoding]).encode! doc = ::Nokogiri::HTML(thing, nil, @options[:input_encoding]) {|c| c.recover } else default_encoding = RUBY_PLATFORM == 'java' ? nil : 'BINARY' doc = ::Nokogiri::HTML(thing, nil, @options[:input_encoding] || default_encoding) {|c| c.recover } end # Fix for removing any CDATA tags from both style and script tags inserted per # https://github.com/sparklemotion/nokogiri/issues/311 and # https://github.com/premailer/premailer/issues/199 %w(style script).each do |tag| doc.search(tag).children.each do |child| child.swap(child.text()) if child.cdata? end end doc end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_page\n @doc = Nokogiri::HTML(@html)\n end", "def doc\n # get_html beforehand for good output messages\n html = get_html\n print \"Parsing doc...\"\n doc = Nokogiri::HTML(html)\n puts \"done.\"\n puts\n doc\n end", "def convert_to_document() \n Nokogi...
[ "0.7020297", "0.6923379", "0.68870384", "0.6730802", "0.67032534", "0.6672094", "0.6397454", "0.63799787", "0.6355923", "0.63490087", "0.6342789", "0.623305", "0.62181395", "0.6153046", "0.6129954", "0.61244375", "0.61153185", "0.6065651", "0.60552466", "0.60302925", "0.60289...
0.6407157
6
returns the zipfile object for the document
def zipfile @zipfile ||= Zip::File.open( @file_path ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zip_docx(zip_data)\n\t\tdocx = Rex::Zip::Archive.new\n\t\tzip_data.each_pair do |k,v|\n\t\t\tdocx.add_file(k,v)\n\t\tend\n\t\treturn docx.pack\n\tend", "def get_file_doc(prptfile, filename)\n Zip::ZipFile.open(prptfile, Zip::ZipFile::CREATE) do |zipfile|\n return REXML::Document.new zipfile.read(filename...
[ "0.73175496", "0.72673887", "0.71925384", "0.7055098", "0.6643349", "0.6599852", "0.6530635", "0.6425319", "0.6414294", "0.6402649", "0.63676727", "0.63633114", "0.63200784", "0.6288232", "0.628422", "0.62816983", "0.62618417", "0.6233918", "0.6196481", "0.6185033", "0.612131...
0.6956159
4
returns a nokogiri document for the workbook
def workbook @workbook ||= Nokogiri::XML( zipfile.read("xl/workbook.xml") ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_document\n self.root = XML::Node.new('Workbook')\n root['xmlns'] = 'urn:schemas-microsoft-com:office:spreadsheet'\n root['xmlns:o'] = 'urn:schemas-microsoft-com:office:office'\n root['xmlns:x'] = 'urn:schemas-microsoft-com:office:excel'\n root['xmlns:ss'] = 'urn:schemas...
[ "0.7476314", "0.66450584", "0.6586632", "0.62136203", "0.620104", "0.61972976", "0.6151632", "0.6110135", "0.6095879", "0.6071614", "0.6005109", "0.6004505", "0.5959767", "0.5937215", "0.59272647", "0.592242", "0.58694327", "0.58340734", "0.5831149", "0.58109915", "0.579341",...
0.7507652
0
returns an array of strings for the sharedStrings.
def shared_strings @shared_strings ||= Nokogiri::XML( zipfile.read("xl/sharedStrings.xml") ).css('si>t').collect(&:text) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_strings\n return @stringpool_main.values\n end", "def extract_shared_strings\n extract ExtractSharedStrings, 'sharedStrings.xml', 'Shared strings'\n end", "def shared_strings\n SharedStringsTable.new(worksheets.collect(&:cells), xml_space)\n end", "def shstrings\n strings = S...
[ "0.6958081", "0.66667473", "0.65610826", "0.6281222", "0.6252961", "0.5757277", "0.56123495", "0.5559892", "0.55482894", "0.55356747", "0.55300385", "0.54677016", "0.54075646", "0.53592885", "0.5354759", "0.5335413", "0.5334933", "0.5313773", "0.5312275", "0.53005254", "0.528...
0.664588
2
returns an array of nokogiri documents for each worksheet
def worksheets @worksheets ||= (1..number_of_worksheets).collect { |n| Nokogiri::XML(zipfile.read("xl/worksheets/sheet#{n}.xml")) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sheets\n return_sheets = []\n #TODO: @workbook_doc.find(\"//*[local-name()='sheet']\").each do |sheet|\n @workbook_doc.xpath(\"//*[local-name()='sheet']\").each do |sheet|\n #TODO: return_sheets << sheet.attributes.to_h['name']\n return_sheets << sheet['name']\n end\n return_sh...
[ "0.75818044", "0.7244742", "0.6546695", "0.65097076", "0.6478125", "0.63756865", "0.6182001", "0.6146395", "0.60642177", "0.5931487", "0.58948976", "0.58770645", "0.5841073", "0.5836425", "0.5832928", "0.58190095", "0.57992464", "0.5788695", "0.57829636", "0.57829636", "0.577...
0.7716788
0
returns a date object representing the start of the serial date system for this sheet Either 19000101 or 19040101
def base_date @base_date ||= lambda do date_base_element = workbook.search('workbookPr').attribute('date1904') if date_base_element && date_base_element.value.to_i == 1 Date.parse('1904-01-01') else Date.parse('1900-01-01') end end.call end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_date\n\t\tDate.new( @year, @month, 1 )\n\tend", "def start_date\n\t\treturn Date.new(y=year, m=START_MONTH, d=START_DAY)\n\tend", "def base_date\n return DATE_SYSTEM_1900 if @xml.nil?\n\n @xml.xpath('//workbook/workbookPr[@date1904]').each do |workbookPr|\n return DATE_SYSTEM_1...
[ "0.6951719", "0.69469506", "0.6822396", "0.6774687", "0.6713731", "0.66813916", "0.6604047", "0.6600179", "0.64780927", "0.6420173", "0.64136595", "0.64009446", "0.63733965", "0.63079864", "0.6303458", "0.6268179", "0.6216541", "0.6187359", "0.6181286", "0.6180044", "0.616744...
0.7383138
0
Change below was necessary to institute Source/Deposit Collection structure. For more information, read the SOURCE_DEPOSIT_CHANGES_README.md in dlpcurate's root folder.
def source_collection_title self['source_collection_title_ssim'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def source_collections\n # The determination of which collections are considered Source Collections\n # is based solely on the Collection's CollectionType deposit_only_collection\n # attribute. This logic can be changed, but the simplest determination is the\n # CollectionType.\n Collectio...
[ "0.57510006", "0.5613235", "0.53883404", "0.52347404", "0.512664", "0.50391346", "0.48785654", "0.48580223", "0.48580223", "0.4846482", "0.48276952", "0.48121795", "0.47960484", "0.4782596", "0.4771699", "0.4769819", "0.47660276", "0.47415572", "0.47112507", "0.46831244", "0....
0.0
-1
Method: push Push QRES object into the stack Params: var_Object:AbstractQueryResult QRES object Returns: Throws:
def push(var_Object) if(!var_Object.is_a?(AbstractQueryResult)) raise QRESTypeError.new("Incorrect object type [#{var_Object.class}], " + AbstractQueryResult.to_s() + " expected") end @VAR_STACK.push(var_Object) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push(x)\n @q << x \n end", "def push(x)\n @q1.push x\n end", "def push\n end", "def push(x)\n p = @stack.unshift(x)\n @q.insert(p)\n self\n end", "def push\n end", "def push(var_Object)\n @VAR_STACK.push(var_Object)\n end", "def push(item); end", "def p...
[ "0.66642594", "0.6650613", "0.6380902", "0.62356406", "0.6203774", "0.6203554", "0.61719376", "0.61054033", "0.607658", "0.6019877", "0.6019877", "0.60175973", "0.5996617", "0.5965906", "0.5945492", "0.5945325", "0.594046", "0.5930339", "0.59237576", "0.5923406", "0.5890294",...
0.8232245
0
Method: pop Gets QRES object from the stack Params: Returns:AbstractQueryResult Throws:
def pop() return @VAR_STACK.pop() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pop()\n @q.shift\n end", "def pop\n if empty?\n nil\n else\n @q.remove\n @stack.shift\n end\n end", "def stack_pop\n\n r = stack_fetch\n stack_unstack if r.class != Rufus::Lua::Table\n\n r\n end", "def pop() end", "def pop()\n @stack.pop ...
[ "0.7548667", "0.7506631", "0.7417536", "0.7334886", "0.7292255", "0.72741765", "0.7271533", "0.7250482", "0.72464544", "0.72209555", "0.72209555", "0.7188088", "0.7163602", "0.71508855", "0.7150853", "0.713455", "0.713455", "0.71259415", "0.71159136", "0.7107729", "0.71053207...
0.66353065
52
Method: to_s Returns a string representation of QRES object. Params: Returns:String Throws:
def to_s() return self.class.to_s() + @VAR_STACK.to_s() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n stringify\n end", "def to_s\n string\n end", "def to_s\n toString\n end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", ...
[ "0.7242264", "0.72417516", "0.7195644", "0.719296", "0.719296", "0.719296", "0.719296", "0.719296", "0.719296", "0.719296", "0.719296", "0.719296", "0.719296", "0.719296", "0.719296", "0.719296", "0.719296", "0.719296", "0.719296", "0.719296", "0.719296", "0.7142175", "0....
0.0
-1
Gnome sort (or stupid sort as it was called by its creator) is similar to bubble sort. It finds the first pair of elements that are out of order and swaps backwards until the order is fixed. Worst case performance is O(n^2), but tends towards O(n) if the initial array is almost sorted.
def swap(array, index1, index2) temp = array[index2] array[index2] = array[index1] array[index1] = temp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gnome_sort(array)\n count = 0\n\n while count < array.length - 1\n if array[count] > array[count + 1]\n array[count + 1], array[count] = array[count], array[count + 1]\n count -= 2 if count.positive?\n end\n count += 1\n end\n\n array\nend", "def bubble_sort(array)\ntemp = nil\n\tfor n...
[ "0.7692385", "0.7672447", "0.7622271", "0.7615467", "0.75846034", "0.7582923", "0.7567134", "0.7560794", "0.7541707", "0.7540498", "0.75322944", "0.75138324", "0.75001574", "0.74839056", "0.7467473", "0.7442694", "0.7436924", "0.7411305", "0.7388727", "0.73862225", "0.7382474...
0.0
-1
GET /documents/1 GET /documents/1.json
def show @document = Document.find(params[:id]) # if @document.shares.count > 0 # if @document.shares.present? && !@document.shares.first.encrypted_password.blank? # redirect_to root_url # end # else respond_to do |format| format.html # show.html.erb format.json { render json: @document } end # end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n \n @document = Document.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document }\n end\n \n end", "def index\n @documents = Document.all\n\n respond_to do |format|\n format.html # index.html.erb\n form...
[ "0.7391596", "0.73689586", "0.73263764", "0.73263764", "0.73263764", "0.73263764", "0.73263764", "0.73263764", "0.73263764", "0.73170596", "0.7306216", "0.7303724", "0.7286854", "0.72555476", "0.71793205", "0.71743375", "0.71661717", "0.714282", "0.71288323", "0.7051852", "0....
0.0
-1
GET /documents/new GET /documents/new.json
def new @document = Document.new respond_to do |format| format.html # new.html.erb format.json { render json: @documents.map{|document| document.to_jq_upload } } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n \n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n \n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @d...
[ "0.8084288", "0.7907427", "0.7907427", "0.7907427", "0.7907427", "0.7907427", "0.7907427", "0.7907427", "0.7907427", "0.7907427", "0.78536075", "0.76244146", "0.76208293", "0.75638074", "0.7377576", "0.7342673", "0.73118055", "0.7309455", "0.7253226", "0.7250304", "0.7237414"...
0.6898144
34
POST /documents POST /documents.json
def create @document = current_user.documents.create(params[:document]) respond_to do |format| if @document.save format.html { render :json => [@document.to_jq_upload].to_json, :content_type => 'text/html', :layout => false } format.json { render json: [@document.to_jq_upload].to_json, status: :created, location: @document } else format.html { render action: "new" } format.json { render json: @document.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, :notice => 'Document was successfully created.' }\n format.json { render :json => @document, :status => :created, :location => @document }\n e...
[ "0.72675", "0.72270125", "0.7202067", "0.7202067", "0.71927583", "0.71516854", "0.7137915", "0.71379024", "0.712435", "0.68928266", "0.6876889", "0.6837602", "0.6818319", "0.68161947", "0.6751123", "0.67454964", "0.6734003", "0.6723543", "0.66879636", "0.6685973", "0.668132",...
0.7049302
9
PUT /documents/1 PUT /documents/1.json
def update @document = Document.find(params[:id]) respond_to do |format| if @document.update_attributes(params[:document]) format.html { redirect_to root_url , notice: 'Document was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @document.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put_document index, id, document\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Put.new(uri)\n req.body = document.to_json\n run(uri, req)\n end", "def update_document index, id, document\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}/_update\...
[ "0.7604765", "0.7348989", "0.7190452", "0.7094024", "0.70421684", "0.6972244", "0.6862227", "0.6861711", "0.6825018", "0.6811377", "0.6811377", "0.6811377", "0.6798293", "0.6792356", "0.6753539", "0.6753529", "0.67480385", "0.66923976", "0.6636967", "0.6636967", "0.6636967", ...
0.67318904
17
DELETE /documents/1 DELETE /documents/1.json
def destroy @document = Document.find(params[:id]) @document.destroy respond_to do |format| format.html { redirect_to documents_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n @client.delete_document(@path)\n end", "def delete_document index, id\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Delete.new(uri)\n run(uri, req)\n end", "def destroy\n @doc = Doc.find(params[:id])\n @doc.destroy\n\n respond...
[ "0.78232354", "0.761401", "0.7518423", "0.75177574", "0.7488822", "0.7488822", "0.7488822", "0.7488822", "0.7488822", "0.7483412", "0.7483412", "0.74585146", "0.7431029", "0.74234265", "0.7416177", "0.74146056", "0.7329395", "0.7328653", "0.7327659", "0.7327659", "0.73240066"...
0.7474384
19
GET /food_donations GET /food_donations.json
def index if current_user.charity? requested_donation = FoodDonation.where(charity_id: current_user.id, status: 1) @food_donations = requested_donation.empty? ? FoodDonation.all.available : requested_donation elsif current_user.restaurant? @food_donations = current_user.food_donations.all end respond_to do |format| format.html format.csv { send_data @food_donations.to_csv, filename: "donations-#{Date.today}.csv" } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n donation = Donation.find_by(id: params[:id])\n render json: donation.as_json\n end", "def show\n @donation = Donation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @donation }\n end\n end", "def show\n @donati...
[ "0.67793286", "0.67164606", "0.6668546", "0.66489303", "0.6642473", "0.66091263", "0.6593443", "0.65243995", "0.6452924", "0.6433808", "0.63592", "0.63592", "0.63592", "0.63592", "0.63592", "0.6313008", "0.6285614", "0.6283549", "0.6278749", "0.62152654", "0.61770207", "0.6...
0.6130881
23
GET /food_donations/1 GET /food_donations/1.json
def show; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n donation = Donation.find_by(id: params[:id])\n render json: donation.as_json\n end", "def food_info(food_id)\n get(\"/foods/#{food_id}.json\")\n end", "def show\n @donation = Donation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.j...
[ "0.69635224", "0.6935336", "0.687765", "0.68609786", "0.6783679", "0.6590121", "0.65027255", "0.6430951", "0.6427963", "0.6363389", "0.63556904", "0.6316558", "0.6311465", "0.6267791", "0.6249966", "0.6246723", "0.6182626", "0.61697274", "0.6165329", "0.6165329", "0.6165329",...
0.0
-1
POST /food_donations POST /food_donations.json
def create @food_donation = current_user.food_donations.new(food_donation_params) # set donation's status to available @food_donation.status = 0 respond_to do |format| if @food_donation.save format.html { redirect_to food_donations_path, notice: 'Food donation was successfully created.'} format.json { render :show, status: :created, location: @food_donation } else format.html { render :new } format.json { render json: @food_donation.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @food_donor = FoodDonor.new(food_donor_params)\n respond_to do |format|\n if @food_donor.save\n format.html { redirect_to food_donor_find_ngos_url(@food_donor), notice: 'Food donor was successfully created.' }\n format.json { render :show, status: :created, location: @food_don...
[ "0.7365243", "0.70084447", "0.6965112", "0.69392556", "0.69222236", "0.6891382", "0.67050385", "0.65433127", "0.65163404", "0.6494896", "0.6403396", "0.6346578", "0.6343288", "0.6336612", "0.6303668", "0.62923884", "0.6283209", "0.6280959", "0.6278536", "0.6271327", "0.626226...
0.73028415
1
PATCH/PUT /food_donations/1 PATCH/PUT /food_donations/1.json
def update respond_to do |format| if @food_donation.update(food_donation_params) format.html { redirect_to @food_donation, notice: 'Food donation was successfully updated.' } format.json { render :show, status: :ok, location: @food_donation } else format.html { render :edit } format.json { render json: @food_donation.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @food_donor.update(food_donor_params)\n format.html { redirect_to @food_donor, notice: 'Food donor was successfully updated.' }\n format.json { render :show, status: :ok, location: @food_donor }\n else\n format.html { render :edit }\n ...
[ "0.6984395", "0.66621584", "0.6632155", "0.6609845", "0.65963197", "0.6580926", "0.655649", "0.649547", "0.64804363", "0.64519554", "0.644133", "0.6432318", "0.6432318", "0.6432318", "0.6432318", "0.64051396", "0.6403323", "0.63523185", "0.63141984", "0.6311872", "0.6300226",...
0.71065706
0
DELETE /food_donations/1 DELETE /food_donations/1.json
def destroy @food_donation.destroy respond_to do |format| format.html { redirect_to food_donations_url, notice: 'Food donation was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @food_donor.destroy\n respond_to do |format|\n format.html { redirect_to food_donors_url, notice: 'Food donor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @food = Food....
[ "0.7071706", "0.7049148", "0.7043413", "0.7043413", "0.7024169", "0.7023758", "0.7023758", "0.7021285", "0.6991148", "0.69819605", "0.69489217", "0.6929549", "0.69035447", "0.6897715", "0.6839437", "0.68149537", "0.6799768", "0.6798316", "0.6794264", "0.67801124", "0.6774184"...
0.7378531
0
Use callbacks to share common setup or constraints between actions.
def set_food_donation @food_donation = FoodDonation.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 food_donation_params params.fetch(:food_donation, {}).permit(:note, :available_at, :quantity) 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
Convenience method to allow configuration options to be set in a block
def configure yield self self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configure(&block)\n raise ArgumentError, \"Block is required.\" unless block_given?\n yield @options\n end", "def config(&block)\n instance_eval(&block) if block_given?\n end", "def configure_with_block(&block)\n self.instance_eval(&block) if block_given?\n end", "def configure_wit...
[ "0.8478099", "0.8120963", "0.81001765", "0.81001765", "0.8010885", "0.7984564", "0.7981057", "0.7940716", "0.79392976", "0.7935303", "0.7903023", "0.7882659", "0.7882427", "0.787986", "0.7873399", "0.78668606", "0.78619075", "0.78619075", "0.78616524", "0.7843603", "0.7843267...
0.0
-1
Create a hash of options and their values
def options options = {} VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)} options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_hash\n OPTIONS.inject({}) do |hash, option|\n hash.merge(option.to_sym => send(option))\n end\n end", "def to_hash\n OPTIONS.inject({}) do |hash, option|\n hash.merge(option.to_sym => send(option))\n end\n end", "def to_hash\n OPTIONS.inject({}) do |hash, opt...
[ "0.7855502", "0.7855502", "0.7855502", "0.7855502", "0.78355616", "0.78355616", "0.78355616", "0.78355616", "0.78355616", "0.7832591", "0.782369", "0.7568831", "0.7562294", "0.7560206", "0.75320995", "0.74729043", "0.74548495", "0.7440437", "0.7437274", "0.7427538", "0.742753...
0.7129261
50
Reset all configuration options to defaults
def reset self.endpoint = DEFAULT_ENDPOINT self.user_agent = DEFAULT_USER_AGENT self.timeout = DEFAULT_TIMEOUT self.platform_credentials = DEFAULT_PLATFORM_CREDENTIALS self.disable_ssl_peer_verification = DEFAULT_DISABLE_SSL_PEER_VERIFICATION self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset!\n @options = defaults\n end", "def reset!\n @options = defaults\n end", "def reset\n CONFIGURATION_DEFAULTS.each { |k, v| send(\"#{k}=\", v) }\n self\n end", "def reset\n @options = VALID_OPTIONS_KEYS.inject({}) do |opts, k|\n default_option = OnTheSnow::Co...
[ "0.86169964", "0.86169964", "0.8273091", "0.82651174", "0.8156763", "0.8108206", "0.80130243", "0.7998084", "0.7991167", "0.7964046", "0.79466546", "0.7861912", "0.78549194", "0.78106874", "0.78054345", "0.7724121", "0.77240366", "0.76479924", "0.7613861", "0.75971186", "0.75...
0.68889064
64
this method is defined in the application controller in the provided solution. Not sure why, besides maybe that it's a pretty general method which could be used in more than one controller
def require_login redirect_to '/sessions/new' unless current_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def controller_class; end", "def controller_class; end", "def before_dispatch(_env)\n end", "def controller(controller); end", "def before_dispatch(env); end", "def controller; end", "def controller; end", "def controller; end", "def controller; end", "def controller; end", "def controller...
[ "0.6188052", "0.6188052", "0.61030495", "0.6082964", "0.60699594", "0.60546833", "0.60546833", "0.60546833", "0.60546833", "0.60546833", "0.60546833", "0.60546833", "0.60546833", "0.60546833", "0.60546833", "0.5977687", "0.5977687", "0.5931892", "0.5931892", "0.591766", "0.58...
0.0
-1
Create the changelog entries and commit
def run(remote = false, branch = 'master') if already_released? logger.fatal "Version #{version} had already been released, did you bump the version manually?" exit 1 end File.write(changelog_file, new_content) unless remote id = commit_changelog(nil, remote, branch) if options[:commit] logger.info "The changelog has been updated to version #{version}" id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_changelog\n @hg_opener.open \"00changelog.i\", \"w\" do |file|\n file.write \"\\0\\0\\0\\2\" # represents revlogv2\n file.write \" dummy changelog to avoid using the old repo type\"\n end\n end", "def changelog\n # Add a changelog file to the project\n...
[ "0.71292514", "0.6907487", "0.67083883", "0.6621085", "0.65094423", "0.65087956", "0.6425871", "0.6382574", "0.6323216", "0.6283284", "0.6273444", "0.61909145", "0.613841", "0.61110866", "0.61012995", "0.6093569", "0.6092925", "0.60896367", "0.6082993", "0.60612595", "0.59821...
0.5719361
38
Encode the min key has no value since it only needs the type and field name when being encoded.
def to_bson(buffer = ByteBuffer.new) buffer end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key_for_min_value\n end", "def get_minimal_key(line)\n compute_minimal_keys if not @minimal_keys\n \n str = \"\"\n minimal_keys.each{|k, size|\n str += line.field(k).to_s[0..size]\n }\n return str\n end", "def get_min_key()\n \n end", "def encode_small\n encode \"smal...
[ "0.66483843", "0.63521314", "0.6280911", "0.6089729", "0.5768553", "0.5766443", "0.57492274", "0.57492274", "0.568234", "0.5625308", "0.5607513", "0.5580112", "0.55678904", "0.5562163", "0.5561781", "0.5551914", "0.55436474", "0.5534306", "0.55312514", "0.5521251", "0.5464814...
0.0
-1
takes numbe rof coconuts, outputs number after 1 was given to monkey
def f(n) o = n-1 o*= 4/5.to_f o end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sheep_count(num)\n \nend", "def hailstone1(num)\n count = 0\n\n if num == 1\n print \"#{num} \"\n num = (num * 3) + 1\n count += 1\n end\n\n print \"#{num} \"\n\n hailoop(num, count)\n\n puts\n puts \"HAILSTONE 1 - Number of steps: #{count}\"\nend", "def bottles_num(counter)\n if counte...
[ "0.63650733", "0.63193625", "0.6311693", "0.623858", "0.62123245", "0.61853015", "0.6170439", "0.615338", "0.6148566", "0.6144052", "0.6130402", "0.60944957", "0.6050813", "0.60497016", "0.604642", "0.6041882", "0.603583", "0.60284007", "0.6023331", "0.6016696", "0.6010967", ...
0.0
-1
putss 'given 96 nuts',is_int(96), is_int(98), is_int(98.0) return;
def find_number i = 0 not_found = true while not_found i+=1 #puts i #puts is_int(f6(i)) not_found = ! is_int(f6(i.to_f)) end i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sanitize_interest(int)\n\t int < 1.0 ? int : (int / 100.0)\n end", "def test_is_nummeric\n assert(StringChecker.is_numeric?(\"+20\"))\n assert(StringChecker.is_numeric?(\"-020\"))\n assert(StringChecker.is_numeric?(\"123\"))\n assert(StringChecker.is_numeric?(\"0123\"))\n assert(!StringCheck...
[ "0.63684964", "0.60820395", "0.60595393", "0.6044318", "0.60429287", "0.6025015", "0.6002063", "0.6002063", "0.59595954", "0.5947825", "0.593683", "0.593498", "0.5920651", "0.5918467", "0.5902165", "0.5858406", "0.5842807", "0.5832292", "0.5828255", "0.5824592", "0.5820254", ...
0.0
-1
~ rust = ab(4,5) ~ putss rust ~ c,d = ab(4,66) ~ putss rust ~ putss [c,d]
def kalman_filter motion, measurements, motion_sig, measurement_sig, mu, sig measurements.each_with_index do | x, i | mu, sig = update(mu, sig, measurements[i], measurement_sig ) putss 'update: '+[mu, sig].inspect mu, sig = predict(mu, sig, motion[i], motion_sig ) putss 'predict: '+[mu, sig].inspect end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method(a, b)\n c=a\n a=b\n b=c\n return a,b\nend", "def sb(t, s, c)\n\n end", "def squares\r\n [@a1, @a2, @a3, @b1, @b2, @b3, @c1, @c2, @c3]\r\n \r\nend", "def squares\n [@a1, @a2, @a3, @b1, @b2, @b3, @c1, @c2, @c3]\n \nend", "def lbu(t, s, c)\n\n end", "def squares\n [@a1, @a2, @a3, @b1, ...
[ "0.5513195", "0.54722965", "0.5332507", "0.53129494", "0.52853817", "0.52845347", "0.52621895", "0.5248688", "0.52335733", "0.5209965", "0.5194036", "0.5187763", "0.5171383", "0.5171383", "0.5171383", "0.5171383", "0.5171383", "0.5171383", "0.5171383", "0.5171383", "0.5171383...
0.0
-1
Build tree with all possible moves from current square as children
def get_moves(start) x = start.x y = start.y moves = [] moves << Node.new(x+2, y+1) moves << Node.new(x+2, y-1) moves << Node.new(x+1, y+2) moves << Node.new(x+1, y-2) moves << Node.new(x-1, y+2) moves << Node.new(x-1, y-2) moves << Node.new(x-2, y+1) moves << Node.new(x-2, y-1) moves = moves.reject do |node| node.x < 0 || node.x > 8 end moves = moves.reject do |node| node.y < 0 || node.y > 8 end moves.each { |move| move.next_node = start } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_move_tree\n queue = [@root_node]\n until queue.empty?\n current_node = queue.shift\n possible_positions = new_move_positions(current_node.value) #[]\n possible_positions.each do |position| #[1,2]\n child_node = PolyTreeNode.new(position) #node object(value = 1,2)\n chil...
[ "0.7883843", "0.76175946", "0.7474585", "0.7454296", "0.7403329", "0.7376055", "0.7322037", "0.73182106", "0.7308959", "0.7301816", "0.72705007", "0.725754", "0.725269", "0.7250206", "0.7230539", "0.7228389", "0.7226356", "0.72213894", "0.72121954", "0.7211279", "0.71731144",...
0.0
-1
Find shortest path from starting to ending square
def build_path(start, end_pos) node = Node.new(start[0], start[1]) target = Node.new(end_pos[0], end_pos[1]) visited_nodes = [] next_moves = [node] until next_moves.empty? do node = next_moves.shift puts "Current node: #{node.x}, #{node.y}" if node.x == target.x && node.y == target.y return node end visited_nodes.push(node) node.moves = get_moves(node) node.moves.reject do |square| visited_nodes.include?(square) end node.moves.each do |move| next_moves.push(move) end end return node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shortest_path\n initial_position_obj = { position: start_position, source: {} }\n\n knights_path = [initial_position_obj]\n\n while knights_path.present?\n current_position = knights_path.shift\n\n position = current_position[:position]\n\n if position == end_position\n return pa...
[ "0.81225955", "0.7521596", "0.72081727", "0.71913284", "0.70679367", "0.7064445", "0.7026986", "0.69918585", "0.6986222", "0.69860804", "0.69834757", "0.69136125", "0.69126", "0.6900757", "0.68562764", "0.683525", "0.6834756", "0.6829711", "0.6801918", "0.67782617", "0.677323...
0.6825812
18
Reconstruct path through the next_node links
def find_path(start, target) node = build_path(start, target) path = [node] until node.next_node.nil? do node = node.next_node path.push(node) end path = path.reverse puts "You made it in #{path.length} moves. Here is your path: " path.each do |node| puts "[#{node.x}], [#{node.y}]" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def path(source, target, meta)\n # retrieve the path to the target node, using the meta hash\n # that was constructed at each iteration of the `each` iteration\n predecessor = target\n result_path = []\n\n # follow the leads from the back\n until predecessor == source\n result_path << predecessor.number\n...
[ "0.66971767", "0.6472391", "0.6323796", "0.6323796", "0.6316688", "0.6314459", "0.63101155", "0.62797403", "0.6259641", "0.61713445", "0.6122361", "0.6082953", "0.60456795", "0.6018207", "0.6018189", "0.59693235", "0.5887896", "0.58597887", "0.5821439", "0.58190286", "0.58149...
0.57887185
24
:callseq: from(url) => self You can pass a url where the ToolkitArtifact should be downloaded from as a string: FLEX_SDK.from(" You can pass :maven as a parameter to download it from a maven repository: FLEX_SDK.from(:maven) If you don't call this function at all, buildras3 will try and resolve a url on automatically
def from(url) @url = url self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def artifact_download_url_for(node, source)\n # TODO: Move this method into the nexus-cli\n config = data_bag_config_for(node, source)\n nexus_path = config['path']\n group_id, artifact_id, version, extension, classifier = source.split(':')\n uri_for_url = URI(config['url'])\n ...
[ "0.6239918", "0.6091529", "0.5676486", "0.5642037", "0.5546805", "0.5517468", "0.551207", "0.54768527", "0.5470584", "0.5462806", "0.54499686", "0.5383347", "0.53765815", "0.5372608", "0.53634924", "0.53627485", "0.53484493", "0.53339267", "0.53251004", "0.53171587", "0.53131...
0.5871638
2