query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
lexer rule space! (SPACE) (in CSV.g)
def space! # -> uncomment the next line to manually enable rule tracing # trace_in( __method__, 3 ) type = SPACE channel = ANTLR3::DEFAULT_CHANNEL # - - - - main rule block - - - - # at line 12:9: ( ' ' )+ # at file 12:9: ( ' ' )+ match_count_2 = 0 while true alt_2 = 2 look_2_0 = @input.peek( 1 ) if ( look_2_0 == 0x20 ) alt_2 = 1 end case alt_2 when 1 # at line 12:9: ' ' match( 0x20 ) else match_count_2 > 0 and break eee = EarlyExit(2) raise eee end match_count_2 += 1 end # --> action channel = HIDDEN # <-- action @state.type = type @state.channel = channel ensure # -> uncomment the next line to manually enable rule tracing # trace_out( __method__, 3 ) end
[ "def space!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 8 )\n\n \n # - - - - main rule block - - - -\n # at line 88:5: ( ' ' | '\\\\t' )+\n # at file 88:5: ( ' ' | '\\\\t' )+\n match_count_12 = 0\n while true\n alt_12 = 2\n look_12_0 = @input.peek( 1 )\n\n if ( look_12_0 == 0x9 || look_12_0 == 0x20 )\n alt_12 = 1\n\n end\n case alt_12\n when 1\n # at line \n if @input.peek(1) == 0x9 || @input.peek(1) == 0x20\n @input.consume\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n else\n match_count_12 > 0 and break\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n eee = EarlyExit(12)\n\n\n raise eee\n end\n match_count_12 += 1\n end\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 8 )\n\n end", "def delim!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 13 )\n\n\n\n type = DELIM\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 305:3: '|'\n match( 0x7c )\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 13 )\n\n\n end", "def scan_comma_spaces; end", "def comma!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 30 )\n\n type = COMMA\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 151:9: ','\n match( 0x2c )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 30 )\n\n end", "def comma!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 46 )\n\n type = COMMA\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 423:9: ','\n match( 0x2c )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 46 )\n\n end", "def comma!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 43 )\n\n type = COMMA\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 368:9: ','\n match( 0x2c )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 43 )\n\n end", "def whitespace!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 7 )\n\n type = WHITESPACE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 30:15: ( ' ' | '\\\\t' | '\\\\r' | '\\\\n' )\n if @input.peek( 1 ).between?( 0x9, 0xa ) || @input.peek(1) == 0xd || @input.peek(1) == 0x20\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n # --> action\n channel=HIDDEN;\n # <-- action\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 7 )\n\n end", "def comma!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 13)\n\n type = COMMA\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 354:8: ','\n match(?,)\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 13)\n\n end", "def whitespace!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 50 )\n\n\n\n type = WHITESPACE\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 137:13: ( '\\\\t' | '\\\\f' | ' ' | '\\\\u00A0' )+\n # at file 137:13: ( '\\\\t' | '\\\\f' | ' ' | '\\\\u00A0' )+\n match_count_9 = 0\n while true\n alt_9 = 2\n look_9_0 = @input.peek( 1 )\n\n if ( look_9_0 == 0x9 || look_9_0 == 0xc || look_9_0 == 0x20 || look_9_0 == 0xa0 )\n alt_9 = 1\n\n end\n case alt_9\n when 1\n # at line \n if @input.peek(1) == 0x9 || @input.peek(1) == 0xc || @input.peek(1) == 0x20 || @input.peek(1) == 0xa0\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n\n end\n\n\n\n else\n match_count_9 > 0 and break\n eee = EarlyExit(9)\n\n\n raise eee\n end\n match_count_9 += 1\n end\n\n\n\n # --> action\n channel = HIDDEN \n # <-- action\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 50 )\n\n\n end", "def whitespace!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 45 )\n\n\n\n type = WHITESPACE\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 66:14: ( '\\\\t' | '\\\\f' | '\\\\n' | '\\\\r' | ' ' | '\\\\u00A0' )+\n # at file 66:14: ( '\\\\t' | '\\\\f' | '\\\\n' | '\\\\r' | ' ' | '\\\\u00A0' )+\n match_count_9 = 0\n while true\n alt_9 = 2\n look_9_0 = @input.peek( 1 )\n\n if ( look_9_0.between?( 0x9, 0xa ) || look_9_0.between?( 0xc, 0xd ) || look_9_0 == 0x20 || look_9_0 == 0xa0 )\n alt_9 = 1\n\n end\n case alt_9\n when 1\n # at line \n if @input.peek( 1 ).between?( 0x9, 0xa ) || @input.peek( 1 ).between?( 0xc, 0xd ) || @input.peek(1) == 0x20 || @input.peek(1) == 0xa0\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n\n end\n\n\n\n else\n match_count_9 > 0 and break\n eee = EarlyExit(9)\n\n\n raise eee\n end\n match_count_9 += 1\n end\n\n\n\n # --> action\n channel=HIDDEN; \n # <-- action\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 45 )\n\n\n end", "def scan_for_commas(token); end", "def space!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 4 )\n\n type = SPACE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 28:5: WS\n ws!\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 4 )\n\n end", "def scan_for_space(token); end", "def scan_comma_spaces\n @scanner.scan(/, +/)\n end", "def separadores!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 8 )\n\n type = SEPARADORES\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 32:14: ( ':' | '(' | ')' | ';' | WHITESPACE | ',' )\n # at line 32:14: ( ':' | '(' | ')' | ';' | WHITESPACE | ',' )\n alt_6 = 6\n case look_6 = @input.peek( 1 )\n when 0x3a then alt_6 = 1\n when 0x28 then alt_6 = 2\n when 0x29 then alt_6 = 3\n when 0x3b then alt_6 = 4\n when 0x9, 0xa, 0xd, 0x20 then alt_6 = 5\n when 0x2c then alt_6 = 6\n else\n raise NoViableAlternative( \"\", 6, 0 )\n end\n case alt_6\n when 1\n # at line 32:16: ':'\n match( 0x3a )\n\n when 2\n # at line 32:22: '('\n match( 0x28 )\n\n when 3\n # at line 32:28: ')'\n match( 0x29 )\n\n when 4\n # at line 32:34: ';'\n match( 0x3b )\n\n when 5\n # at line 32:40: WHITESPACE\n whitespace!\n\n when 6\n # at line 32:53: ','\n match( 0x2c )\n\n end\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 8 )\n\n end", "def whitespace=(_); end", "def parse_whitespace\n @lexer.next! while @lexer.get and @lexer.get.type == :whitespace\n true\n end", "def space()\n # pocitanie riadkov\n self.line.push position if /\\n/ === data[position]\n /\\s/ === data[position]\n\n end", "def scan_whitespace\n\t\t\tappend_scan(/[\\t\\x20]+/, :Spacing, nil)\n\t\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an array of locations for a circle.
def get_circle(location, r) startY = location.y - r startX = 0 endX = 0 if startY % 2 == 0 startX = location.x - (r / 2.0).floor endX = location.x + r; else startX = location.x - (r / 2.0).floor endX = location.x + r; if r % 2 == 0 startX+=1; endX+=1; end end endY = location.y + r; circle_width = 2 * r + 1; delta_y_odd = -1; delta_y_even = -1; offset = 0; circle = Array.new; for y in Range.new(startY, endY) length = circle_width - (y - location.y).abs; if (y % 2 == 0) if (delta_y_even == -1) delta_y_even = (y - location.y).abs; end offset = ((y - location.y).abs - delta_y_even) / 2; if ((location.y - r) % 2 != 0) offset-=1; end else if (delta_y_odd == -1) delta_y_odd = (y - location.y).abs; end offset = (((y - location.y).abs - delta_y_odd) / 2.0).floor - 1; end start = startX + offset; #trace("y = " + y + "location = " + location.y + " : " + length); s = ""; for x in Range.new(start, start + length - 1) s += x.to_s + " "; circle.push(Location.new(x,y)); end #trace(s); end return circle; end
[ "def getPointOnCircle(cx,cy,r,angle)\n x = cx + (r*Math.cos(Math::PI*angle/180)).round\n y = cy + (r*Math.sin(Math::PI*angle/180)).round \n\n return [x,y]\nend", "def location(x, y, theta, distance)\n \t return [\n \t x + distance * Math.cos(theta),\n \t y - distance * Math.sin(theta)\n \t ]\n \tend", "def location(x, y, theta, distance)\n\t [x + distance * Math.cos(theta), y - distance * Math.sin(theta)]\n\tend", "def getPointOnCircleFloat(cx,cy,r,angle)\n x = cx + (r*Math.cos(Math::PI*angle/180))\n y = cy + (r*Math.sin(Math::PI*angle/180)) \n\n return [x,y]\nend", "def bresenham_circle_coordinates\n coordinates = []\n\n populate_symmetric = -> (x, y) {\n coordinates << [x, y]\n coordinates << [x, -y]\n coordinates << [-x, -y]\n coordinates << [-x, y]\n coordinates << [y, x]\n coordinates << [y, -x]\n coordinates << [-y, -x]\n coordinates << [-y, x]\n }\n\n # start from the upper point of the circle\n x = 0\n y = @r\n\n delta = 3 - 2 * y\n\n while x <= y do\n populate_symmetric[x, y]\n\n if delta < 0\n delta += 4 * x + 6\n else\n delta += 4 * (x - y) + 10\n y -= 1\n end\n\n x += 1\n end\n\n # move circle to proper center position\n coordinates.uniq.map { |x, y| [x + @x, y + @y] }\n end", "def coords\n coord_list = []\n (@x..(@x + @size_x - 1)).each do |i|\n (@y..(@y + @size_y - 1)).each do |j|\n coord = [i, j]\n coord_list << coord\n end\n end\n\n return coord_list\n end", "def coords_from_angle(theta)\n cos_theta = Math.cos(theta)\n sin_theta = Math.sin(theta)\n radius = @a * @b / Math.sqrt(@b * @b * cos_theta * cos_theta + @a * @a * sin_theta * sin_theta)\n [radius * cos_theta, radius * sin_theta]\n end", "def in_polar_coordinates\n return [] unless recognized_format?\n radius_data.map.with_index { |r, i| [i * 2 * Math::PI / radius_data.size, r] }\n end", "def coords(type=:cartesien)\n if type == :cartesien\n return [self.x, self.y]\n elsif type == :polar\n @polarcoords ||= [self.r, self.angle]\n return @polarcoords\n else\n Kernel.raise( \"Unknown coord type #{type}\" ) \n end\n end", "def calc_geo_rect\n \t deg_radius = (@radius / MILES_PER_ARC_DEGREE).ceil\n\n \t west_long = (@center_long - deg_radius).floor\n \t east_long = (@center_long + deg_radius).ceil\n\n \t south_lat = (@center_lat - deg_radius).floor\n \t north_lat = (@center_lat + deg_radius).ceil\n\n \t [west_long, east_long, south_lat, north_lat]\n end", "def surrounding(position, radius)\n dlat = 0.0001\n dlng = 0.0001\n (1..radius).map do |r|\n (-r..r).map do |rlat|\n points = [sum(position, [dlat * rlat, dlng * (r - rlat.abs)])]\n if rlat.abs != r\n points += [sum(position, [dlat * rlat, dlng * (rlat.abs - r)])]\n end\n points\n end.flatten(1)\n end\nend", "def index\n @center = params[:location].present? ? Location.location_from(params[:location]) : current_user.location\n locations = Location.near(@center).to_a\n @circles = Circle.where(location: locations.uniq)\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { render layout: false }\n end\n end", "def calculate_coordinates\n bresenham_circle_coordinates\n end", "def coordinate_bounds(latitude, longitude, radius)\n radius = radius.to_f\n factor = (Math::cos(latitude * Math::PI / 180.0) * 69.0).abs\n [\n latitude - (radius / 69.0),\n latitude + (radius / 69.0),\n longitude - (radius / factor),\n longitude + (radius / factor)\n ]\n end", "def coordinates(x0, y0, distance, angle)\n x1 = x0 + Math.cos(radians(angle)) * distance\n y1 = y0 + Math.sin(radians(angle)) * distance\n [x1,y1]\n end", "def coords\n [x, y]\n end", "def coordinates\n [@x, @y]\n end", "def locations\n Array(location)\n end", "def latlng\n [lat, lon]\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List all available style names
def style_names styles.keys end
[ "def styles\n mentos(:get_all_styles)\n end", "def character_style_names\n ::Kramdown::Parser::IdmlStory::HANDLED_CHARACTER_STYLES.map { |e|\n e.gsub('CharacterStyle/', '')\n }\n end", "def paragraph_style_names\n ::Kramdown::Parser::IdmlStory.paragraph_style_mappings.keys\n end", "def styles\n return @metadata[:styles]\n end", "def display_styles(problem) \n problem.styles.map(&:name).join(', ')\n end", "def getStyleName\n styleNameHelper(MODE_GET)\n end", "def styles\n @empty_style ||= Xl::Style.new\n [@empty_style].tap do |styles|\n worksheets.each {|s| styles.concat(s.styles)}\n end.uniq\n end", "def get_styles(format)\n params = { format: format }\n styles = self.http_get('/api/styles', params)['styles']\n styles_list = []\n styles.each do |style|\n return styles_list << Style.new(format, style)\n end\n end", "def styles\n a = []\n a << super\n a << {name: 'lt-gray', bg_color: \"A9A9A9\", b: true}\n a << {name: 'gray', bg_color: \"808080\", alignment: { horizontal: :center}, b: true}\n a.flatten\n end", "def style_name\n theme_color\n end", "def get_styles\n # what is self? ==> painter instance\n\n self.paintings.map do |painting|\n # return the array with just the style string\n # paintng.style\n\n # return hash for a painting title and style\n {style: painting.style, title: painting.title}\n end.uniq\n\n end", "def all_styles(include_hidden = false)\n doc = Scraping.noko_doc(URI.join(BASE_URL, '/beerstyles/'))\n root = doc.at_css('div.container-fluid')\n\n categories = root.css('h3').map(&:text)\n style_node = root.css('.styleGroup')\n\n styles = style_node.flat_map.with_index do |list, i|\n list.css('a').map do |x|\n category = categories[i]\n Style.new(x['href'].split('/').last.to_i, name: x.text).tap do |s|\n s.category = category\n end\n end\n end\n if include_hidden\n styles + hidden_styles\n else\n styles\n end\n end", "def printGetFormatStyles(dbName, formatName)\n printDebugMessage('printGetFormatStyles', 'Begin', 1)\n formatInfo = getFormatInfo(dbName, formatName)\n if formatInfo != nil\n formatInfo.each_element('styleInfoList/styleInfo') { |styleInfo|\n puts styleInfo.elements['name'].text\n }\n end\n printDebugMessage('printGetFormatStyles', 'End', 1)\n end", "def style name\n Attribute.new \"style = %p\" % [name]\n end", "def options_from_csl_styles(current = '')\n list = [ [ I18n.t('users.show.default_style'), '' ] ]\n\n APP_CONFIG['available_csl_styles'].each do |loc|\n list << [ APP_CONFIG['csl_style_names'][loc], loc ]\n end\n\n options_for_select(list, current)\n end", "def styles( album)\n return get_metadata( album )[:styles]\n end", "def styles\n @styles ||= Hash.new do |_styles, stylename|\n _styles[stylename] = Style.new\n _styles[stylename].stylename = stylename\n _styles[stylename].stylesheet = self\n _styles[stylename]\n end\n end", "def retrieve(name)\n self.all.detect{|style| style.name == name}\n end", "def style\n # returns styles\n throw NotImplementedError\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove notifications from problem editors
def remove_problem_upvote_notifications ((@resource.versions.map{ |version| version.user }).uniq - [@actor]).each do |editor| n = Notification.find_by(recipient: editor, actor: @actor, notifiable: @resource, action_type: "like") if !n.nil? n.destroy @removed += 1 end end end
[ "def removeNotifications\r\n @notifications.clear\r\n end", "def reset_errors_notification\n @notifications.delete(:error)\n end", "def removeCustomNotification sender\n return if notifications_table.selectedRow == -1\n removed = custom_notification_list[notifications_table.selectedRow]\n custom_notification_list.delete_at(notifications_table.selectedRow)\n\n update_custom_notification_list \n \n # Remove notification highlight from views\n NSApplication.sharedApplication.delegate.removeNotificationFromViews(removed)\n end", "def remove_proof_upvote_notifications\n ((@resource.versions.map{ |version| version.user }).uniq - [@actor]).each do |editor|\n n = Notification.find_by(recipient: @resource.user, actor: @actor, \n action_type: \"like\", \n notifiable: @resource) if @resource.user != @actor\n if !n.nil?\n n.destroy\n @removed += 1\n end\n end\n end", "def clear_notifications\n Notification.where(actor_id: self.id).destroy_all\n end", "def destroy_notifications\n Notification.where(notifiable_id: @lecture.id, notifiable_type: 'Lecture')\n .delete_all\n end", "def clear_notifications\n Notification.where(actor_id: id).destroy_all\n end", "def clear_check_notification\n @notifications.delete(:check)\n end", "def remove_all\n @input_note_messages.clear\n mark_changed\n true\n end", "def destroy_all\n current_user.notifications.delete_all\n current_user.touch\n end", "def delete_notifications\n Notification.where(origin_type: 'Message', origin_id: @message.id).destroy_all\n end", "def destroy_notifications\n Notification.where(notifiable_id: @course.id, notifiable_type: 'Course')\n .delete_all\n end", "def fRemoveNotificationsFrom (email)\n @users.removeNotificationsFrom(email)\n end", "def delete_notification\n Notification.where(origin_type: 'Review', origin_id: @review.id).destroy_all\n end", "def remove_notifier(notifier)\n @notifiers.delete(notifier)\n end", "def delete_notifications\n Notification.where(origin_type: 'Post', origin_id: @post.id).destroy_all\n @post.messages.each do |message|\n Notification.where(origin_type: 'Message', origin_id: message.id).destroy_all\n end\n end", "def strip_removed_issues!\n removed_issues.each { |issue| issue.update!(review_request: nil) }\n end", "def delete_notifier(name)\n @notifiers.delete(name) if defined? @notifiers\n end", "def exec_commande_notifications\n # On affiche toujours la liste des notifications\n clear\n notifications.wait_for_choix_and_execute\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove notifications from proof editors
def remove_proof_upvote_notifications ((@resource.versions.map{ |version| version.user }).uniq - [@actor]).each do |editor| n = Notification.find_by(recipient: @resource.user, actor: @actor, action_type: "like", notifiable: @resource) if @resource.user != @actor if !n.nil? n.destroy @removed += 1 end end end
[ "def removeNotifications\r\n @notifications.clear\r\n end", "def remove_problem_upvote_notifications\n ((@resource.versions.map{ |version| version.user }).uniq - [@actor]).each do |editor|\n n = Notification.find_by(recipient: editor,\n actor: @actor,\n notifiable: @resource,\n action_type: \"like\")\n if !n.nil?\n n.destroy\n @removed += 1\n end\n end\n\n end", "def clear_check_notification\n @notifications.delete(:check)\n end", "def removeCustomNotification sender\n return if notifications_table.selectedRow == -1\n removed = custom_notification_list[notifications_table.selectedRow]\n custom_notification_list.delete_at(notifications_table.selectedRow)\n\n update_custom_notification_list \n \n # Remove notification highlight from views\n NSApplication.sharedApplication.delegate.removeNotificationFromViews(removed)\n end", "def remove_all\n @input_note_messages.clear\n mark_changed\n true\n end", "def destroy_notifications\n Notification.where(notifiable_id: @lecture.id, notifiable_type: 'Lecture')\n .delete_all\n end", "def send_deletion_notification\n @notifiable = self\n @tutor = User.find(self.user_id)\n @student = User.find(self.pupil_id)\n Notification.create(:user => @tutor, :receiver_id => @student.id, :message => @tutor.title + ' has removed you from their student list')\n end", "def delete_notification\n Notification.where(origin_type: 'Review', origin_id: @review.id).destroy_all\n end", "def clear_notifications\n Notification.where(actor_id: id).destroy_all\n end", "def clear_notifications\n Notification.where(actor_id: self.id).destroy_all\n end", "def destroy_all\n current_user.notifications.delete_all\n current_user.touch\n end", "def fRemoveNotificationsFrom (email)\n @users.removeNotificationsFrom(email)\n end", "def remove_comment_upvote_notifications\n n = Notification.find_by(recipient: @resource.user, actor: @actor, \n action_type: \"like\",\n notifiable: @resource) if @resource.user != @actor\n if !n.nil?\n n.destroy\n @removed += 1\n end\n end", "def delete_notifications\n Notification.where(origin_type: 'Message', origin_id: @message.id).destroy_all\n end", "def uncheck\n @user_notifications.delete(:check)\n end", "def destroy_lecture_notifications\n lecture = Lecture.find_by_id(params[:lecture_id])\n return unless lecture.present?\n Notification.delete(current_user.active_notifications(lecture).pluck(:id))\n current_user.touch\n render :destroy_all\n end", "def delete_notifications\n Notification.where(origin_type: 'Post', origin_id: @post.id).destroy_all\n @post.messages.each do |message|\n Notification.where(origin_type: 'Message', origin_id: message.id).destroy_all\n end\n end", "def exec_commande_notifications\n # On affiche toujours la liste des notifications\n clear\n notifications.wait_for_choix_and_execute\n end", "def dont_notify_changes\n self.notified = true\n self.save\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove notification from owner of comment
def remove_comment_upvote_notifications n = Notification.find_by(recipient: @resource.user, actor: @actor, action_type: "like", notifiable: @resource) if @resource.user != @actor if !n.nil? n.destroy @removed += 1 end end
[ "def remove_from_notification (n)\n logger.debug2 \"comment id #{id}. Notification id #{n.id}. notification key #{n.noti_key}\" if debug_notifications\n # only modify unread notifications\n return unless n.noti_read == 'N'\n cn = notifications.where(\"notification_id = ?\", n.id).first\n logger.debug2 \"cn.class = #{cn.class}\" if debug_notifications\n logger.debug2 \"cn.id = #{cn.id}\" if cn and debug_notifications\n logger.debug2 \"cn.noti_key = #{cn.noti_key}\" if cn and debug_notifications\n logger.debug2 \"cn.from_user.short_user_name = #{cn.from_user.short_user_name}\" if cn and cn.from_user and debug_notifications\n logger.debug2 \"cn.to_user.short_user_name = #{cn.to_user.short_user_name}\" if cn and cn.to_user and debug_notifications\n # find no users before and after removing this comment from notification\n old_no_users = n.api_comments.collect { |c| c.user_id }.uniq.size\n new_users = n.api_comments.find_all { |ac| ac.id != id }.collect { |ac| ac.user }.uniq\n new_no_users = new_users.size\n if new_no_users == 0\n # last user for this unread notification has been removed\n logger.debug2 \"last user for this unread notification has been removed\" if debug_notifications\n n.destroy!\n return\n end\n return if old_no_users == new_no_users # unchanged number of users => unchanged notification\n if new_no_users > 3\n # unchanged noti_key and username array. Just change number of users\n logger.debug2 \"unchanged noti_key and username array. Just change number of users\" if debug_notifications\n notifications.delete(cn) if cn\n noti_options = n.noti_options\n noti_options[:no_users] = new_no_users\n noti_options[:no_other_users] = new_no_users - 2\n n.noti_options = noti_options\n n.save!\n return\n end\n # change noti_key, username array and number of users\n if n.noti_key !~ /^([a-z_]+)_(\\d)_v(\\d+)$/\n logger.debug2 \"invalid noti key format. noti key = #{noti_key}\"\n return\n end\n logger.debug2 \"change noti_key, username array and number of users\" if debug_notifications\n noti_key_prefix, noti_key_no_users, noti_key_version = $1, $2, $3\n noti_options = n.noti_options\n (1..3).each { |i| noti_options[\"username#{i}\".to_sym] = nil }\n usernames = new_users.collect { |u| u.short_user_name }\n 0.upto(usernames.size-1).each do |i|\n noti_options[\"username#{i+1}\".to_sym] = usernames[i]\n end\n noti_options[:no_users] = new_no_users\n noti_options[:no_other_users] = new_no_users - 2\n n.noti_key = \"#{noti_key_prefix}_#{new_no_users}_v#{noti_key_version}\"\n logger.debug2 \"noti_key: old = #{n.noti_key_was}, new = #{n.noti_key}\" if debug_notifications\n n.noti_options = noti_options\n notifications.delete(cn) if cn\n n.save!\n end", "def destroy_post_owner_notification_of_reply(reply)\n self.notifications.find_by_key(post_reply_notification_key(reply)).destroy rescue true\n end", "def destroy_post_owner_notification_of_reply(reply)\n unless self.user.role == \"Poster\"\n self.notifications.find_by_key(post_reply_notification_key(reply)).destroy rescue true\n else\n self.postable.notifications.find_by_key(post_reply_notification_key(reply)).destroy rescue true\n end\n end", "def send_deletion_notification\n @notifiable = self\n @tutor = User.find(self.user_id)\n @student = User.find(self.pupil_id)\n Notification.create(:user => @tutor, :receiver_id => @student.id, :message => @tutor.title + ' has removed you from their student list')\n end", "def delete_notification\n Notification.where(origin_type: 'Review', origin_id: @review.id).destroy_all\n end", "def delete_notification(principal_uri, notification)\n end", "def fRemoveNotificationsFrom (email)\n @users.removeNotificationsFrom(email)\n end", "def remove_notification(value)\n @children['notification'][:value].delete(value)\n end", "def unsubscribe_from_comments user\n subscription = find_or_build_comment_subscription user\n subscription.subscribed = false\n subscription.save!\n end", "def remove_proof_upvote_notifications\n ((@resource.versions.map{ |version| version.user }).uniq - [@actor]).each do |editor|\n n = Notification.find_by(recipient: @resource.user, actor: @actor, \n action_type: \"like\", \n notifiable: @resource) if @resource.user != @actor\n if !n.nil?\n n.destroy\n @removed += 1\n end\n end\n end", "def remove_with_notify(swimming_buddy)\n if @user.remove_friendship(swimming_buddy)\n NewsFeed.create_social_feed(\n @user.id,\n swimming_buddy.id,\n I18n.t('newsfeed.remove_title'),\n I18n.t('newsfeed.remove_body').gsub('{SWIMMER_NAME}', swimming_buddy.get_full_name)\n )\n # TODO: Create also achievement row accordingly?\n end\n end", "def clear_notifications\n Notification.where(actor_id: id).destroy_all\n end", "def remove_problem_upvote_notifications\n ((@resource.versions.map{ |version| version.user }).uniq - [@actor]).each do |editor|\n n = Notification.find_by(recipient: editor,\n actor: @actor,\n notifiable: @resource,\n action_type: \"like\")\n if !n.nil?\n n.destroy\n @removed += 1\n end\n end\n\n end", "def delete_notification notification_id\n delete \"user/notifications/#{notification_id}\"\n end", "def delete_comment!(permlink); delete_comment(permlink).broadcast!(true); end", "def unflag\n @comment = Comment.find(params[:comment_id])\n\n @comment.reported_users.clear\n\n redirect_to admin_comment_path(@comment.uni_module)\n end", "def delete_notification!(id: nil)\n self.notifications = @notifications.delete_if { |notification| notification.id == id }\n end", "def destroy\n Dropio::Client.instance.destroy_comment(self)\n end", "def removeCustomNotification sender\n return if notifications_table.selectedRow == -1\n removed = custom_notification_list[notifications_table.selectedRow]\n custom_notification_list.delete_at(notifications_table.selectedRow)\n\n update_custom_notification_list \n \n # Remove notification highlight from views\n NSApplication.sharedApplication.delegate.removeNotificationFromViews(removed)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
'anchor' is one of the ANCHOR_ constants above. 'where' is the pixel location to slide around, and slide_direction is +/1 to indicate which way to slide when showing. 'displacement' is where along the nonanchored axis the box should be.
def initialize(anchor, where, slide_direction, disp = 0) super() @rl = Opal::ResourceLocator.instance @bgcolor = Rubygame::Color[:blue] @border = Rubygame::Color[:white] @anchor = anchor @where = where @slide_direction = slide_direction @displacement = disp @slide_offset = 0 @speed = 120 setup_gui hide end
[ "def setup_slide\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n @move_obj.clear_move_info\n xpos = (flip ? -@acts[1] : @acts[1])\n ypos = @acts[2]\n slide(xpos, ypos, @acts[3], @acts[4])\n end", "def anchor=(value)\n @anchor = value\n end", "def setup_target_slide\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n args = [@acts[1], @acts[2], @acts[3], @acts[4]]\n if area_flag\n target_array.each do |target|\n target.slide(*args)\n end\n return\n end\n target.slide(*args)\n end", "def setup_target_slide\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n args = [@acts[1], @acts[2], @acts[3], @acts[4], @acts[5] || 0]\n if area_flag\n target_array.each do |target|\n target.slide(*args)\n end\n return\n end\n target.slide(*args)\n end", "def anchor; end", "def displace(left, top)\n self.displace_left = left\n self.displace_top = top\n gui.update_position\n self\n end", "def flow_bounding_box options = {}\n original_y, original_x = y, bounds.absolute_left\n canvas do\n bounding_box [original_x + (options.delete :position).to_f, @margin_box.absolute_top], options do\n self.y = original_y\n yield\n end\n end\n end", "def update_placement\n self.width = calc_window_width\n self.height = calc_window_height\n self.x = calc_window_x\n self.x = x < 0 ? 0 : x + width > Graphics.width ? Graphics.width - width : x\n self.y = calc_window_y\n self.y = y < 0 ? 0 : y + height > Graphics.height ? Graphics.height - height : y\n end", "def anchor_from(my_point, parent, parent_point, x_offset, y_offset)\n my_point = alignment_data_transformer(my_point)\n parent_point = alignment_data_transformer(parent_point)\n parent = $last_ui if parent == :previous\n set_layout_data com.ardor3d.extension.ui.layout.AnchorLayoutData.new(my_point, parent, parent_point, x_offset, y_offset)\n end", "def add_anchor(cmd)\n @positional_anchors[cmd] ||= []\n @positional_anchors[cmd].push @end_offset\n end", "def build_needle\n self.needle = NeedleView.alloc.initWithFrame(CGRectMake(0, 0, 77, 77))\n self.needle.backgroundColor = UIColor.clearColor\n self.needle.layer.anchorPoint = CGPointMake(2, 0.5)\n self.needle.center = [self.bounds.size.width/2, self.bounds.size.height/2]\n end", "def start_at(x, y)\n @anchor.from.col = x\n @anchor.from.row = y\n end", "def move_pointer(dy, make_space = false)\n @y -= dy\n if @y < @bottom_margin\n start_new_page\n @y -= dy if make_space\n elsif @y > absolute_top_margin\n @y = absolute_top_margin\n end\n end", "def slide_if_necessary\n if @showing\n # Calculate what the y position would be if the\n # palette were to slide up.\n new = @offset + @slide_speed\n if new >= height\n # If it will be above the max height, set it to\n # that.\n @offset = height\n else\n # Slide the palette up.\n @offset = new\n end\n else\n # Calculate what the y position would be if the\n # palette were to slide down.\n new = @offset - @slide_speed\n if @offset <= 0\n # If it will be below the min height, set it to\n # that.\n @offset = 0\n else\n # Slide the palette down.\n @offset = new\n end\n end\n end", "def rotation_anchor\n [0.7, 0.5]\nend", "def flow_bounding_box left = 0, opts = {}\n original_y = self.y\n # QUESTION should preserving original_x be an option?\n original_x = bounds.absolute_left - margin_box.absolute_left\n canvas do\n bounding_box [margin_box.absolute_left + original_x + left, margin_box.absolute_top], opts do\n self.y = original_y\n yield\n end\n end\n end", "def setup_target_slide\n return unless PONY::ERRNO::check_sequence(current_act)\n args = [@acts[1], @acts[2], @acts[3], @acts[4], @acts[5] || 0]\n current_action_targets.each do |target|\n target.slide(*args)\n end\n end", "def alias anchor\n raise \"Unexpected alias #{anchor}\"\n end", "def anchor(name)\n line_anchor(name)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adjusts the scale (and inverse_scale) by the given amount ZOOM_SPEED
def zoom(delay) self.scale += delay * ZOOM_SPEED end
[ "def update_zoom\n if self.zoom_x < 2\n self.zoom_x += 0.05\n self.zoom_y += 0.05\n end\n end", "def update_zoom\n @effectus_old_zoom_x = @picture.zoom_x\n @effectus_old_zoom_y = @picture.zoom_y\n self.zoom_x = @effectus_old_zoom_x / 100.0\n self.zoom_y = @effectus_old_zoom_y / 100.0\n end", "def vscale(factor)\n @height = @height * factor\n @top *= factor\n self\n end", "def scale_up(scale)\n self.length *= scale\n self.width *= scale\n end", "def incr_zoom(val = 0.02)\n @zoom_incr += val\n new_zoom = 2 ** @zoom_incr\n self.zoom = new_zoom\n end", "def slew_scale(scale, factor)\n @scale *= (scale/@scale)**factor\n end", "def incr_zoom(val = 0.02)\n @zoom_incr += val\n new_zoom = 2 ** @zoom_incr\n self.zoom = new_zoom\n end", "def unzoom_by(value)\n self.size *= value\n end", "def update_zoom\n self.zoom_x = @battler.zoom_x\n self.zoom_y = @battler.zoom_y\n end", "def update_icon_mp_ex_anime\r\r\n return if !MP_ICON_EX_ZOOM_EFFECT\r\r\n if @mp_icon3_anime_phase == 0\r\r\n @mp_icon3.zoom_x += 0.01\r\r\n if @mp_icon3.zoom_x >= 1.30\r\r\n @mp_icon3.zoom_x = 1.30\r\r\n @mp_icon3_anime_phase = 1\r\r\n end \r\r\n else\r\r\n @mp_icon3.zoom_x -= 0.01\r\r\n if @mp_icon3.zoom_x <= 1.05\r\r\n @mp_icon3.zoom_x = 1.05\r\r\n @mp_icon3_anime_phase = 0\r\r\n end \r\r\n end \r\r\n @mp_icon3.zoom_y = @mp_icon3.zoom_x\r\r\n end", "def update_icon_mp_ex_anime\n return if !MP_ICON_EX_ZOOM_EFFECT\n if @mp_icon3_anime_phase == 0\n @mp_icon3.zoom_x += 0.01\n if @mp_icon3.zoom_x >= 1.30\n @mp_icon3.zoom_x = 1.30\n @mp_icon3_anime_phase = 1\n end \n else\n @mp_icon3.zoom_x -= 0.01\n if @mp_icon3.zoom_x <= 1.05\n @mp_icon3.zoom_x = 1.05\n @mp_icon3_anime_phase = 0\n end \n end \n @mp_icon3.zoom_y = @mp_icon3.zoom_x\n end", "def update_scale\n differences = target_scale.round(2) - @node.xScale.round(2)\n\n return if differences.zero?\n\n @node.xScale += differences * @scale_rate\n @node.yScale += differences * @scale_rate\n end", "def zoom_scale; end", "def fix_scale\n @window_scale = (PARGV[:scale] || @window_scale).to_i\n @window_scale = 2 if @window_scale < 0.1\n end", "def update_viewport_zoom\n if TH::Overlay_Map_Zoom::Parallax_Zoom\n zoom_x == viewport.zoom\n @phase_viewport_zoom = true\n self.zoom_x = viewport.zoom\n self.zoom_y = viewport.zoom\n self.ox = - ((Graphics.width >> 1) +\n (ox - (Graphics.width >> 1)) * viewport.zoom).to_i\n self.oy = - ((Graphics.height >> 1) +\n (oy - (Graphics.height >> 1)) * viewport.zoom).to_i\n @phase_viewport_zoom = false\n end\n end", "def scale_by( scale_factor )\n\t\t\tpoints.each{ |p| p.scale_by!( scale_factor ) }\n\t\tend", "def scale= scale\n protected_use_method(MM::Scaling, :@scale, scale)\n end", "def scale!(x, y, z)\n scale x, y, z, self\n end", "def scale(value)\r\n value * @height/2 + @height/4\r\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Register a lock to be renewed every extend_interval seconds.
def register(lock, extend_interval) registration = Registration.new registration.lock = lock registration.mutex = Mutex.new registration.thread = Thread.current registration.acquired_at = Time.now registration.extend_interval = extend_interval registration.released = false @locks_mutex.synchronize do locks << registration end registration end
[ "def extend_lock_if_expires_in_less_than(duration)\n extend_lock if duration > remaining_lock_time\n end", "def lock_duration=(interval)\n @lock_duration = Core::Utils::Interval.try_convert(interval)\n end", "def renew!(holder:)\n if held_by?(holder)\n touch\n\n Lux::LOCK_OK\n else\n Lux::LOCK_NOT_OWNED\n end\n end", "def lock_account!\n self.update(unlocks_at:LOCKOUT_DURATION.from_now, lockout_strikes:0)\n end", "def relock_every\n @relock_every ||= 5\n end", "def lock_time\n 60\n end", "def extend_locks\n # Make a local copy of the locks array to avoid accessing it outside of the mutex.\n locks_copy = @locks_mutex.synchronize { locks.dup }\n locks_copy.each { |registration| extend_lock(registration) }\n @locks_mutex.synchronize do\n locks.delete_if(&:released)\n end\n end", "def lock_account!\n self.update!(\n account_unlocks_at: Time.current + Tolaria.config.lockout_duration,\n lockout_strikes: 0,\n )\n end", "def extend(time)\n self.expires_on += time\n self\n end", "def lock_after_execution_period\n @lock_after_execution_period ||= 0\n end", "def lock(resource, ttl, options = {}, &block)\n lock_info = try_lock_instances(resource, ttl, options)\n if options[:extend_only_if_life] && !Gem::Deprecate.skip\n warn 'DEPRECATION WARNING: The `extend_only_if_life` option has been renamed `extend_only_if_locked`.'\n options[:extend_only_if_locked] = options[:extend_only_if_life]\n end\n if options[:extend_life] && !Gem::Deprecate.skip\n warn 'DEPRECATION WARNING: The `extend_life` option has been renamed `extend_only_if_locked`.'\n options[:extend_only_if_locked] = options[:extend_life]\n end\n\n if block_given?\n begin\n yield lock_info\n !!lock_info\n ensure\n unlock(lock_info) if lock_info\n end\n else\n lock_info\n end\n end", "def refresh_lock(ttl)\n check_exists\n SideJob.redis.expire \"#{redis_key}:lock\", ttl\n end", "def refresh_lock\n raise NotImplementedError\n end", "def lock(max_time = nil)\n raise 'lock must be called with a block' unless block_given?\n started_at = current_period\n has_lock = false\n until has_lock\n now = current_period\n if max_time && (now - started_at) >= max_time\n raise Unavailable.new(\"Unable to obtain a lock after #{now - started_at}ms\")\n end\n lockable_time = rounded_period now\n current_key = KEY_PREFIX + lockable_time.to_s\n count = redis.incr current_key\n if count <= amount\n has_lock = true\n # Now we have a lock, we need to actually set the expiration of\n # the key. Note, we only ever set this on the first set to avoid\n # setting @amount times...\n if count == 1\n # Expire after 3 periods. This means we only\n # ever keep a small number in memory.\n expires_after = ((period * 3).to_f / 1000).ceil\n redis.expire current_key, expires_after\n redis.setex \"#{current_key}:obtained_at\", now, expires_after\n end\n else\n obtained_at = [redis.get(\"#{current_key}:obtained_at\").to_i, lockable_time].max\n next_period = (lockable_time + period)\n wait_for = (next_period - current_period).to_f / 1000\n yield wait_for\n end\n end\n end", "def renew_account_until(account, expiration_time) \n # account = find_active_account(account)\n # account.valid_until = expiration_time\n MISS\n end", "def lock_expired?; end", "def add(args={}, &block)\n Thread.exclusive do\n @items[block] = {\n :remaining => args[:period].to_f, \n :reset => args[:once] ? 0 : args[:period].to_f\n }\n end\n retime\n block\n end", "def regulate!\n if self.available?\n if @mutex.locked?\n @mutex.unlock\n end\n else\n @mutex.try_lock\n end\n end", "def lock_for(duration)\n @locked = true\n @mutex.synchronize { sleep duration }\n @locked = false\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Extend all currently registered locks that have been held longer than the extend_interval since they were last acquired/extended. If any locks have expired (should not happen), it will release them.
def extend_locks # Make a local copy of the locks array to avoid accessing it outside of the mutex. locks_copy = @locks_mutex.synchronize { locks.dup } locks_copy.each { |registration| extend_lock(registration) } @locks_mutex.synchronize do locks.delete_if(&:released) end end
[ "def extend_lock_if_expires_in_less_than(duration)\n extend_lock if duration > remaining_lock_time\n end", "def register(lock, extend_interval)\n registration = Registration.new\n registration.lock = lock\n registration.mutex = Mutex.new\n registration.thread = Thread.current\n registration.acquired_at = Time.now\n registration.extend_interval = extend_interval\n registration.released = false\n @locks_mutex.synchronize do\n locks << registration\n end\n registration\n end", "def unlock_all!\n locks.active.each(&:unlock!)\n end", "def refresh_lock\n if locked?\n @store.transaction do\n @store[:lockdiscovery].last[:timeout] = timeout_node\n end\n\n fetch_lock_info\n else\n refresh_ancestor_locks @ancestor_path, @ancestors.dup\n end\n end", "def relock_every\n @relock_every ||= 5\n end", "def unlock_all\n Delayed::Job.transaction do\n Delayed::Job.where(:locked_by => hostname).update_all(:locked_by => nil, :locked_at => nil)\n end\n end", "def drain_permits\n mutexes = @count.times.map { |index| mutex_object(index: index) }\n mutexes.select! { |mutex| mutex.try_lock }\n\n @permits.push(*mutexes)\n\n mutexes.size\n end", "def unlock_all\n update_all('$set': { locking_name_field => nil, locked_at_field => nil }).modified_count\n end", "def hold_jobs!(wait: false)\n self.jobs_held = true\n save! if changed?\n delayed_jobs_shard.activate(::Delayed::Backend::ActiveRecord::AbstractJob) do\n lock_jobs_for_hold\n end\n return unless wait\n\n delayed_jobs_shard.activate(::Delayed::Backend::ActiveRecord::AbstractJob) do\n while ::Delayed::Job.where(shard_id: id)\n .where.not(locked_at: nil)\n .where.not(locked_by: ::Delayed::Backend::Base::ON_HOLD_LOCKED_BY).exists?\n sleep 10\n lock_jobs_for_hold\n end\n end\n end", "def lock(max_time = nil)\n raise 'lock must be called with a block' unless block_given?\n started_at = current_period\n has_lock = false\n until has_lock\n now = current_period\n if max_time && (now - started_at) >= max_time\n raise Unavailable.new(\"Unable to obtain a lock after #{now - started_at}ms\")\n end\n lockable_time = rounded_period now\n current_key = KEY_PREFIX + lockable_time.to_s\n count = redis.incr current_key\n if count <= amount\n has_lock = true\n # Now we have a lock, we need to actually set the expiration of\n # the key. Note, we only ever set this on the first set to avoid\n # setting @amount times...\n if count == 1\n # Expire after 3 periods. This means we only\n # ever keep a small number in memory.\n expires_after = ((period * 3).to_f / 1000).ceil\n redis.expire current_key, expires_after\n redis.setex \"#{current_key}:obtained_at\", now, expires_after\n end\n else\n obtained_at = [redis.get(\"#{current_key}:obtained_at\").to_i, lockable_time].max\n next_period = (lockable_time + period)\n wait_for = (next_period - current_period).to_f / 1000\n yield wait_for\n end\n end\n end", "def lock\n old = @locked\n\n unless @locked\n total_count = @cleaner.failure.count\n if total_count>@maximum\n @start_index = total_count-@maximum\n @jobs = all( @start_index, @maximum)\n else\n @start_index = 0\n @jobs = all( 0, total_count)\n end\n end\n\n @locked = true\n yield\n ensure\n @locked = old\n end", "def lock_expired?; end", "def refresh_lock\n raise NotImplementedError\n end", "def lock_after_execution_period\n @lock_after_execution_period ||= 0\n end", "def lock_account!\n self.update(unlocks_at:LOCKOUT_DURATION.from_now, lockout_strikes:0)\n end", "def grow\n @lock.synchronize do\n prune\n logger.debug { \"jobs: #{num_jobs}; busy: #{num_working}; idle: #{num_idle}\" }\n if @size == 0 || (@size < @max_size && num_jobs > 0 && num_jobs > num_idle) then\n space = @max_size-@size\n jobs = num_jobs-num_idle\n needed = space < jobs ? space : jobs\n needed = 1 if needed <= 0\n expand(needed)\n else\n logger.debug \"NOT growing the pool!\"\n end\n end\n\n nil\n end", "def supported_locks\n []\n end", "def locks\n sql = %q(\n select\n pg_stat_activity.procpid,\n pg_class.relname,\n pg_locks.transactionid,\n pg_locks.granted,\n substr(pg_stat_activity.current_query,1,30) as query_snippet,\n age(now(),pg_stat_activity.query_start) as \"age\"\n from pg_stat_activity,pg_locks left\n outer join pg_class on (pg_locks.relation = pg_class.oid)\n where pg_stat_activity.current_query <> '<insufficient privilege>' and\n pg_locks.pid=pg_stat_activity.procpid and pg_locks.mode = 'ExclusiveLock' order by query_start)\n\n exec_sql(sql, find_uri)\n end", "def allowed_blocking_locks_remaining\n 0\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /selecaos/1 GET /selecaos/1.json
def show @selecao = Selecao.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @selecao } end end
[ "def show\n @seguro = Seguro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @seguro }\n end\n end", "def show\n @secao = Secao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @secao }\n end\n end", "def show\n @seminario = Seminario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @seminario }\n end\n end", "def index\n @socios = Socio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @socios }\n end\n end", "def show\n @sueldo = Sueldo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sueldo }\n end\n end", "def show\n @soiree = Soiree.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @soiree }\n end\n end", "def show\n @sezione = Sezione.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sezione }\n end\n end", "def index\n @solicitacaos = Solicitacao.find(:all, :conditions => {:usuario_id => current_usuario.id})\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @solicitacaos }\n end\n end", "def index\n @secciones = Seccion.order(\"grado_id\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @secciones }\n end\n end", "def show\n @asesoria = Asesoria.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asesoria }\n end\n end", "def show\n @escola = Escola.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @escola }\n end\n end", "def show\n @esclerosi = Esclerosi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @esclerosi }\n end\n end", "def index\n\n if params[:ventas_seguimiento]\n cliente_id = params[:ventas_seguimiento][:cliente_id]\n @ventas_seguimientos = Ventas::Seguimiento.where(\"cliente_id = ?\",cliente_id).order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 5)\n @seguimientos = Ventas::Seguimiento.new(:cliente_id => cliente_id)\n else\n @ventas_seguimientos = Ventas::Seguimiento.order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 5)\n @seguimientos = Ventas::Seguimiento.new\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_seguimientos }\n end\n end", "def index\n @solicitantes = Solicitante.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @solicitantes }\n end\n end", "def show\n @sorvete = Sorvete.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sorvete }\n end\n end", "def index\n @seos = Seo.all\n end", "def show\n @estudiante = Estudiante.find(params[:id])\n\n render json: @estudiante\n end", "def show\n @seguidore = Seguidore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @seguidore }\n end\n end", "def show\n @ventas_seguimiento = Ventas::Seguimiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ventas_seguimiento }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /selecaos/new GET /selecaos/new.json
def new @selecao = Selecao.new respond_to do |format| format.html # new.html.erb format.json { render json: @selecao } end end
[ "def new\n @newse = Newse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newse }\n end\n end", "def new\n @seguro = Seguro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seguro }\n end\n end", "def new\n @secao = Secao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @secao }\n end\n end", "def create\n @newse = Newse.new(params[:newse])\n\n respond_to do |format|\n if @newse.save\n format.html { redirect_to newses_path, notice: t('newses.successfully_created') }\n format.json { render json: @newse, status: :created, location: @newse }\n else\n format.html { render action: \"new\" }\n format.json { render json: @newse.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @sezione = Sezione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sezione }\n end\n end", "def new\n @seguidore = Seguidore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seguidore }\n end\n end", "def new\n @solicitud = Solicitud.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @solicitud }\n end\n end", "def new\n @escola = Escola.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @escola }\n end\n end", "def new\n @seminario = Seminario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seminario }\n end\n end", "def new\n @socio = Socio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @socio }\n end\n end", "def new\n @salle = Salle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @salle }\n end\n end", "def new\n @sistema = Sistema.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sistema }\n end\n end", "def new\n @estatuto = Estatuto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @estatuto }\n end\n end", "def new\r\n @salle = Salle.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @salle }\r\n end\r\n end", "def new\n @tipo_seguro = TipoSeguro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_seguro }\n end\n end", "def new\n @socio = Socio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @socio }\n end\n end", "def new\n @posizione = Posizione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @posizione }\n end\n end", "def new\n @caixa = Caixa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @caixa }\n end\n end", "def new\n @servico = Servico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @servico }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /selecaos POST /selecaos.json
def create @selecao = Selecao.new(params[:selecao]) respond_to do |format| if @selecao.save format.html { redirect_to @selecao, notice: 'Selecao was successfully created.' } format.json { render json: @selecao, status: :created, location: @selecao } else format.html { render action: "new" } format.json { render json: @selecao.errors, status: :unprocessable_entity } end end end
[ "def create\n @seito = Seito.new(seito_params)\n\n respond_to do |format|\n if @seito.save\n format.html { redirect_to @seito, notice: \"生徒を追加しました\" }\n format.json { render :show, status: :created, location: @seito }\n else\n format.html { render :new }\n format.json { render json: @seito.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @seguro = Seguro.new(params[:seguro])\n\n respond_to do |format|\n if @seguro.save\n format.html { redirect_to @seguro, notice: 'Seguro was successfully created.' }\n format.json { render json: @seguro, status: :created, location: @seguro }\n else\n format.html { render action: \"new\" }\n format.json { render json: @seguro.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @seguro = Seguro.new(seguro_params)\n\n respond_to do |format|\n if @seguro.save\n format.html { redirect_to @seguro, notice: 'Seguro was successfully created.' }\n format.json { render :show, status: :created, location: @seguro }\n else\n format.html { render :new }\n format.json { render json: @seguro.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sesione = Sesione.new(sesione_params)\n\n respond_to do |format|\n if @sesione.save\n format.html { redirect_to @sesione, notice: 'Sesione was successfully created.' }\n format.json { render :show, status: :created, location: @sesione }\n else\n format.html { render :new }\n format.json { render json: @sesione.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @secao = Secao.new(params[:secao])\n\n respond_to do |format|\n if @secao.save\n format.html { redirect_to @secao, notice: 'Secao was successfully created.' }\n format.json { render json: @secao, status: :created, location: @secao }\n else\n format.html { render action: \"new\" }\n format.json { render json: @secao.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @seminario = Seminario.new(params[:seminario])\n\n respond_to do |format|\n if @seminario.save\n format.html { redirect_to @seminario, notice: 'Seminario was successfully created.' }\n format.json { render json: @seminario, status: :created, location: @seminario }\n else\n format.html { render action: \"new\" }\n format.json { render json: @seminario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @soatseguro = Soatseguro.new(soatseguro_params)\n\n respond_to do |format|\n if @soatseguro.save\n format.html { redirect_to @soatseguro, notice: 'Soatseguro was successfully created.' }\n format.json { render :show, status: :created, location: @soatseguro }\n else\n format.html { render :new }\n format.json { render json: @soatseguro.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @estudiante = Estudiante.new(params[:estudiante])\n\n if @estudiante.save\n render json: @estudiante, status: :created, location: @estudiante\n else\n render json: @estudiante.errors, status: :unprocessable_entity\n end\n end", "def create\n @sueldo = Sueldo.new(params[:sueldo])\n\n respond_to do |format|\n if @sueldo.save\n format.html { redirect_to @sueldo, notice: 'Sueldo was successfully created.' }\n format.json { render json: @sueldo, status: :created, location: @sueldo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sueldo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n excursao = Excursao.new(excursaos_params)\n\n if excursao.save\n render status: :no_content, json: {}\n else\n render status: :bad_request, json: excursao.errors.messages\n end\n end", "def create\n @establecimiento = Establecimiento.new(establecimiento_params)\n\n if @establecimiento.save\n render json: @establecimiento, status: :created, location: @establecimiento\n else\n render json: @establecimiento.errors, status: :unprocessable_entity\n end\n end", "def create\n @sueldo = Sueldo.new(sueldo_params)\n\n respond_to do |format|\n if @sueldo.save\n format.html { redirect_to @sueldo, notice: 'Sueldo was successfully created.' }\n format.json { render :show, status: :created, location: @sueldo }\n else\n format.html { render :new }\n format.json { render json: @sueldo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pessoa = Pessoa.new(pessoa_params)\n if @pessoa.save\n render json: @pessoa\n else\n render json: @pessoa.errors, status: :unprocessable_entity\n end\n end", "def create\n @escola = Escola.new(params[:escola])\n\n respond_to do |format|\n if @escola.save\n format.html { redirect_to @escola, :notice => 'Escola was successfully created.' }\n format.json { render :json => @escola, :status => :created, :location => @escola }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @escola.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @soiree = Soiree.new(params[:soiree])\n\n respond_to do |format|\n if @soiree.save\n format.html { redirect_to @soiree, notice: 'Soiree was successfully created.' }\n format.json { render json: @soiree, status: :created, location: @soiree }\n else\n format.html { render action: \"new\" }\n format.json { render json: @soiree.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @esclerosi = Esclerosi.new(params[:esclerosi])\n\n respond_to do |format|\n if @esclerosi.save\n format.html { redirect_to @esclerosi, notice: 'Esclerosi was successfully created.' }\n format.json { render json: @esclerosi, status: :created, location: @esclerosi }\n else\n format.html { render action: \"new\" }\n format.json { render json: @esclerosi.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @socio = Socio.new(params[:socio])\n\n respond_to do |format|\n if @socio.save\n format.html { redirect_to @socio, :notice => 'Socio cadastrado com sucesso.' }\n format.json { render :json => @socio, :status => :created, :location => @socio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @socio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @estatuto = Estatuto.new(params[:estatuto])\n\n respond_to do |format|\n if @estatuto.save\n format.html { redirect_to @estatuto, notice: 'Estatuto was successfully created.' }\n format.json { render json: @estatuto, status: :created, location: @estatuto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @estatuto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @salle = Salle.new(params[:salle])\n\n respond_to do |format|\n if @salle.save\n format.html { redirect_to @salle, notice: 'Salle was successfully created.' }\n format.json { render json: @salle, status: :created, location: @salle }\n else\n format.html { render action: \"new\" }\n format.json { render json: @salle.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /selecaos/1 PUT /selecaos/1.json
def update @selecao = Selecao.find(params[:id]) respond_to do |format| if @selecao.update_attributes(params[:selecao]) format.html { redirect_to @selecao, notice: 'Selecao was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @selecao.errors, status: :unprocessable_entity } end end end
[ "def update\n\n excursao = Excursao.find params[:id]\n \n if excursao.save excursaos_params\n render status: :no_content, json: {}\n else\n render status: :bad_request, json: excursao.errors.messages\n end\n end", "def update\n @seguro = Seguro.find(params[:id])\n\n respond_to do |format|\n if @seguro.update_attributes(params[:seguro])\n format.html { redirect_to @seguro, notice: 'Seguro was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @seguro.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @secao = Secao.find(params[:id])\n\n respond_to do |format|\n if @secao.update_attributes(params[:secao])\n format.html { redirect_to @secao, notice: 'Secao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @secao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_aos_version(args = {}) \n put(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def update\n @seminario = Seminario.find(params[:id])\n\n respond_to do |format|\n if @seminario.update_attributes(params[:seminario])\n format.html { redirect_to @seminario, notice: 'Seminario was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @seminario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @socio_serasa.update(socio_serasa_params)\n format.html { redirect_to @socio_serasa, notice: 'Socio serasa was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @socio_serasa.errors, status: :unprocessable_entity }\n end\n end\n end", "def put *args\n make_request :put, *args\n end", "def update\n @soiree = Soiree.find(params[:id])\n\n respond_to do |format|\n if @soiree.update_attributes(params[:soiree])\n format.html { redirect_to @soiree, notice: 'Soiree was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @soiree.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @estudiante = Estudiante.find(params[:id])\n\n if @estudiante.update(params[:estudiante])\n head :no_content\n else\n render json: @estudiante.errors, status: :unprocessable_entity\n end\n end", "def update\n @asesoria = Asesoria.find(params[:id])\n\n respond_to do |format|\n if @asesoria.update_attributes(params[:asesoria])\n format.html { redirect_to @asesoria, notice: 'Asesoria was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asesoria.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @socio = Socio.find(params[:id])\n\n respond_to do |format|\n if @socio.update_attributes(params[:socio])\n format.html { redirect_to @socio, :notice => 'Socio atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @socio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put\n request_method('PUT')\n end", "def put(*a) route 'PUT', *a end", "def update\n @osoba = Osoba.find(params[:id])\n\n if @osoba.update(params[:osoba])\n head :no_content\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n @estoque = Estoque.find(params[:id])\n\n respond_to do |format|\n if @estoque.update_attributes(params[:estoque])\n format.html { redirect_to @estoque, notice: 'Estoque was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @estoque.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @seguidore = Seguidore.find(params[:id])\n\n respond_to do |format|\n if @seguidore.update_attributes(params[:seguidore])\n format.html { redirect_to @seguidore, notice: 'Seguidore was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @seguidore.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @oase = Oasis.find(params[:id])\n\n respond_to do |format|\n if @oase.update_attributes(params[:oase])\n format.html { redirect_to @oase, notice: 'Oasis was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @oase.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @inventario_cosa.update(inventario_cosa_params)\n format.html { redirect_to @inventario_cosa, notice: 'Inventario cosa was successfully updated.' }\n format.json { render :show, status: :ok, location: @inventario_cosa }\n else\n format.html { render :edit }\n format.json { render json: @inventario_cosa.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /selecaos/1 DELETE /selecaos/1.json
def destroy @selecao = Selecao.find(params[:id]) @selecao.destroy respond_to do |format| format.html { redirect_to selecaos_url } format.json { head :no_content } end end
[ "def destroy\n @seguro = Seguro.find(params[:id])\n @seguro.destroy\n\n respond_to do |format|\n format.html { redirect_to seguros_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @seguidore = Seguidore.find(params[:id])\n @seguidore.destroy\n\n respond_to do |format|\n format.html { redirect_to seguidores_url }\n format.json { head :ok }\n end\n end", "def destroy\n @seminario = Seminario.find(params[:id])\n @seminario.destroy\n\n respond_to do |format|\n format.html { redirect_to seminarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sueldo = Sueldo.find(params[:id])\n @sueldo.destroy\n\n respond_to do |format|\n format.html { redirect_to sueldos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @secao = Secao.find(params[:id])\n @secao.destroy\n\n respond_to do |format|\n format.html { redirect_to secaos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @escola = Escola.find(params[:id])\n @escola.destroy\n\n respond_to do |format|\n format.html { redirect_to escolas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sezione = Sezione.find(params[:id])\n @sezione.destroy\n\n respond_to do |format|\n format.html { redirect_to sezioni_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @semaine.destroy\n respond_to do |format|\n format.html { redirect_to semaines_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n\n head :no_content\n end", "def destroy\n @seccion = Seccion.find(params[:id])\n @seccion.destroy\n\n respond_to do |format|\n format.html { redirect_to seccions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @soiree = Soiree.find(params[:id])\n @soiree.destroy\n\n respond_to do |format|\n format.html { redirect_to soirees_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @esclerosi = Esclerosi.find(params[:id])\n @esclerosi.destroy\n\n respond_to do |format|\n format.html { redirect_to esclerosis_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @salle = Salle.find(params[:id])\n @salle.destroy\n\n respond_to do |format|\n format.html { redirect_to salles_url }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @estatuto = Estatuto.find(params[:id])\n @estatuto.destroy\n\n respond_to do |format|\n format.html { redirect_to estatutos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @sobre = Sobre.find(params[:id])\n @sobre.destroy\n\n respond_to do |format|\n format.html { redirect_to sobres_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sorvete = Sorvete.find(params[:id])\n @sorvete.destroy\n\n respond_to do |format|\n format.html { redirect_to sorvetes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sesion.destroy\n respond_to do |format|\n format.html { redirect_to sesiones_url }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /franchises GET /franchises.json
def index @franchises = Franchise.all end
[ "def show \n @franchise = @franchise_set.franchises.find(params[:id])\n\n respond_with(@franchise_set, @franchise)\n end", "def show\n @devenir_franchise = DevenirFranchise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @devenir_franchise }\n end\n end", "def index\n @franchises = @habitat.franchises.find(:all)\n \n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @franchises.to_xml }\n end\n end", "def show \n @franchise_set = FranchiseSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @franchise_set }\n end\n end", "def show\n @feast = Feast.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feast }\n end\n end", "def new \n @franchise_set = @franchise_set.franchises.new\n @franchise = @franchise_set.franchises.build\n\n respond_with(@franchise_set, @franchise)\n end", "def show\n @featuring = Featuring.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @featuring }\n end\n end", "def index\n @fretes = Frete.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fretes }\n end\n end", "def index\n @frais_hebergements = FraisHebergement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @frais_hebergements }\n end\n end", "def show\n @forest = Forest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @forest }\n end\n end", "def index\n\t @fares = Fare.all\n\n\t respond_to do |format|\n\t\tformat.html # index.html.erb\n\t\tformat.json { render json: @fares }\n\t end\n\tend", "def show\n @fundraiser = Fundraiser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fundraiser }\n end\n end", "def show\n @ragefest = Ragefest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ragefest }\n end\n end", "def display_franchises(company)\n puts \"#{company.name} owns these franchises:\"\n company.franchises.select { |franchise| puts \"Franchise #{franchise.id} in #{franchise.location}\" }\n end", "def new \n @franchise_set = FranchiseSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @franchise_set }\n end\n end", "def index\n @filials = Filial.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @filials }\n end\n end", "def new\n @devenir_franchise = DevenirFranchise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @devenir_franchise }\n end\n end", "def index\n @frizures = Frizure.all\n end", "def show\n @flier = Flier.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @flier }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Converts the given field to the value that the database adapter returns as a usable column name: column_alias_for("users.id") => "users_id" column_alias_for("sum(id)") => "sum_id" column_alias_for("count(distinct users.id)") => "count_distinct_users_id" column_alias_for("count()") => "count_all"
def column_alias_for(field) column_alias = +field column_alias.gsub!(/\*/, "all") column_alias.gsub!(/\W+/, " ") column_alias.strip! column_alias.gsub!(/ +/, "_") @connection.table_alias_for(column_alias) end
[ "def column_alias_for(field); end", "def column_alias(column)\r\n end", "def translate_column(col, mapping)\n if mapping[col][:name]\n mapping[col][:name]\n else\n if col[-3,3] == \"_id\"\n col = col[0, col.length - 3]\n end\n col.humanize\n end\n end", "def data_column\n \"#{aggregation_function}(#{aggregation_column})\"\n end", "def column_name(name_or_alias)\n _column_aliases[name_or_alias] || name_or_alias\n end", "def alias_field(alias_name_, field_name_)\n @aliases[alias_name_.to_sym] = field_name_.to_sym\n end", "def field_name(field)\n \"#{object_name}[#{field}]\"\n end", "def database_field_name(name, relations, aliased_fields, aliased_associations)\n return nil unless name.present?\n key = name.to_s\n segment, remaining = key.split('.', 2)\n\n # Don't get the alias for the field when a belongs_to association\n # is not the last item. Therefore, get the alias when one of the\n # following is true:\n # 1. This is the last item, i.e. there is no remaining.\n # 2. It is not an association.\n # 3. It is not a belongs association\n if !remaining || !relations.key?(segment) || !relations[segment].is_a?(Association::Referenced::BelongsTo)\n segment = aliased_fields[segment]&.dup || segment\n end\n\n return segment unless remaining\n\n relation = relations[aliased_associations[segment] || segment]\n if relation\n k = relation.klass\n \"#{segment}.#{database_field_name(remaining, k.relations, k.aliased_fields, k.aliased_associations)}\"\n else\n \"#{segment}.#{remaining}\"\n end\n end", "def field_name(field)\n field.is_a?(Symbol) ? field.to_field_name : field\n end", "def col_name(col)\n [@_table_name, col.name].join('.')\n end", "def aggregated_fact_column_sql\n aggregate_fields.collect { |c| \n \"#{c.strategy_name}(#{c.from_table_name}.#{c.name}) AS #{c.label_for_table}\"\n }.join(\",\")\n end", "def namespaced_column(column, klass=nil)\n if klass.respond_to?(:table_name)\n ::ActiveRecord::Base.connection.quote_table_name(klass.table_name) + '.' + column.to_s\n else\n column.to_s\n end\n end", "def distinct_column_name\n @distinct_column || distinct_column\n end", "def count_by column_name, field\n inc = increment_mask_for column_name, field\n only = only_mask_for column_name, field\n # Create super-special-bitfield-grouping-query w/ AREL\n sql = arel_table.\n project(\"count(#{primary_key}) as #{field}_count, (#{column_name} & #{only})/#{inc} as #{field}\").\n group(field).to_sql\n connection.send :select, sql, 'AREL' # Execute the query\n end", "def column\n klass.columns_hash[field.to_s]\n end", "def column_label_for(type, request, model, column)\n unless label = model.column_options_for(type, request, column)[:label]\n label = humanize(column)\n end\n label\n end", "def get_field_column_name(args)\r\n #expected args => :unlimited, :field\r\n prefix = args[:unlimited] ? \"u_\" : \"l_\"\r\n field_id = \"_#{args[:field_id]}\"\r\n field_name = args[:field]\r\n column_name = \"#{prefix}#{field_name}\"\r\n checksum = \"_#{Digest::CRC16.hexdigest(field_name)}\"\r\n field_truncate_pos = @max_db_identifier_size - (prefix.size + checksum.size)\r\n if column_name.size > @max_db_identifier_size then\r\n \"#{prefix}#{field_name[0,field_truncate_pos]}#{checksum}\"\r\n else\r\n column_name\r\n end\r\n end", "def get_field(field, collection)\n if field.is_a?(Hash) # rubocop:disable Style/ConditionalAssignment\n field = \"#{field[:table]}.#{field[:field]}\"\n else\n field = \"#{collection.table_name}.#{field}\"\n end\n field_base.gsub(Placeholder::FIELD, field)\n end", "def counter_column_name\n (self.class.name.underscore.pluralize + '_count').to_sym\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as count but perform the query asynchronously and returns an ActiveRecord::Promise
def async_count(column_name = nil) async.count(column_name) end
[ "def async_count_by_sql(sql)\n connection.select_value(sanitize_sql(sql), \"#{name} Count\", async: true).then(&:to_i)\n end", "def count\n\n #if lib.respond_to?(:qry_count)\n run.free unless @has_run\n lib.qry_count(@query)\n #else\n # @last_resultset ? @last_resultset.size : 0\n #end\n end", "def count(*args, &block)\n if args || block\n @model.reactive_count(*args, &block)\n else\n cursor = add_query_part(:count)\n\n cursor.persistor.value\n end\n end", "def count\n\n #@query.count\n # not yet implemented by Hirabayashi-san\n run.free unless @has_run\n @last_resultset ? @last_resultset.size : 0\n end", "def count(sql)\n query(sql).first[:count]\n end", "def fetch_count\n @options[:count_only] = true\n result_processor.to_result\n end", "def count(query)\n count_results(make_query(query)) \n end", "def comments_per_recipe\n db_connection do |conn|\n conn.exec(\"SELECT recipe_id, COUNT(*) FROM comments GROUP BY recipe_id\").to_a\n end\nend", "def execute_count_sql(sql)\r\n #MES- Perform the SQL and return the CT column from the first row\r\n User.perform_select_all_sql(sql)[0]['CT'].to_i\r\n end", "def count(query)\n count_results(make_query(query))\n end", "def retrieved_records\n results.count\n end", "def db_query_transform__count query\n tmp_table = \"resultset_table\"\n make_tmp_table = db_query_transform__subquery query, tmp_table\n \"SELECT COUNT(*) FROM #{make_tmp_table}\"\n end", "def total_count\n query_results.total_count\n end", "def count_by_sql(sql)\n sql = sanitize_conditions(sql)\n connection.select_value(sql, \"#{name} Count\").to_i\n end", "def count_by_sql(sql)\n sql = sanitize_conditions(sql)\n connection.select_value(sql, \"#{name} Count\").to_i\n end", "def count(sql = \"\", *bindvars)\n select(:count, sql, *bindvars)\n end", "def websiteCount()\n db = openDatabase\n count = 0\n statement = db.prepare(\"select COUNT(*) from Websites\")\n statement.execute.each do |row|\n count = row[0]\n end\n return count\nend", "def count(selector={})\n @db.count(@name, selector || {})\n end", "def row_count\n rows = query(\"#{self.class} Count rows in #{@heading.name}\") { |q, table|\n q.project Arel::Nodes::SqlLiteral.new('COUNT(*) count')\n }\n rows.first[:count]\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculates the average value on a given column. Returns +nil+ if there's no row. See calculate for examples with options. Person.average(:age) => 35.8
def average(column_name) calculate(:average, column_name) end
[ "def average(column)\n run.avg(column)\n end", "def average(column)\n if s = sum(column)\n s / _all_with_present_column(column).count.to_f\n end\n end", "def avg(column)\n get(:avg[column])\n end", "def avg_col(k)\n map{|e|e[k]}.find_all{|e|e}.avg\n end", "def columnMean(col, meanNumber = 1.0)\n if 0 > col || columnCount <= col\n raise \"column out of bounds\";\n end\n\n if empty?\n return 0.0;\n end\n\n return rangeMean(0, col, rowCount - 1, col, meanNumber);\n end", "def avg(field)\n total = sum(field)\n total ? (total / count) : nil\n end", "def avg\n average\n end", "def average_student_gpa\n \"SELECT AVG(gpa) from students;\"\nend", "def avg(field)\n aggregates(field)[\"avg\"]\n end", "def async_average(column_name)\n async.average(column_name)\n end", "def average_student_gpa\n \"SELECT AVG(gpa) as average_student_gpa FROM students \"\nend", "def cached_average_column\n \"rating_average\"\n end", "def average\n return nil if @numSamples < 1\n @sumSamples.to_f / @numSamples\n end", "def avg(*args)\n query = args.last.kind_of?(Hash) ? args.pop : {}\n property_name = args.first\n\n assert_property_type property_name, ::Integer, ::Float, ::BigDecimal\n\n aggregate(query.merge(:fields => [ property_name.avg ]))\n end", "def average_gpa_for_9th_grade\n 'SELECT AVG(gpa) FROM students WHERE grade = 9;'\nend", "def meanColumns(rows)\n sums = Array.new(rows[0].size(), 0)\n\n rows.each{|row|\n row.each_index{|i|\n sums[i] += row[i]\n }\n }\n\n return sums.map{|sum| sum / rows.size().to_f()}\nend", "def avg(*args)\n with_repository_and_property(*args) do |repository,property,query|\n check_property_is_number(property)\n repository.avg(property, query.merge(:limit => 1))\n end\n end", "def set_cached_average_column(value = nil, &block)\n define_attr_method :cached_average_column, value, &block\n end", "def rowMean(row, meanNumber = 1.0)\n if 0 > row || rowCount <= row\n raise \"row out of bounds\";\n end\n\n if empty?\n return 0.0;\n end\n\n rangeMean(row, 0, row, columnCount - 1, meanNumber);\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as average but perform the query asynchronously and returns an ActiveRecord::Promise
def async_average(column_name) async.average(column_name) end
[ "def average_student_gpa\n \"SELECT AVG(gpa) from students;\"\nend", "def loadavg\n do_request 'loadavg'\n end", "def instructor_avg_wait_time(ord1, ord2 = nil)\n city_id = 2\n date1 = Day.find_by(cycle: Cycle.current(2), ord: ord1).date\n date2 = ord2 ? Day.find_by(cycle: Cycle.current(2), ord: ord2).date : Date.current\n Instructor.current_instructional.where(city_id: city_id).joins(:answered_questions).where('questions.taken_at >= ?', date1).where('questions.taken_at <= ?', date2).group(:id).pluck(:firstname, :lastname, 'CAST(SUM(questions.wait_time) AS FLOAT)/ COUNT(questions.id)')\nend", "def average_student_gpa\n \"SELECT AVG(gpa) as average_student_gpa FROM students \"\nend", "def compute_mean_response\n (0...trips).map do |trip|\n async_benchmark_request(trip)\n end.map(&:value)\n\n # calcualte the sum of response times\n # total time taken / # of trips\n (@response_times.inject(:+) / trips)\n end", "def async_sum(identity_or_column = nil)\n async.sum(identity_or_column)\n end", "def calculate(operation, column_name)\n operation = operation.to_s.downcase\n\n if @none\n case operation\n when \"count\", \"sum\"\n result = group_values.any? ? Hash.new : 0\n return @async ? Promise::Complete.new(result) : result\n when \"average\", \"minimum\", \"maximum\"\n result = group_values.any? ? Hash.new : nil\n return @async ? Promise::Complete.new(result) : result\n end\n end\n\n if has_include?(column_name)\n relation = apply_join_dependency\n\n if operation == \"count\"\n unless distinct_value || distinct_select?(column_name || select_for_count)\n relation.distinct!\n relation.select_values = [ klass.primary_key || table[Arel.star] ]\n end\n # PostgreSQL: ORDER BY expressions must appear in SELECT list when using DISTINCT\n relation.order_values = [] if group_values.empty?\n end\n\n relation.calculate(operation, column_name)\n else\n perform_calculation(operation, column_name)\n end\n end", "def final_avg\n @wait_time.to_i / @avg_count.to_i # return average\n end", "def async_count_by_sql(sql)\n connection.select_value(sanitize_sql(sql), \"#{name} Count\", async: true).then(&:to_i)\n end", "def average_gpa_for_9th_grade\n 'SELECT AVG(gpa) FROM students WHERE grade = 9;'\nend", "def do_query (&block)\n\n q = prepare_query(&block)\n rs = q.run\n\n return rs\n\n ensure\n q && q.free\n end", "def execute_async_query\n if @query\n th = Thread.new(@query) do |query|\n http = Net::HTTP.new(@uri.host)\n http.open_timeout = 10\n request = Net::HTTP::Get.new(@uri.request_uri + \"?query=#{query}\")\n request['Accept'] = \"application/sparql-results+xml\"\n response = http.request(request)\n if response.is_a? Net::HTTPSuccess; @result = parse_request(response.body)\n else raise Exception, \"HTTP Error\"; end\n yield results\n self\n end\n end\n end", "def collect_results futures\n # init a hash which automatically expands to something like {a:[], b:[]}\n values = Hash.new { |h, k| h[k] = [] }\n # get the results and put them into the Hash\n futures.map { |f|\n model, result, params = f.value # this is the actual blocking call\n next if model.nil?\n values[params.key] << result\n }\n # calculate means for each parameter pair\n values = values.map{|k,v| {k => v.instance_eval { reduce(:+) / size.to_f }}}\n # flatten array of hashed into one hash\n Hash[*values.map(&:to_a).flatten]\n end", "def avg(*args)\n with_repository_and_property(*args) do |repository,property,query|\n check_property_is_number(property)\n repository.avg(property, query.merge(:limit => 1))\n end\n end", "def average(column)\n run.avg(column)\n end", "def execute\n # Generate the Lua code for this query.\n code = codegen()\n \n # Send it to the server.\n results = client.aggregate(code)\n \n # Return the results.\n return results\n end", "def perform\n if calculation_needed?\n average = previous_average_record ? calculate! : dataset.avg(:value)\n table.add(average, table_index: table_index + 1, created: last[:created], type: :gauge)\n end\n end", "def average_db_time\n return time_average(@db_times)\n end", "def mean_time\n return 0 if self.task_responses.size == 0\n (self.task_responses.map{|r| r.work_duration}.inject(:+) / self.task_responses.size.to_f)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculates the minimum value on a given column. The value is returned with the same data type of the column, or +nil+ if there's no row. See calculate for examples with options. Person.minimum(:age) => 7
def minimum(column_name) calculate(:minimum, column_name) end
[ "def minimum(column_name, options = {})\n calculate(:minimum, column_name, options)\n end", "def min(column)\n get(:min[column])\n end", "def min(column_name)\n calculate(:min, column_name)\n end", "def min(column)\n _all_with_present_column(column).min\n end", "def min(attr)\n column(attr).min\n end", "def min(column)\n run.min(column)\n end", "def min(column = nil)\n return super() unless column && first && first.class.respond_to?(:descends_from_active_record?) \n map(&column.to_sym).min\n end", "def minimum_value(table, expr)\n min_or_max_value(table, expr, false)\n end", "def minimum(attribute_name, options = {})\n calculate(:min, attribute_name, options)\n end", "def min\n read_attribute(:min) or ( input and input.min )\n end", "def min (row_num)\n row = @rows[row_num]\n min = row[0]\n row.each do |num|\n if min == 0 then\n min = num\n end\n if (num < min) && (num != 0) then\n min = num\n end\n end\n return min\n end", "def min(field = nil)\n block_given? ? super() : aggregates(field)[\"min\"]\n end", "def min_value_for(gql_or_scenario)\n if gql_or_scenario.is_a?(Scenario)\n cache_for(gql_or_scenario).read(gql_or_scenario, self)[:min]\n elsif @min_value_gql.present?\n coerce_nan(\n wrap_gql_errors(:min) { gql_or_scenario.query(@min_value_gql) }\n )\n else\n @min_value || 0.0\n end\n end", "def async_minimum(column_name)\n async.minimum(column_name)\n end", "def min(field, opts={})\n opts = ::Hashie::Mash.new(opts)\n all(opts).inject(nil) do |min, item|\n val = item.send(field)\n min = val if !val.nil? && (min.nil? || val < min)\n min\n end\n end", "def min\n raise AnyError, \"No min value for type #{self}\"\n end", "def lowest_student_gpa\n \"SELECT MIN(gpa) as lowest_student_gpa FROM students\"\nend", "def min(field = nil)\n return super() if block_given?\n\n aggregate_by(field, :min)\n end", "def min\n return super if super.nil?\n (numeric_type == 'Integer') ? super.to_i : super.to_f\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as minimum but perform the query asynchronously and returns an ActiveRecord::Promise
def async_minimum(column_name) async.minimum(column_name) end
[ "def oldest_ready_object\n ActiveRecord::Base.connection.execute(\"select * from media_objects where created = (select min(created) from media_objects where status = 'received') limit 1;\").first\n end", "def async_find_by_sql(sql, binds = [], preparable: nil, &block)\n _query_by_sql(sql, binds, preparable: preparable, async: true).then do |result|\n _load_from_sql(result, &block)\n end\n end", "def lowest_student_gpa\n \"SELECT MIN(gpa) FROM students;\"\nend", "def lowest_student_gpa\n \"SELECT MIN(gpa) FROM students\"\nend", "def min(*args)\n with_repository_and_property(*args) do |repository,property,query|\n check_property_is_number(property)\n repository.min(property, query.merge(:limit => 1))\n end\n end", "def lowest_student_gpa\n \"SELECT MIN(gpa) as lowest_student_gpa FROM students\"\nend", "def min_rows_returned; end", "def fetch_first(&block)\n persistor = self.persistor\n\n if persistor && persistor.is_a?(Persistors::ArrayStore)\n # On array store, we wait for the result to be loaded in.\n promise = limit(1).fetch do |res|\n result = res.first\n\n result\n end\n else\n # On all other persistors, it should be loaded already\n promise = Promise.new.resolve(first)\n end\n\n # Run any passed in blocks after fetch\n promise = promise.then(&block) if block\n\n promise\n end", "def min(field = nil)\n return super() if block_given?\n\n aggregate_by(field, :min)\n end", "def minimum(event_collection, params, options={})\n query(__method__, event_collection, params, options)\n end", "def lowest_student_gpa\n 'SELECT gpa FROM students ORDER BY gpa ASC LIMIT 1'\nend", "def min_value_for(gql_or_scenario)\n if gql_or_scenario.is_a?(Scenario)\n cache_for(gql_or_scenario).read(gql_or_scenario, self)[:min]\n elsif @min_value_gql.present?\n coerce_nan(\n wrap_gql_errors(:min) { gql_or_scenario.query(@min_value_gql) }\n )\n else\n @min_value || 0.0\n end\n end", "def min_measurement(options = {})\n options.reverse_merge! start_point: Time.at(0), end_point: Time.now\n\n # Convert time range to UTC timezone in UNIX time\n start_point = options[:start_point].utc.to_i\n end_point = options[:end_point].utc.to_i\n\n result = TITS.influx.query(\"select min(value) from r#{id} where \\\n time > #{start_point}s and \\\n time < #{end_point}s;\")\n\n return unless result && !result.empty?\n\n result = result[\"r#{id}\"].first\n value = result['min']\n time = Time.at(result['time'] / 1000)\n Measurement.new(id, value, time)\n end", "def min() end", "def find_min\r\n return nil if !@head\r\n cursor = @head\r\n min = cursor.data\r\n while cursor\r\n if cursor.data < min\r\n min = cursor.data\r\n end\r\n cursor = cursor.next\r\n end\r\n return min\r\n end", "def min(column = nil)\n return super() unless column && first && first.class.respond_to?(:descends_from_active_record?) \n map(&column.to_sym).min\n end", "def min(field = nil)\n block_given? ? super() : aggregates(field)[\"min\"]\n end", "def min(column)\n run.min(column)\n end", "def earliest_payment\n payments.min_by(&:date)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculates the maximum value on a given column. The value is returned with the same data type of the column, or +nil+ if there's no row. See calculate for examples with options. Person.maximum(:age) => 93
def maximum(column_name) calculate(:maximum, column_name) end
[ "def max(column)\n get(:max[column])\n end", "def max(attr)\n column(attr).max\n end", "def max(column)\n _all_with_present_column(column).max\n end", "def max(column)\n run.max(column)\n end", "def column_max( table, column )\n\tmax = -9999999\n\t(0...(column + 2)).each do |x|\n\t\tif table[x][column] != nil\n\t\t\tif table[x][column] > max\n\t\t\t\tmax = table[x][column]\n\t\t\tend\n\t\tend\n\tend\n\n\treturn max\nend", "def max(column=@pkey)\n\t\t@db.query(\"SELECT MAX(#{column}) FROM #{@table_name}\").first.values[-1]\n\tend", "def read_max(type, record, valueType, condition = nil)\n connector = @connectors[type]\n maxval = nil\n unless (retval = connector.read({type: \"rmax\", record: record},\n condition)).nil?\n retval.each { |r| r.values.each { |v| \n maxval = (valueType == :integer ? v.to_i :\n valueType == :float ? v.to_f :\n v)\n }}\n end\n if maxval.nil?\n error(\"fail to get max value of #{record} from the #{type} database.\")\n return nil\n end\n return maxval\n end", "def max(column = nil)\n return super() unless column && first && first.class.respond_to?(:descends_from_active_record?) \n map(&column.to_sym).max\n end", "def maximum_value(table, expr)\n min_or_max_value(table, expr, true)\n end", "def biggest_column\n @cols.max_by { |col| col.rows.length }\n end", "def max\n cells.compact.max\n end", "def max_value\n max = 0\n\n @matrix.each do |row|\n row_max = row.max\n max = row_max if row_max > max\n end\n\n max\n end", "def highest_value\n if data.kind_of?( Array ) && ! data.empty?\n max = data.flatten.compact.max\n else\n max = 0\n end\n return max\n end", "def max\n if valid\n max_value\n else\n # fetch max from stack if stored obj is invalid right now\n # due to unfinished data operations (see challenge_big_data.rb)\n set_max(get_max)\n end\n end", "def max(field = nil)\n block_given? ? super() : aggregates(field)[\"max\"]\n end", "def largest_value\n values.max\n end", "def max(field, opts={})\n opts = ::Hashie::Mash.new(opts)\n all(opts).inject(nil) do |max, item|\n val = item.send(field)\n max = val if !val.nil? && (max.nil? || val > max)\n max\n end\n end", "def max\n return super if super.nil?\n (numeric_type == 'Integer') ? super.to_i : super.to_f\n end", "def max\n @max ||= [data.compact.max, data.compact.min.abs].max.to_f\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as maximum but perform the query asynchronously and returns an ActiveRecord::Promise
def async_maximum(column_name) async.maximum(column_name) end
[ "def latest_result\n return get_entities(Result, data.id, :limit => 1).first\n end", "def query_max_task_id\n check_max_id(@db_base.query_max_task_id.next)\n end", "def async_minimum(column_name)\n async.minimum(column_name)\n end", "def latest_job\n @mysql.query(\"select * from #{table_name}\").each do |job|\n return job\n end\n end", "def query_max_person_id\n stmt = @db.prepare(\"SELECT Id FROM Persons ORDER BY Id DESC LIMIT 1\")\n stmt.execute\n end", "def max(field = nil)\n return super() if block_given?\n\n aggregate_by(field, :max)\n end", "def highest_student_gpa\n 'SELECT gpa FROM students ORDER BY gpa DESC LIMIT 1'\nend", "def await_results(promises)\n ResultSet.new(promises.map(&:value))\n end", "def async_find_by_sql(sql, binds = [], preparable: nil, &block)\n _query_by_sql(sql, binds, preparable: preparable, async: true).then do |result|\n _load_from_sql(result, &block)\n end\n end", "def biggest(collection, &block)\n block ? collection.select(&block).max : collection.max\nend", "def highest_student_gpa\n \"SELECT MAX(gpa) as highest_gpa FROM students;\"\nend", "def max(*args)\n with_repository_and_property(*args) do |repository,property,query|\n check_property_is_number(property)\n repository.max(property, query.merge(:limit => 1))\n end\n end", "def async_count_by_sql(sql)\n connection.select_value(sanitize_sql(sql), \"#{name} Count\", async: true).then(&:to_i)\n end", "def min_or_max_value(table, expr, max = false)\n res = ActiveRecord::Base.connection.execute(\n \"SELECT #{max ? 'MAX' : 'MIN'}(#{expr}) FROM #{table}\"\n )\n case adapter = ActiveRecord::Base.connection.adapter_name\n when \"PostgreSQL\"\n res.first.first[1].to_f\n when \"Mysql2\"\n res.first[0]\n else\n raise StandardError, \"Database adapter '#{adapter}' not supported\"\n end\n end", "def job_div_pop_max\n\t\tJobsCity.connection.select_all(\"SELECT MAX(CAST(#{self.numberjobs}*1000 AS float)/CAST(#{self.population} AS float)) FROM jobs_cities\")\n\tend", "def find_post_highest_likes\n highest= self.posts.max do |like|\n like.likes\n end\n highest.title\nend", "def max_build\n builds.first(:order => 'id DESC', :select => 'id')\n end", "def get_highest_bid\n self.bids.order('price DESC').first\n end", "def newest(constraints = {})\n constraints.merge!(order: :created_at.desc)\n _q = query(constraints)\n _q.define_singleton_method(:method_missing) { |m, *args, &block| self.results.send(m, *args, &block) }\n _q\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as sum but perform the query asynchronously and returns an ActiveRecord::Promise
def async_sum(identity_or_column = nil) async.sum(identity_or_column) end
[ "def record_sum(session, database)\n session.send(database).select_one( \\\n \"select sum(number1) + sum(number2) + sum(number3) + sum(number4) as sum\n from big_rep\")['sum'].to_f\n end", "def async_count_by_sql(sql)\n connection.select_value(sanitize_sql(sql), \"#{name} Count\", async: true).then(&:to_i)\n end", "def record_sum(session, record_type, database)\n session.send(database).select_one( \\\n \"select sum(number1) + sum(number2) + sum(number3) + sum(number4) as sum\n from big_scan where diff_type = '#{record_type}'\")['sum'].to_f\n end", "def calculate(operation, column_name)\n operation = operation.to_s.downcase\n\n if @none\n case operation\n when \"count\", \"sum\"\n result = group_values.any? ? Hash.new : 0\n return @async ? Promise::Complete.new(result) : result\n when \"average\", \"minimum\", \"maximum\"\n result = group_values.any? ? Hash.new : nil\n return @async ? Promise::Complete.new(result) : result\n end\n end\n\n if has_include?(column_name)\n relation = apply_join_dependency\n\n if operation == \"count\"\n unless distinct_value || distinct_select?(column_name || select_for_count)\n relation.distinct!\n relation.select_values = [ klass.primary_key || table[Arel.star] ]\n end\n # PostgreSQL: ORDER BY expressions must appear in SELECT list when using DISTINCT\n relation.order_values = [] if group_values.empty?\n end\n\n relation.calculate(operation, column_name)\n else\n perform_calculation(operation, column_name)\n end\n end", "def execute\n # Generate the Lua code for this query.\n code = codegen()\n \n # Send it to the server.\n results = client.aggregate(code)\n \n # Return the results.\n return results\n end", "def sum(field)\n sum = execute.inject(nil) do |memo, doc|\n value = doc.send(field) || 0\n memo ? memo += value : value\n end\n end", "def records_sum(records)\n sum = 0.0;\n records.each{|r| sum+= r[:amount].to_f}\n return sum\nend", "def await_results(promises)\n ResultSet.new(promises.map(&:value))\n end", "def async_count(column_name = nil)\n async.count(column_name)\n end", "def async_average(column_name)\n async.average(column_name)\n end", "def do_query (&block)\n\n q = prepare_query(&block)\n rs = q.run\n\n return rs\n\n ensure\n q && q.free\n end", "def sum(column)\n result = all\n\n if result.any?\n result.inject(0.0) do |acc, record|\n if value = record.public_send(column)\n acc += value\n end\n\n acc\n end\n end\n end", "def calculate_amount\n# self.update_column(:cp_pg_amount , cp_pg_products.sum(:total_amount))\n total_amount = 0\n cp_pg_products.each do |pp|\n total_amount += pp.total_amount\n end\n self.update_column(:cp_pg_amount , total_amount)\n end", "def result\n VoucherRow.joins(:voucher).where(:account_number => number, 'vouchers.activity_year_id' => activity_year_id, :canceled => false).sum(:sum).to_f\n end", "def sum\n self.reduce('lambda{|sum, item| sum + item}')\n end", "def sum(field = nil)\n return super() if block_given?\n\n aggregate_by(field, :sum) || 0\n end", "def calculate_sum\n completion = 0\n @sorted_joblist.each do |job|\n completion += job[1]\n @sum += job[0] * completion\n end\n end", "def total_tardies_for_all_students\n \"SELECT SUM(tardies) from students\"\nend", "def execute_sql(my_sql)\n pg_result = ActiveRecord::Base.connection.execute(my_sql)\n\n # In this example we are just calling #to_a to convert the PG::Result to an\n # Array. PG::Result has a nice API for slicing and dicing itself so you may\n # want to to something clever instead. See\n # https://www.rubydoc.info/gems/pg/PG/Result for details.\n #\n # The important bit here is that we are copying all the data we care about\n # out of the PG::Result in preparation for later clearing the PG::Result\n results = pg_result.to_a\n\n # Calling #clear on the PG::Result is the important bit of cleanup and the\n # whole reason this method exists. See\n # https://www.rubydoc.info/gems/pg/PG/Result#clear-instance_method\n pg_result.clear\n\n yield results if block_given?\n\n results\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This calculates aggregate values in the given column. Methods for count, sum, average, minimum, and maximum have been added as shortcuts. Person.calculate(:count, :all) The same as Person.count Person.average(:age) SELECT AVG(age) FROM people... Selects the minimum age for any family without any minors Person.group(:last_name).having("min(age) > 17").minimum(:age) Person.sum("2 age") There are two basic forms of output: Single aggregate value: The single value is type cast to Integer for COUNT, Float for AVG, and the given column's type for everything else. Grouped values: This returns an ordered hash of the values and groups them. It takes either a column name, or the name of a belongs_to association. values = Person.group('last_name').maximum(:age) puts values["Drake"] => 43 drake = Family.find_by(last_name: 'Drake') values = Person.group(:family).maximum(:age) Person belongs_to :family puts values[drake] => 43 values.each do |family, max_age| ... end
def calculate(operation, column_name) operation = operation.to_s.downcase if @none case operation when "count", "sum" result = group_values.any? ? Hash.new : 0 return @async ? Promise::Complete.new(result) : result when "average", "minimum", "maximum" result = group_values.any? ? Hash.new : nil return @async ? Promise::Complete.new(result) : result end end if has_include?(column_name) relation = apply_join_dependency if operation == "count" unless distinct_value || distinct_select?(column_name || select_for_count) relation.distinct! relation.select_values = [ klass.primary_key || table[Arel.star] ] end # PostgreSQL: ORDER BY expressions must appear in SELECT list when using DISTINCT relation.order_values = [] if group_values.empty? end relation.calculate(operation, column_name) else perform_calculation(operation, column_name) end end
[ "def calculate(scope, method, column)\n case method\n when :count\n calculation = \"COUNT(#{column || \"*\"})\"\n when :maximum\n calculation = \"MAX(#{column})\"\n when :minimum\n calculation = \"MIN(#{column})\"\n when :sum\n calculation = \"SUM(#{column})\"\n when :average\n calculation = \"AVG(#{column})\"\n else\n raise \"Unrecognized calculation: #{method.inspect}\"\n end\n\n calculate_statement = \"SELECT #{calculation} AS #{method} FROM #{scope.klass.table_name} #{scope.predicate}\"\n\n if (row = @db.execute(calculate_statement, scope.predicate_values).first)\n row[method]\n else\n nil\n end\n end", "def sum(column)\n result = all\n\n if result.any?\n result.inject(0.0) do |acc, record|\n if value = record.public_send(column)\n acc += value\n end\n\n acc\n end\n end\n end", "def total_for(column)\n sum_totals_for(column)\n Datum.new(@totals[column.to_s], column, nil, self)\n end", "def calculate(operation, column_name, options = {})\n validate_calculation_options(operation, options)\n column_name = options[:select] if options[:select]\n column_name = '*' if column_name == :all\n column = column_for column_name\n catch :invalid_query do\n if options[:group]\n return execute_grouped_calculation(operation, column_name, column, options)\n else\n return execute_simple_calculation(operation, column_name, column, options)\n end\n end\n 0\n end", "def sum_column(column_name)\n @result.inject(0.0) { |sum, item_hash|\n if item_hash.has_key?(column_name)\n sum + item_hash[column_name].to_f\n else\n sum\n end\n }\n end", "def calculate_score\n @results.collect { |mir| mir.send(@column.to_sym) }.sum\n end", "def average(column_name)\n calculate(:average, column_name)\n end", "def average(column)\n if s = sum(column)\n s / _all_with_present_column(column).count.to_f\n end\n end", "def sum(column)\n get(:sum[column])\n end", "def aggregate_cell_values(row_or_column, meth, aggregate)\n ColumnWidthCalculator.new(self).aggregate_cell_values(row_or_column, meth, aggregate)\n end", "def aggregate(term = \"COUNT(*)\", options = {})\n # Leave this .dup here, causes problems because options are changed\n options = options.dup\n\n klass = options[:class]\n\n # Rename search term, SQL92 but _not_ SQL89 compatible\n options = {\n :select => \"#{term} AS #{term[/^\\w+/]}\"\n }.update(options)\n\n unless options[:group] || options[:group_by]\n options.delete(:order)\n options.delete(:order_by)\n end\n sql = resolve_options(klass, options)\n\n if field = options[:field]\n return_type = klass.ann(field, :class) || Integer\n else\n return_type = Integer\n end\n\n if options[:group] || options[:group_by]\n # This is an aggregation, so return the calculated values\n # as an array.\n values = []\n res = query(sql)\n res.each_row do |row, idx|\n values << type_cast(return_type, row[0])\n end\n return values\n else\n return type_cast(return_type, query(sql).first_value)\n end\n end", "def calc_val(agg, h, k = nil)\n column = column(h, k)\n\n # Convert Date and Time objects to DateTime\n if [Date, Time].include?(agg.class)\n agg = agg.to_datetime\n end\n\n case agg\n when Symbol\n column.send(agg)\n when String\n begin\n converted_val = Convert.convert_to_type(agg, column.type)\n rescue UserError, IncompatibleTypeError\n converted_val = false\n end\n if converted_val\n converted_val\n else\n agg\n end\n when column.type.constantize\n agg\n when Proc\n result =\n if group\n case agg.arity\n when 0\n agg.call\n when 1\n agg.call(k)\n when 2\n agg.call(k, column)\n when 3\n agg.call(k, column, self)\n else\n msg = 'a lambda used in a group footer may have 0 to 3 three arguments: (k, c, f)'\n raise ArgumentError, msg\n end\n else\n case agg.arity\n when 0\n agg.call\n when 1\n agg.call(column)\n when 2\n agg.call(column, self)\n else\n msg = 'a lambda used in a non-group footer may have 0 to 2 arguments: (c, f)'\n raise ArgumentError, msg\n end\n end\n # Pass the result back into this method as the new agg\n calc_val(result, h, k)\n else\n agg.to_s\n end\n end", "def sum(column_name, options = {})\n calculate(:sum, column_name, options)\n end", "def sum(column_name)\n \traise ActiveRecord::StatementInvalid, \"Missing column name entered!\" if column_name.is_a? Integer\n \tbegin\n \t\tself.catalog_analytics.sum(column_name)\n \trescue ActiveRecord::StatementInvalid\n \t\traise ActiveRecord::StatementInvalid, \"Missing column name entered!\"\n \tend\t\n end", "def execute_simple_calculation(operation, column_name, distinct) #:nodoc:\n # LIMIT 0 clauses on aggregate queries will return a 0 result\n # no need to query salesforce for that\n return 0 if has_limit_or_offset? && limit_value == 0\n\n if operation == \"count\" && (column_name == :all && distinct || has_limit_or_offset?)\n # Shortcut when limit is zero.\n \n query_builder = build_count_subquery(spawn, column_name, distinct)\n else\n # PostgreSQL doesn't like ORDER BY when there are no GROUP BY\n relation = unscope(:order).distinct!(false)\n\n column = aggregate_column(column_name)\n select_value = operation_over_aggregate_column(column, operation, distinct)\n\n relation.select_values = [select_value]\n\n query_builder = relation.arel\n end\n\n result = skip_query_cache_if_necessary { @klass.connection.select_all(query_builder, nil) }\n row = result.first\n\n value = row && row.fetch(\"expr0\")\n\n type = type_for(column_name)\n \n type_cast_calculated_value(value, type, operation)\n end", "def sum(column)\n run.sum(column)\n end", "def data_column\n \"#{aggregation_function}(#{aggregation_column})\"\n end", "def avg(*args)\n query = args.last.kind_of?(Hash) ? args.pop : {}\n property_name = args.first\n\n assert_property_type property_name, ::Integer, ::Float, ::BigDecimal\n\n aggregate(query.merge(:fields => [ property_name.avg ]))\n end", "def aggregate\n klass.collection.group(\n :key => field_list,\n :cond => selector,\n :initial => { :count => 0 },\n :reduce => Javascript.aggregate\n )\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Use pluck as a shortcut to select one or more attributes without loading an entire record object per row. Person.pluck(:name) instead of Person.all.map(&:name) Pluck returns an Array of attribute values typecasted to match the plucked column names, if they can be deduced. Plucking an SQL fragment returns String values by default. Person.pluck(:name) SELECT people.name FROM people => ['David', 'Jeremy', 'Jose'] Person.pluck(:id, :name) SELECT people.id, people.name FROM people => [[1, 'David'], [2, 'Jeremy'], [3, 'Jose']] Person.distinct.pluck(:role) SELECT DISTINCT role FROM people => ['admin', 'member', 'guest'] Person.where(age: 21).limit(5).pluck(:id) SELECT people.id FROM people WHERE people.age = 21 LIMIT 5 => [2, 3] Person.pluck(Arel.sql('DATEDIFF(updated_at, created_at)')) SELECT DATEDIFF(updated_at, created_at) FROM people => ['0', '27761', '173'] See also ids.
def pluck(*column_names) return [] if @none if loaded? && all_attributes?(column_names) result = records.pluck(*column_names) if @async return Promise::Complete.new(result) else return result end end if has_include?(column_names.first) relation = apply_join_dependency relation.pluck(*column_names) else klass.disallow_raw_sql!(column_names.flatten) columns = arel_columns(column_names) relation = spawn relation.select_values = columns result = skip_query_cache_if_necessary do if where_clause.contradiction? ActiveRecord::Result.empty(async: @async) else klass.connection.select_all(relation.arel, "#{klass.name} Pluck", async: @async) end end result.then do |result| type_cast_pluck_values(result, columns) end end end
[ "def pluck(*column_names)\n column_names.map! do |column_name|\n if column_name.is_a?(Symbol) && attribute_alias?(column_name)\n attribute_alias(column_name)\n else\n column_name.to_s\n end\n end\n\n if has_include?(column_names.first)\n construct_relation_for_association_calculations.pluck(*column_names)\n else\n relation = spawn\n relation.select_values = column_names.map { |cn|\n columns_hash.key?(cn) ? arel_table[cn] : cn\n }\n result = klass.connection.select_all(relation.arel, nil, bound_attributes)\n result.cast_values(klass.attribute_types)\n end\n end", "def pluck(column_name)\n column_name = column_name.to_s\n klass.connection.select_all(select(column_name).arel).map! do |attributes|\n klass.type_cast_attribute(attributes.keys.first, klass.initialize_attributes(attributes))\n end\n end", "def pluck(*fields)\n # Multiple fields can map to the same field name. For example, plucking\n # a field and its _translations field map to the same field in the database.\n # because of this, we need to keep track of the fields requested.\n normalized_field_names = []\n normalized_select = fields.inject({}) do |hash, f|\n db_fn = klass.database_field_name(f)\n normalized_field_names.push(db_fn)\n hash[klass.cleanse_localized_field_names(f)] = true\n hash\n end\n\n view.projection(normalized_select).reduce([]) do |plucked, doc|\n values = normalized_field_names.map do |n|\n extract_value(doc, n)\n end\n plucked << (values.size == 1 ? values.first : values)\n end\n end", "def pluck4 feathers\n if Rails.version =~ /^3/\n self.all.map{ |ar|\n feathers.map { |f|\n # THIS WILL ONLY WORK FOR ATTRIBUTES - NOT METHODS\n ar[f]\n }\n #.join(\", \") RETURN AS STRING? OPTIONAL\n }\n else\n self.pluck feathers\n end\n end", "def pluck(*args)\n []\n end", "def pluck(*_fields)\n []\n end", "def pluck(name)\n find { |choice| choice.name == name }\n end", "def async_pluck(*column_names)\n async.pluck(*column_names)\n end", "def pluck(ary, key)\n # your implementation here\n ary.map {|item| item[key]}\nend", "def pluck(ary, key)\n\n ary.map {|item| item[key]}\nend", "def pick(*column_names)\n if loaded? && all_attributes?(column_names)\n result = records.pick(*column_names)\n return @async ? Promise::Complete.new(result) : result\n end\n\n limit(1).pluck(*column_names).then(&:first)\n end", "def pluck(*fields)\n fields = fields.flatten(1).reject(&:blank?).map(&:to_s)\n\n source_fields = fields - EVERFIELDS\n scope = except(FIELD_STORAGES, EXTRA_STORAGES)\n .source(source_fields.presence || false)\n\n hits = raw_limit_value ? scope.hits : scope.scroll_hits(batch_size: DEFAULT_PLUCK_BATCH_SIZE)\n hits.map do |hit|\n if fields.one?\n fetch_field(hit, fields.first)\n else\n fields.map do |field|\n fetch_field(hit, field)\n end\n end\n end\n end", "def pick(*fields)\n limit(1).pluck(*fields).first\n end", "def pluck(field)\n\t\t\tif self.general_info.include? field\n\t\t\t\tself.result.map{ |p| p[field] }\n\t\t\telse\n\t\t\t\tself.result.map{ |p| p['participant_information'].select{ |a| a['desc'] == field } }.flatten.map{ |x| x['info'] }\n\t\t\tend\n\t\tend", "def pluck_from_doc(doc, *fields)\n if fields.length == 1\n retrieve_value_at_path(doc, fields.first)\n else\n fields.map do |field|\n retrieve_value_at_path(doc, field)\n end\n end\n end", "def async_pick(*column_names)\n async.pick(*column_names)\n end", "def pluck(field, index_key = nil)\n unless index_key\n newlist = {}\n # This is simple. Could at some point wrap array_column()\n # if we knew we had an array of arrays.\n @output.each_pair do |key, value|\n if value.is_a? Hash\n newlist[key] = value[field]\n else\n newlist[key] = value.send(field.to_sym)\n end\n end\n return @output = newlist\n end\n\n newlist = {}\n # When index_key is not set for a particular item, push the value\n # to the end of the stack. This is how array_column() behaves.\n @output.each_value do |value|\n if !value.is_a? Hash\n if value.send(index_key)\n newlist[value.send(index_key)] = value.send(field.to_sym)\n else\n newlist << value.send(field.to_sym)\n end\n else\n if value[index_key]\n newlist[value[index_key]] = value[field]\n else\n newlist << value[field]\n end\n end\n end\n @output = newlist\n end", "def select_random(field_name)\n random.pluck(field_name)\n end", "def _pick_attribute(names)\n [names].flatten.each do |name|\n return self.send(name) if self.respond_to?(name)\n end\n return nil\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as pluck but perform the query asynchronously and returns an ActiveRecord::Promise
def async_pluck(*column_names) async.pluck(*column_names) end
[ "def pluck(*column_names)\n return [] if @none\n\n if loaded? && all_attributes?(column_names)\n result = records.pluck(*column_names)\n if @async\n return Promise::Complete.new(result)\n else\n return result\n end\n end\n\n if has_include?(column_names.first)\n relation = apply_join_dependency\n relation.pluck(*column_names)\n else\n klass.disallow_raw_sql!(column_names.flatten)\n columns = arel_columns(column_names)\n relation = spawn\n relation.select_values = columns\n result = skip_query_cache_if_necessary do\n if where_clause.contradiction?\n ActiveRecord::Result.empty(async: @async)\n else\n klass.connection.select_all(relation.arel, \"#{klass.name} Pluck\", async: @async)\n end\n end\n result.then do |result|\n type_cast_pluck_values(result, columns)\n end\n end\n end", "def pick(*column_names)\n if loaded? && all_attributes?(column_names)\n result = records.pick(*column_names)\n return @async ? Promise::Complete.new(result) : result\n end\n\n limit(1).pluck(*column_names).then(&:first)\n end", "def async_pick(*column_names)\n async.pick(*column_names)\n end", "def pluck(*args)\n []\n end", "def pluck(*column_names)\n column_names.map! do |column_name|\n if column_name.is_a?(Symbol) && attribute_alias?(column_name)\n attribute_alias(column_name)\n else\n column_name.to_s\n end\n end\n\n if has_include?(column_names.first)\n construct_relation_for_association_calculations.pluck(*column_names)\n else\n relation = spawn\n relation.select_values = column_names.map { |cn|\n columns_hash.key?(cn) ? arel_table[cn] : cn\n }\n result = klass.connection.select_all(relation.arel, nil, bound_attributes)\n result.cast_values(klass.attribute_types)\n end\n end", "def pluck(column_name)\n column_name = column_name.to_s\n klass.connection.select_all(select(column_name).arel).map! do |attributes|\n klass.type_cast_attribute(attributes.keys.first, klass.initialize_attributes(attributes))\n end\n end", "def async_find_by_sql(sql, binds = [], preparable: nil, &block)\n _query_by_sql(sql, binds, preparable: preparable, async: true).then do |result|\n _load_from_sql(result, &block)\n end\n end", "def pluck(*fields)\n # Multiple fields can map to the same field name. For example, plucking\n # a field and its _translations field map to the same field in the database.\n # because of this, we need to keep track of the fields requested.\n normalized_field_names = []\n normalized_select = fields.inject({}) do |hash, f|\n db_fn = klass.database_field_name(f)\n normalized_field_names.push(db_fn)\n hash[klass.cleanse_localized_field_names(f)] = true\n hash\n end\n\n view.projection(normalized_select).reduce([]) do |plucked, doc|\n values = normalized_field_names.map do |n|\n extract_value(doc, n)\n end\n plucked << (values.size == 1 ? values.first : values)\n end\n end", "def pluck(*_fields)\n []\n end", "def pluck(ary, key)\n # your implementation here\n ary.map {|item| item[key]}\nend", "def select_values(sql)\n result = select(sql)\n result.map { |r| r.values.first }\n end", "def fetch_from_db(records)\n return [] if records.empty?\n\n identifier = primary_identifier_of(records.first)\n identifier_ids = records.collect { |r| r[identifier] }.uniq\n records_uid = records.collect { |r| r[:uid] }\n\n current_model.where(uid: records_uid).where(identifier => identifier_ids)\n end", "def fetch(sql, *params)\n rs = self.execute(sql, *params)\n return [] if self.interpreter.preview? and not rs\n return rs.fetch_all\n end", "def pluck(*fields)\n fields = fields.flatten(1).reject(&:blank?).map(&:to_s)\n\n source_fields = fields - EVERFIELDS\n scope = except(FIELD_STORAGES, EXTRA_STORAGES)\n .source(source_fields.presence || false)\n\n hits = raw_limit_value ? scope.hits : scope.scroll_hits(batch_size: DEFAULT_PLUCK_BATCH_SIZE)\n hits.map do |hit|\n if fields.one?\n fetch_field(hit, fields.first)\n else\n fields.map do |field|\n fetch_field(hit, field)\n end\n end\n end\n end", "def pluck(ary, key)\n\n ary.map {|item| item[key]}\nend", "def await_results(promises)\n ResultSet.new(promises.map(&:value))\n end", "def select_all\n query { |db| return db.to_hash }\n end", "def find_user_emails\n Purchase.where(status: 'COMPLETED').where('purchased_at >= ?', Time.zone.now - 7.days).find_in_batches do |batch|\n ids = batch.map(&:user_id)\n @user_emails = User.where(id: ids).pluck(:email)\n end\n return @user_emails\nend", "def to_a\n exec_query unless loaded?\n @loaded_array\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Pick the value(s) from the named column(s) in the current relation. This is shorthand for relation.limit(1).pluck(column_names).first, and is primarily useful when you have a relation that's already narrowed down to a single row. Just like pluck, pick will only load the actual value, not the entire record object, so it's also more efficient. The value is, again like with pluck, typecast by the column type. Person.where(id: 1).pick(:name) SELECT people.name FROM people WHERE id = 1 LIMIT 1 => 'David' Person.where(id: 1).pick(:name, :email_address) SELECT people.name, people.email_address FROM people WHERE id = 1 LIMIT 1
def pick(*column_names) if loaded? && all_attributes?(column_names) result = records.pick(*column_names) return @async ? Promise::Complete.new(result) : result end limit(1).pluck(*column_names).then(&:first) end
[ "def pick(*fields)\n limit(1).pluck(*fields).first\n end", "def pluck(*column_names)\n return [] if @none\n\n if loaded? && all_attributes?(column_names)\n result = records.pluck(*column_names)\n if @async\n return Promise::Complete.new(result)\n else\n return result\n end\n end\n\n if has_include?(column_names.first)\n relation = apply_join_dependency\n relation.pluck(*column_names)\n else\n klass.disallow_raw_sql!(column_names.flatten)\n columns = arel_columns(column_names)\n relation = spawn\n relation.select_values = columns\n result = skip_query_cache_if_necessary do\n if where_clause.contradiction?\n ActiveRecord::Result.empty(async: @async)\n else\n klass.connection.select_all(relation.arel, \"#{klass.name} Pluck\", async: @async)\n end\n end\n result.then do |result|\n type_cast_pluck_values(result, columns)\n end\n end\n end", "def pluck(*column_names)\n column_names.map! do |column_name|\n if column_name.is_a?(Symbol) && attribute_alias?(column_name)\n attribute_alias(column_name)\n else\n column_name.to_s\n end\n end\n\n if has_include?(column_names.first)\n construct_relation_for_association_calculations.pluck(*column_names)\n else\n relation = spawn\n relation.select_values = column_names.map { |cn|\n columns_hash.key?(cn) ? arel_table[cn] : cn\n }\n result = klass.connection.select_all(relation.arel, nil, bound_attributes)\n result.cast_values(klass.attribute_types)\n end\n end", "def pluck(column_name)\n column_name = column_name.to_s\n klass.connection.select_all(select(column_name).arel).map! do |attributes|\n klass.type_cast_attribute(attributes.keys.first, klass.initialize_attributes(attributes))\n end\n end", "def async_pick(*column_names)\n async.pick(*column_names)\n end", "def pluck(name)\n find { |choice| choice.name == name }\n end", "def pluck(*fields)\n # Multiple fields can map to the same field name. For example, plucking\n # a field and its _translations field map to the same field in the database.\n # because of this, we need to keep track of the fields requested.\n normalized_field_names = []\n normalized_select = fields.inject({}) do |hash, f|\n db_fn = klass.database_field_name(f)\n normalized_field_names.push(db_fn)\n hash[klass.cleanse_localized_field_names(f)] = true\n hash\n end\n\n view.projection(normalized_select).reduce([]) do |plucked, doc|\n values = normalized_field_names.map do |n|\n extract_value(doc, n)\n end\n plucked << (values.size == 1 ? values.first : values)\n end\n end", "def fetch_first_field(sql)\n fetch_first_row(sql)&.values&.first\n end", "def pick_one(pick, elems)\n case pick\n when :first\n return elems.first\n when :last\n return elems.last\n when :random\n return elems.to_a.shuffle.first\n else\n if pick.is_a? Numeric\n return elems[pick.to_i]\n else\n options[:message] = optional_message(\"Invalid :pick value #{pick}.\", options)\n options[:groups] = ['find', 'pick']\n world.error(options)\n end\n end\n end", "def select_values(sql, name = nil)\n result = select_rows(sql, name)\n result.map { |v| v[0] }\n end", "def select_values(sql)\n result = select(sql)\n result.map { |r| r.values.first }\n end", "def async_pluck(*column_names)\n async.pluck(*column_names)\n end", "def pluck(*fields)\n fields = fields.flatten(1).reject(&:blank?).map(&:to_s)\n\n source_fields = fields - EVERFIELDS\n scope = except(FIELD_STORAGES, EXTRA_STORAGES)\n .source(source_fields.presence || false)\n\n hits = raw_limit_value ? scope.hits : scope.scroll_hits(batch_size: DEFAULT_PLUCK_BATCH_SIZE)\n hits.map do |hit|\n if fields.one?\n fetch_field(hit, fields.first)\n else\n fields.map do |field|\n fetch_field(hit, field)\n end\n end\n end\n end", "def fetch_first_column(sql)\n fetch_rows(sql).map(&:values).map(&:first)\n end", "def first(sql = \"\", *bindvars)\n select(:first, sql, *bindvars)\n end", "def pluck4 feathers\n if Rails.version =~ /^3/\n self.all.map{ |ar|\n feathers.map { |f|\n # THIS WILL ONLY WORK FOR ATTRIBUTES - NOT METHODS\n ar[f]\n }\n #.join(\", \") RETURN AS STRING? OPTIONAL\n }\n else\n self.pluck feathers\n end\n end", "def _pick_attribute(names)\n [names].flatten.each do |name|\n return self.send(name) if self.respond_to?(name)\n end\n return nil\n end", "def pluck(field)\n\t\t\tif self.general_info.include? field\n\t\t\t\tself.result.map{ |p| p[field] }\n\t\t\telse\n\t\t\t\tself.result.map{ |p| p['participant_information'].select{ |a| a['desc'] == field } }.flatten.map{ |x| x['info'] }\n\t\t\tend\n\t\tend", "def select_random(field_name)\n random.pluck(field_name)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as pick but perform the query asynchronously and returns an ActiveRecord::Promise
def async_pick(*column_names) async.pick(*column_names) end
[ "def pick(*column_names)\n if loaded? && all_attributes?(column_names)\n result = records.pick(*column_names)\n return @async ? Promise::Complete.new(result) : result\n end\n\n limit(1).pluck(*column_names).then(&:first)\n end", "def async_find_by_sql(sql, binds = [], preparable: nil, &block)\n _query_by_sql(sql, binds, preparable: preparable, async: true).then do |result|\n _load_from_sql(result, &block)\n end\n end", "def async_pluck(*column_names)\n async.pluck(*column_names)\n end", "def fetch(&block)\n Volt.logger.warn('Deprication warning: in 0.9.3.pre4, all query methods on store now return Promises, so you can juse use .all or .first instead of .fetch')\n promise = Promise.new\n\n # Run the block after resolve if a block is passed in\n promise = promise.then(&block) if block\n\n if @model.loaded_state == :loaded\n promise.resolve(@model)\n else\n proc do |comp|\n if @model.loaded_state == :loaded\n promise.resolve(@model)\n\n comp.stop\n end\n end.watch!\n end\n\n promise\n end", "def await_results(promises)\n ResultSet.new(promises.map(&:value))\n end", "def then(&block)\n promise = Promise.new\n\n promise = promise.then(&block) if block\n\n if @state == :loaded\n promise.resolve(@model)\n else\n @fetch_promises ||= []\n @fetch_promises << promise\n\n load_data\n end\n\n return promise\n end", "def fetch_first(&block)\n persistor = self.persistor\n\n if persistor && persistor.is_a?(Persistors::ArrayStore)\n # On array store, we wait for the result to be loaded in.\n promise = limit(1).fetch do |res|\n result = res.first\n\n result\n end\n else\n # On all other persistors, it should be loaded already\n promise = Promise.new.resolve(first)\n end\n\n # Run any passed in blocks after fetch\n promise = promise.then(&block) if block\n\n promise\n end", "def safe_query\n ActiveRecord::Base.connection_pool.with_connection { yield }\n end", "def demand(promise)\n if promise.respond_to? :__result__\n promise.__result__\n else\n promise\n end\n end", "def pluck(*column_names)\n return [] if @none\n\n if loaded? && all_attributes?(column_names)\n result = records.pluck(*column_names)\n if @async\n return Promise::Complete.new(result)\n else\n return result\n end\n end\n\n if has_include?(column_names.first)\n relation = apply_join_dependency\n relation.pluck(*column_names)\n else\n klass.disallow_raw_sql!(column_names.flatten)\n columns = arel_columns(column_names)\n relation = spawn\n relation.select_values = columns\n result = skip_query_cache_if_necessary do\n if where_clause.contradiction?\n ActiveRecord::Result.empty(async: @async)\n else\n klass.connection.select_all(relation.arel, \"#{klass.name} Pluck\", async: @async)\n end\n end\n result.then do |result|\n type_cast_pluck_values(result, columns)\n end\n end\n end", "def do_query (&block)\n\n q = prepare_query(&block)\n rs = q.run\n\n return rs\n\n ensure\n q && q.free\n end", "def fetch_quantites\n ActiveRecord::Base.connection.execute('SELECT id, detail FROM quantites')\n end", "def query_result_set(query)\n\t result = ValueSet.new\n\t call(:query_result_set, query) do |marshalled_set|\n\t\tfor task in marshalled_set\n\t\t task = local_object(task)\n\t\t Distributed.keep.ref(task)\n\t\t result << task\n\t\tend\n\t end\n\n\t result\n\tend", "def query_wait sql, waiting_time = 10\n result = db[sql].all\n if result.empty?\n if waiting_time != 0\n sleep 1\n result = query_wait(sql, waiting_time - 1)\n end\n end\n return result\n end", "def fetch_from_db(records)\n return [] if records.empty?\n\n identifier = primary_identifier_of(records.first)\n identifier_ids = records.collect { |r| r[identifier] }.uniq\n records_uid = records.collect { |r| r[:uid] }\n\n current_model.where(uid: records_uid).where(identifier => identifier_ids)\n end", "def execute\n result = nil\n ActiveRecord::Base.connection_pool.with_connection do |con|\n result = con.execute(to_sql)\n end\n if @sql_returning.nil?\n nil\n else\n if @returning_flat\n result.values.map{|r| r.first}\n else\n result\n end\n end\n end", "def fetch_and_enqueue(force_all_syncs=false)\n begin\n if force_all_syncs\n query = db.fetch(%Q(\n SELECT r.name, r.id FROM #{relation} r, users u WHERE\n (r.state = '#{CartoDB::Synchronization::Member::STATE_SUCCESS}'\n OR r.state = '#{CartoDB::Synchronization::Member::STATE_SYNCING}')\n AND u.id = user_id AND u.state = '#{Carto::User::STATE_ACTIVE}'\n ))\n else\n query = db.fetch(%Q(\n SELECT r.name, r.id, r.user_id FROM #{relation} r, users u\n WHERE EXTRACT(EPOCH FROM r.run_at) < #{Time.now.utc.to_f}\n AND u.id = user_id AND u.state = '#{Carto::User::STATE_ACTIVE}'\n AND\n (\n r.state = '#{CartoDB::Synchronization::Member::STATE_SUCCESS}'\n OR (r.state = '#{CartoDB::Synchronization::Member::STATE_FAILURE}'\n AND r.retried_times < #{CartoDB::Synchronization::Member::MAX_RETRIES})\n )\n ORDER BY ran_at\n ))\n end\n success = true\n rescue Exception => e\n success = false\n print_log(\"ERROR fetching sync tables: #{e.message}, #{e.backtrace}\", true)\n end\n\n if success\n print_log \"Fetched #{query.count} records\"\n force_all_syncs ? enqueue_all(query) : enqueue_rate_limited(query)\n end\n\n self\n end", "def single_record!\n if use_eager_all?\n obj = clone(:all_called=>true).all.first\n\n if opts[:eager_graph]\n obj = clone(:all_called=>true).where(obj.qualified_pk_hash).unlimited.all.first\n end\n\n obj\n else\n super\n end\n end", "def async_result()\n #This is a stub, used for indexing\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /qx/take_offs GET /qx/take_offs.json
def index # @qx_take_offs = Qx::TakeOff.all per_page = params[:per_page] || 100 @q = Qx::TakeOff.ransack(params[:q]) @qx_take_offs = @q.result().paginate(:page => params[:page], :per_page => per_page) end
[ "def get_client_throughput_time_series_data(args = {}) \n get(\"/clients.json/stats/throughput\", args)\nend", "def get_trouble_spots()\n exec_get(\"#{@base_path}/api/v2/customers/trouble_spots.json?api_key=#{@api_key}\")\n end", "def update\n respond_to do |format|\n if @qx_take_off.update(qx_take_off_params)\n format.html { redirect_to @qx_take_off, notice: 'Take off was successfully updated.' }\n format.json { render :show, status: :ok, location: @qx_take_off }\n else\n format.html { render :edit }\n format.json { render json: @qx_take_off.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n runway = qx_take_off_params[:runway].split(\"/\")\n runway.each do |item|\n qx_take_off_params[:runway_id] = Qx::Runway.get_runay_id(qx_take_off_params[:airport_id], item)\n @qx_take_off = Qx::TakeOff.new(qx_take_off_params)\n end\n\n\n p runway\n\n respond_to do |format|\n if @qx_take_off.save\n format.html { redirect_to @qx_take_off, notice: 'Take off was successfully created.' }\n format.json { render :show, status: :created, location: @qx_take_off }\n else\n format.html { render :new }\n format.json { render json: @qx_take_off.errors, status: :unprocessable_entity }\n end\n end\n end", "def trades\n Client.current.get(\"#{resource_url}/trades\")\n end", "def index\n set_user\n @time_offs = TimeOff.all\n end", "def show\n @time_off_request = TimeOffRequest.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_off_request }\n end\n end", "def index\n @offs = Off.all\n end", "def trades_list(symbol:, start_time: nil, end_time: nil, from_id: nil, limit: nil, recv_window: nil)\n params = {\n symbol: symbol,\n }\n params[:startTime] = start_time if start_time\n params[:endTime] = end_time if end_time\n params[:fromId] = from_id if from_id\n params[:limit] = limit if limit\n params[:recWindow] = recv_window if recv_window\n\n SignedRequest.perform({\n request_method: :get,\n path: '/api/v3/myTrades',\n params: params,\n })\n end", "def show\n @offcut = Offcut.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offcut }\n end\n end", "def retrieve(id)\n @client.make_request(:get, \"pickups/#{id}\", MODEL_CLASS)\n end", "def index\n @fy = params[:fy] ? params[:fy].to_i : to_fy(Date.today)\n @offs = current_user.offs.where(fy:@fy).order(:off_date)\n\n @offs0 = @offs.where(off_type:0).order(:off_date)\n @offs1 = @offs.where(off_type:1).order(:off_date)\n @offs2 = @offs.where(off_type:2).order(:off_date)\n\n end", "def all(params = {})\n @client.make_request(:get, 'pickups', MODEL_CLASS, params)\n end", "def index\n @intakeoutputs = Intakeoutput.all\n render json: @intakeoutputs\n end", "def index\n limit, offset = Calculator.limit_and_offset(params)\n @test_rides = TestRide.all.limit(limit).offset(offset).order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @test_rides, each_serializer: Web::V1::TestRideSerializer\n end", "def destroy\n @qx_take_off.destroy\n respond_to do |format|\n format.html { redirect_to qx_take_offs_url, notice: 'Take off was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def index\n @more_power_ups_requests = MorePowerUpsRequest.pending\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @more_power_ups_requests }\n end\n end", "def show\n @take = Take.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @take }\n end\n end", "def index\n respond_to do |format|\n format.html\n format.json {\n\n render :json => TimeOff.joins('LEFT OUTER JOIN request_types ON time_offs.request_type_id = request_types.id')\n .joins('INNER JOIN users ON time_offs.user_id = users.id')\n .select(\n 'time_offs.id,\n time_offs.request_start_date,\n time_offs.request_end_date,\n time_offs.status,\n time_offs.comments,\n users.name as users_name,\n request_types.name as request_type_name') }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /qx/take_offs POST /qx/take_offs.json
def create runway = qx_take_off_params[:runway].split("/") runway.each do |item| qx_take_off_params[:runway_id] = Qx::Runway.get_runay_id(qx_take_off_params[:airport_id], item) @qx_take_off = Qx::TakeOff.new(qx_take_off_params) end p runway respond_to do |format| if @qx_take_off.save format.html { redirect_to @qx_take_off, notice: 'Take off was successfully created.' } format.json { render :show, status: :created, location: @qx_take_off } else format.html { render :new } format.json { render json: @qx_take_off.errors, status: :unprocessable_entity } end end end
[ "def create\n @takeoff = Takeoff.new(params[:takeoff])\n\n respond_to do |format|\n if @takeoff.save\n format.html { redirect_to @takeoff, notice: 'Takeoff was successfully created.' }\n format.json { render json: @takeoff, status: :created, location: @takeoff }\n else\n format.html { render action: \"new\" }\n format.json { render json: @takeoff.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @off = current_user.offs.new(off_params)\n calc_off\n\n respond_to do |format|\n if @off.save\n format.html { redirect_to offs_url, notice: 'Off was successfully created.' }\n format.json { render action: 'show', status: :created, location: @off }\n else\n format.html { render action: 'new' }\n format.json { render json: @off.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @qx_take_off.update(qx_take_off_params)\n format.html { redirect_to @qx_take_off, notice: 'Take off was successfully updated.' }\n format.json { render :show, status: :ok, location: @qx_take_off }\n else\n format.html { render :edit }\n format.json { render json: @qx_take_off.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @off = current_user.offs.build(off_params)\n respond_to do |format|\n if @off.save\n format.html { redirect_to @off, notice: 'Off was successfully created.' }\n format.json { render :show, status: :created, location: @off }\n else\n format.html { render :new }\n format.json { render json: @off.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @time_off = TimeOff.new(time_off_params)\n\n respond_to do |format|\n if @time_off.save\n format.html { redirect_to @time_off, notice: 'Time off was successfully created.' }\n format.json { render :show, status: :created, location: @time_off }\n else\n format.html { render :new }\n format.json { render json: @time_off.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n # @qx_take_offs = Qx::TakeOff.all\n \n per_page = params[:per_page] || 100\n @q = Qx::TakeOff.ransack(params[:q])\n @qx_take_offs = @q.result().paginate(:page => params[:page], :per_page => per_page)\n end", "def destroy\n @qx_take_off.destroy\n respond_to do |format|\n format.html { redirect_to qx_take_offs_url, notice: 'Take off was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @offcut = Offcut.new(params[:offcut])\n\n respond_to do |format|\n if @offcut.save\n format.html { redirect_to @offcut, notice: 'Offcut was successfully created.' }\n format.json { render json: @offcut, status: :created, location: @offcut }\n else\n format.html { render action: \"new\" }\n format.json { render json: @offcut.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n set_user\n @time_off = TimeOff.new(time_off_params)\n\n respond_to do |format|\n if @time_off.save\n format.html { redirect_to user_time_off_path(@user, @time_off), notice: 'Time off was successfully created.' }\n format.json { render action: 'show', status: :created, location: @time_off }\n else\n format.html { render action: 'new' }\n format.json { render json: @time_off.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_request\n return \"204\" if self.suppressed?\n uri = URI.parse(\"#{self.base_request_url}/patrons/#{self.patron_id}/holds/requests\")\n\n request = Net::HTTP::Post.new(uri)\n request.content_type = \"application/json\"\n request[\"Authorization\"] = \"Bearer #{self.bearer}\"\n\n request.body = JSON.dump({\n \"recordType\" => \"i\", #TODO: This may change at a later date, but for now we are only doing item requests. KAK.\n \"recordNumber\" => self.record_number.to_i,\n \"pickupLocation\" => self.pickup_location\n })\n $logger.debug \"Posting hold-request: #{request.body} to #{uri}\"\n\n req_options = {\n use_ssl: uri.scheme == \"https\",\n read_timeout: 10\n }\n\n begin\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n rescue Exception => e\n $logger.error \"Sierra post_request error: #{e.message}\"\n response = TimeoutResponse.new\n end\n\n $logger.debug \"Sierra Post request response code: #{response.code}, response: #{response.body}\"\n response # returns empty content, either code 204 if success, 404 if not found, or 500 if error, so passing code along.\n end", "def scrobble( params )\n LastFM.requires_authentication\n # Tracks are passed to the service using array notation for each of the above params\n array_params = {}\n params.each do |hkey, hval|\n hval = hval.to_i if hval.is_a?(Time)\n Array(hval).each_with_index do |aval, index|\n array_params[\"#{hkey}[#{index}]\"] = aval\n end\n end\n LastFM.post( \"track.scrobble\", array_params )\n end", "def create\n @takeout = Takeout.new(takeout_params)\n\n respond_to do |format|\n if @takeout.save\n format.html { redirect_to @takeout, notice: 'Takeout was successfully created.' }\n format.json { render action: 'show', status: :created, location: @takeout }\n else\n format.html { render action: 'new' }\n format.json { render json: @takeout.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @take = Take.new(params[:take])\n\n respond_to do |format|\n if @take.save\n format.html { redirect_to @take, notice: 'Take was successfully created.' }\n format.json { render json: @take, status: :created, location: @take }\n else\n format.html { render action: \"new\" }\n format.json { render json: @take.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @take = Take.new(take_params)\n\n respond_to do |format|\n if @take.save\n format.html { redirect_to @take, notice: 'Take was successfully created.' }\n format.json { render :show, status: :created, location: @take }\n else\n format.html { render :new }\n format.json { render json: @take.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @kickoff = Kickoff.new(params[:kickoff])\n\n respond_to do |format|\n if @kickoff.save\n format.html { redirect_to @kickoff, notice: 'Kickoff was successfully created.' }\n format.json { render json: @kickoff, status: :created, location: @kickoff }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kickoff.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @intake = current_user.intakes.build(intake_params)\n\n respond_to do |format|\n if @intake.save\n @intake.calculate_calories\n format.html { redirect_to intakes_url, notice: 'Intake was successfully created.' }\n format.json { render :show, status: :created, location: @intake }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @intake.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @take_key = TakeKey.new(take_key_params)\n\n respond_to do |format|\n if @take_key.save\n format.html { redirect_to take_keys_url, notice: 'Take key was successfully created.' }\n format.json { render :show, status: :created, location: @take_key }\n else\n format.html { render :new }\n format.json { render json: @take_key.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @hold_request = HoldRequest.new(hold_request_params)\n\n respond_to do |format|\n if @hold_request.save\n format.html { redirect_to @hold_request, notice: 'Hold request was successfully created.' }\n format.json { render :show, status: :created, location: @hold_request }\n else\n format.html { render :new }\n format.json { render json: @hold_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pokestop = Pokestop.new(pokestop_params)\n\n respond_to do |format|\n if @pokestop.save\n format.html { redirect_to @pokestop, notice: 'Pokestop was successfully created.' }\n format.json { render :show, status: :created, location: @pokestop }\n else\n format.html { render :new }\n format.json { render json: @pokestop.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /qx/take_offs/1 PATCH/PUT /qx/take_offs/1.json
def update respond_to do |format| if @qx_take_off.update(qx_take_off_params) format.html { redirect_to @qx_take_off, notice: 'Take off was successfully updated.' } format.json { render :show, status: :ok, location: @qx_take_off } else format.html { render :edit } format.json { render json: @qx_take_off.errors, status: :unprocessable_entity } end end end
[ "def update\n @takeoff = Takeoff.find(params[:id])\n\n respond_to do |format|\n if @takeoff.update_attributes(params[:takeoff])\n format.html { redirect_to @takeoff, notice: 'Takeoff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @takeoff.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @time_off_request = TimeOffRequest.find(params[:id])\n respond_to do |format|\n if @time_off_request.update_attributes(params[:time_off_request])\n format.html { redirect_to time_off_requests_url, notice: 'Time off request was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_off_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @kickoff = Kickoff.find(params[:id])\n\n respond_to do |format|\n if @kickoff.update_attributes(params[:kickoff])\n format.html { redirect_to @kickoff, notice: 'Kickoff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kickoff.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @time_off_request = TimeOffRequest.find(params[:id])\n respond_to do |format|\n if @time_off_request.update_attributes(params[:time_off_request])\n format.html { redirect_to admin_time_off_requests_url, notice: 'Time off request was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_off_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n spice = Spice.find_by(id: params[:id])\n spice.update(spice_params)\n render json: spice\nend", "def update\n respond_to do |format|\n if @pick.update_attributes(picks_params)\n format.html { redirect_to games_path, notice: 'Pick was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pick.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @example_lift_req.update(example_lift_req_params)\n format.html { redirect_to @example_lift_req, notice: 'Example lift req was successfully updated.' }\n format.json { render :show, status: :ok, location: @example_lift_req }\n else\n format.html { render :edit }\n format.json { render json: @example_lift_req.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch *args\n make_request :patch, *args\n end", "def update\n respond_to do |format|\n if @off.update(off_params)\n format.html { redirect_to @off, notice: 'Off was successfully updated.' }\n format.json { render :show, status: :ok, location: @off }\n else\n format.html { render :edit }\n format.json { render json: @off.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @toppick = Toppick.find(params[:id])\n\n respond_to do |format|\n if @toppick.update_attributes(params[:toppick])\n format.html { redirect_to @toppick, notice: 'Toppick was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @toppick.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pick_up_point = PickUpPoint.find(params[:id])\n\n respond_to do |format|\n if @pick_up_point.update_attributes(params[:pick_up_point])\n format.html { redirect_to @pick_up_point, notice: 'Pick up point was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pick_up_point.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @take = Take.find(params[:id])\n\n respond_to do |format|\n if @take.update_attributes(params[:take])\n format.html { redirect_to @take, notice: 'Take was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @take.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @intake = Intake.find(params[:id])\n\n respond_to do |format|\n if @intake.update_attributes(params[:intake])\n format.html { redirect_to @intake, notice: 'Intake was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @intake.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @taking.update(taking_params)\n format.html { redirect_to @taking, notice: 'Taking was successfully updated.' }\n format.json { render :show, status: :ok, location: @taking }\n else\n format.html { render :edit }\n format.json { render json: @taking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @offcut = Offcut.find(params[:id])\n\n respond_to do |format|\n if @offcut.update_attributes(params[:offcut])\n format.html { redirect_to @offcut, notice: 'Offcut was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @offcut.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n pr = PickupRequest.find(params[:id])\n pr.turtlebot_registration_id = @reg.id\n if pr.rstatus.to_sym == :completed\n render json: pr, status: :ok\n else\n if pr.update_attributes(pickup_params)\n render json: pr, status: :ok\n else\n render json: {message: pr.error}, status: :bad_request\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_pending.update(api_v1_pending_params)\n format.html { redirect_to @api_v1_pending, notice: 'Pending was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_pending }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_pending.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n update_resource @ride, ride_params\n end", "def update\n respond_to do |format|\n if @owner_take.update(owner_take_params)\n format.html { redirect_to @owner_take, notice: 'Owner take was successfully updated.' }\n format.json { render :show, status: :ok, location: @owner_take }\n else\n format.html { render :edit }\n format.json { render json: @owner_take.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /qx/take_offs/1 DELETE /qx/take_offs/1.json
def destroy @qx_take_off.destroy respond_to do |format| format.html { redirect_to qx_take_offs_url, notice: 'Take off was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @takeoff = Takeoff.find(params[:id])\n @takeoff.destroy\n\n respond_to do |format|\n format.html { redirect_to takeoffs_url }\n format.json { head :no_content }\n end\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend", "def delete\n Client.delete(\"/kits/#{@id}\")\n end", "def delete\n RestClient.delete \"#{@uri}/api/requests/request/#{@data['requestId']||@data['id']}\"\n puts ' Deleted request: '.red + \"#{@data['requestId']||@data['id']}\".light_blue\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n response = RestClient.delete $api_service+\"/claim_issues/\"+params['id']\n redirect_to :action => \"index\"\n end", "def destroy\n @off.destroy\n respond_to do |format|\n format.html { redirect_to offs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @intake.destroy\n respond_to do |format|\n format.html { redirect_to intakes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_off_request = TimeOffRequest.find(params[:id])\n @time_off_request.destroy\n\n respond_to do |format|\n format.html { redirect_to time_off_requests_url}\n format.json { head :ok }\n end\n end", "def cmd_delete argv\n setup argv\n e = @hash['element']\n response = @api.delete(e)\n msg response\n return response\n end", "def test_delete_object_time\n url = format('%s/times/abcd-3453-3de3-99sh?token=%s',\n @ts.instance_variable_get(:@baseurl),\n @ts.instance_variable_get(:@token))\n\n stub_request(:delete, url)\n @ts.delete_object('times', 'abcd-3453-3de3-99sh')\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @intake.destroy\n respond_to do |format|\n format.html { redirect_to intakes_url, notice: 'Intake was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @offcut = Offcut.find(params[:id])\n @offcut.destroy\n\n respond_to do |format|\n format.html { redirect_to offcuts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @hold_request.destroy\n respond_to do |format|\n format.html { redirect_to hold_requests_url, notice: 'Hold request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @take = Take.find(params[:id])\n @take.destroy\n\n respond_to do |format|\n format.html { redirect_to takes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @time_off_request = TimeOffRequest.find(params[:id])\n @time_off_request.destroy\n \n respond_to do |format|\n format.html { redirect_to admin_time_off_requests_url}\n format.json { head :ok }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /host_states GET /host_states.json
def index @host_states = HostState.all end
[ "def get_states\n perform(:get, 'enum/states', nil, nonauth_headers).body\n end", "def index\n @states = states.all\n json_response(@states)\n end", "def device_states_list\n get \"deviceStates\"\n end", "def index\n @api_states = Api::State.all\n end", "def host_states=(value)\n @host_states = value\n end", "def host_states\n return @host_states\n end", "def index\n @server_states = ServerState.all\n end", "def get_state_hash\n json = Net::HTTP.get(API_ENDPOINT, '/state.json')\n MultiJson.load(json)\n end", "def states\n response = params[:name].present? ? State.search(params[:name].to_s) : @country.states\n render json: response\n end", "def index\n @requests_states = Requests::State.all\n end", "def index\n @ag_states = Ag::State.all\n end", "def service_states\n svcs(\"-H\", \"-o\", \"state,nstate\", @resource[:name]).chomp.split\n end", "def index\n @service_states = ServiceState.all\n end", "def instance_states\n states = []\n request(:get, entry_points[:instance_states]) do |response|\n Nokogiri::XML(response).xpath('states/state').each do |state_el|\n state = DeltaCloud::InstanceState::State.new(state_el['name'])\n state_el.xpath('transition').each do |transition_el|\n state.transitions << DeltaCloud::InstanceState::Transition.new(\n transition_el['to'],\n transition_el['action']\n )\n end\n states << state\n end\n end\n states\n end", "def device_states_get(device_name)\n get \"deviceStates/#{device_name}\"\n end", "def index\n @home_states = HomeState.all\n end", "def list_states\n if params[:country_2_code].present?\n all_states = [[\"\", \"Select State/Province\"]]\n Country.find_country_by_alpha2(\"#{params[:country_2_code]}\").states.sort.map { |state|\n all_states << [\"#{state[0]}\", \"#{state[1].first[1]}\"]\n }\n render :json => all_states\n else\n render :text => \"Please select a country to continue...\"\n end\n end", "def index\n if params.has_key?(\"country_id\")\n @db_country = DbCountry.find(params[:country_id])\n #@db_state = DbState.where((country_id: params[:id]))\n @db_states = @db_country.states\n else\n @db_states = DbState.all\n end\n render json: @db_states\n end", "def index\n @project_states = ProjectState.all\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /host_states POST /host_states.json
def create @host_state = HostState.new(host_state_params) respond_to do |format| if @host_state.save format.html { redirect_to @host_state, notice: 'Host state was successfully created.' } format.json { render :show, status: :created, location: @host_state } else format.html { render :new } format.json { render json: @host_state.errors, status: :unprocessable_entity } end end end
[ "def host_states=(value)\n @host_states = value\n end", "def index\n @host_states = HostState.all\n end", "def create\n state.attributes = state_params\n\n respond_to do |format|\n if state.save\n format.html { redirect_to admin_states_path, notice: 'State was successfully created.' }\n format.json { render :show, status: :created, location: state }\n else\n format.html { render :new }\n format.json { render json: state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @server_state = ServerState.new(server_state_params)\n\n respond_to do |format|\n if @server_state.save\n format.html { redirect_to @server_state, notice: 'Server state was successfully created.' }\n format.json { render :show, status: :created, location: @server_state }\n else\n format.html { render :new }\n format.json { render json: @server_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @api_state = Api::State.new(api_state_params)\n\n if @api_state.save\n render json: @api_state, status: :created, location: @api_state\n else\n render json: @api_state.errors, status: :unprocessable_entity\n end\n end", "def create\n @state = State.new(state_params)\n\n if @state.save\n render json: @state, status: :created, location: @state\n # 'state was successfully created.'\n else\n render json: @state.errors, status: :unprocessable_entity\n end\n end", "def states_params\n\t \t params.require(:state).permit(:country_id, :name, :status)\n\t end", "def create\n @state_machine = StateMachine.new(state_machine_params)\n\n respond_to do |format|\n if @state_machine.save\n format.html { redirect_to @state_machine, notice: 'State machine was successfully created.' }\n format.json { render :show, status: :created, location: @state_machine }\n else\n format.html { render :new }\n format.json { render json: @state_machine.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ag_state = Ag::State.new(ag_state_params)\n\n respond_to do |format|\n if @ag_state.save\n format.html { redirect_to @ag_state, notice: 'State was successfully created.' }\n format.json { render :show, status: :created, location: @ag_state }\n else\n format.html { render :new }\n format.json { render json: @ag_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @state = current_user.states.new(state_params)\n\n respond_to do |format|\n if @state.save\n format.html { redirect_to @state, notice: 'State was successfully created.' }\n format.json { render :show, status: :created, location: @state }\n else\n format.html { render :new }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @service_state = ServiceState.new(service_state_params)\n\n respond_to do |format|\n if @service_state.save\n format.html { redirect_to @service_state, notice: 'Service state was successfully created.' }\n format.json { render :show, status: :created, location: @service_state }\n else\n format.html { render :new }\n format.json { render json: @service_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @requests_state = Requests::State.new(requests_state_params)\n\n respond_to do |format|\n if @requests_state.save\n format.html { redirect_to @requests_state, notice: 'State was successfully created.' }\n format.json { render action: 'show', status: :created, location: @requests_state }\n else\n format.html { render action: 'new' }\n format.json { render json: @requests_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @host_state.update(host_state_params)\n format.html { redirect_to @host_state, notice: 'Host state was successfully updated.' }\n format.json { render :show, status: :ok, location: @host_state }\n else\n format.html { render :edit }\n format.json { render json: @host_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @map_state = MapState.new(params[:map_state])\n\n respond_to do |format|\n if @map_state.save\n format.html { redirect_to @map_state, :notice => 'Map state was successfully created.' }\n format.json { render :json => @map_state, :status => :created, :location => @map_state }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @map_state.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @event_state = EventState.new(event_state_params)\n\n respond_to do |format|\n if @event_state.save\n format.html { redirect_to @event_state, notice: 'Event state was successfully created.' }\n format.json { render :show, status: :created, location: @event_state }\n else\n format.html { render :new }\n format.json { render json: @event_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ot_state = OtState.new(params[:ot_state])\n\n respond_to do |format|\n if @ot_state.save\n format.html { redirect_to @ot_state, notice: 'Ot state was successfully created.' }\n format.json { render json: @ot_state, status: :created, location: @ot_state }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ot_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@state = State.new(params[:state])\n\t\t@country = Country.find_by_iso_code(@state.country_iso_code)\n\t\tif (@country.nil?)\n\t\t\tformat.html { render action: \"new\" }\n\t\t\tformat.json { render json: @state.errors, status: :unprocessable_entity }\n\t\telse\n\t\t\t@state.country = @country\n\t\t\t@country.states.append @state\n\t\tend\n\n\t\trespond_to do |format|\n\t\t\tif @state.save && @country.save\n\t\t\t\tformat.html { redirect_to @state, notice: \"State was successfully created\" }\n\t\t\t\tformat.json { render json: @state, status: :created, location: @state }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\"}\n\t\t\t\tformat.json { render json: @state.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @state = State.new(params[:state])\n\n respond_to do |format|\n if @state.save\n format.html { redirect_to @state, notice: 'State was successfully created.' }\n format.json { render json: @state, status: :created, location: @state }\n else\n format.html { render action: \"new\" }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @state_hw = StateHw.new(state_hw_params)\n\n respond_to do |format|\n if @state_hw.save\n format.html { redirect_to @state_hw, notice: 'State hw was successfully created.' }\n format.json { render :show, status: :created, location: @state_hw }\n else\n format.html { render :new }\n format.json { render json: @state_hw.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /host_states/1 PATCH/PUT /host_states/1.json
def update respond_to do |format| if @host_state.update(host_state_params) format.html { redirect_to @host_state, notice: 'Host state was successfully updated.' } format.json { render :show, status: :ok, location: @host_state } else format.html { render :edit } format.json { render json: @host_state.errors, status: :unprocessable_entity } end end end
[ "def update\n @api_state = Api::State.find(params[:id])\n\n if @api_state.update(api_state_params)\n head :no_content\n else\n render json: @api_state.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @server_state.update(server_state_params)\n format.html { redirect_to @server_state, notice: 'Server state was successfully updated.' }\n format.json { render :show, status: :ok, location: @server_state }\n else\n format.html { render :edit }\n format.json { render json: @server_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @requests_state.update(requests_state_params)\n format.html { redirect_to @requests_state, notice: 'State was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @requests_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @service_state.update(service_state_params)\n format.html { redirect_to @service_state, notice: 'Service state was successfully updated.' }\n format.json { render :show, status: :ok, location: @service_state }\n else\n format.html { render :edit }\n format.json { render json: @service_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if state.update(state_params)\n format.html { redirect_to admin_state_path(state), notice: 'State was successfully updated.' }\n format.json { render :show, status: :ok, location: state }\n else\n format.html { render :edit }\n format.json { render json: state.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @modelstate.update(params[:modelstates])\n format.html { redirect_to @modelstate, notice: 'Modelstate was successfully updated.' }\n format.json { render :show, status: :ok, location: @modelstate }\n else\n format.html { render :edit }\n format.json { render json: @modelstate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ot_state = OtState.find(params[:id])\n\n respond_to do |format|\n if @ot_state.update_attributes(params[:ot_state])\n format.html { redirect_to @ot_state, notice: 'Ot state was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ot_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_state(state)\n request = Http.put(\"#{@@apiserver}/machine/#{self.identifier}\", { \"state\" => state })\n logger.info \"#{Time.now} #{self.identifier}: setting state of VM to #{state}\"\n\n end", "def update\n respond_to do |format|\n if @intervention_state.update(intervention_state_params)\n format.html { redirect_to intervention_states_url, notice: \"Intervention state was successfully updated.\" }\n format.json { render :show, status: :ok, location: @intervention_state }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @intervention_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ag_state.update(ag_state_params)\n format.html { redirect_to @ag_state, notice: 'State was successfully updated.' }\n format.json { render :show, status: :ok, location: @ag_state }\n else\n format.html { render :edit }\n format.json { render json: @ag_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @state_machine.update(state_machine_params)\n format.html { redirect_to @state_machine, notice: 'State machine was successfully updated.' }\n format.json { render :show, status: :ok, location: @state_machine }\n else\n format.html { render :edit }\n format.json { render json: @state_machine.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @state = State.find(params[:id])\n\n respond_to do |format|\n if @state.update_attributes(params[:state])\n format.html { redirect_to @state, notice: 'State was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @overtime_state = OvertimeState.find(params[:id])\n\n respond_to do |format|\n if @overtime_state.update_attributes(params[:overtime_state])\n format.html { redirect_to @overtime_state, notice: 'Overtime state was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @overtime_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_state(state)\n # Sets state of a VM\n request = Http.put(\"#{@@apiserver}/machine/#{self.identifier}\", { \"state\" => state })\n logger.info \"#{Time.now} #{self.identifier}: setting state of VM to #{state}\"\n\n end", "def update\n respond_to do |format|\n if @fsstate.update(fsstate_params)\n format.html { redirect_to @fsstate, notice: 'Fsstate was successfully updated.' }\n format.json { render :show, status: :ok, location: @fsstate }\n else\n format.html { render :edit }\n format.json { render json: @fsstate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @process_state.update(process_state_params)\n format.html { redirect_to @process_state, notice: 'Process state was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @process_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @host_config.update(host_config_params)\n format.html { redirect_to @host_config, notice: 'Host config was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @host_config.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event_state.update(event_state_params)\n format.html { redirect_to @event_state, notice: 'Event state was successfully updated.' }\n format.json { render :show, status: :ok, location: @event_state }\n else\n format.html { render :edit }\n format.json { render json: @event_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @map_state = MapState.find(params[:id])\n\n respond_to do |format|\n if @map_state.update_attributes(params[:map_state])\n format.html { redirect_to @map_state, :notice => 'Map state was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @map_state.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /host_states/1 DELETE /host_states/1.json
def destroy @host_state.destroy respond_to do |format| format.html { redirect_to host_states_url, notice: 'Host state was successfully destroyed.' } format.json { head :no_content } end end
[ "def delete(state)\n @db[:states].filter(host: state.host, service: state.service).delete\n end", "def destroy\n @ot_state = OtState.find(params[:id])\n @ot_state.destroy\n\n respond_to do |format|\n format.html { redirect_to ot_states_url }\n format.json { head :ok }\n end\n end", "def destroy\n @state = State.find(params[:id])\n @state.destroy\n\n respond_to do |format|\n format.html { redirect_to states_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ag_state.destroy\n respond_to do |format|\n format.html { redirect_to ag_states_url, notice: 'State was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @requests_state.destroy\n respond_to do |format|\n format.html { redirect_to requests_states_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @server_state.destroy\n respond_to do |format|\n format.html { redirect_to server_states_url, notice: 'Server state a bien été supprimé.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @state = State.find(params[:id])\n @state.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_states_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @service_state.destroy\n respond_to do |format|\n format.html { redirect_to service_states_url, notice: 'Service state was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @modelstate.destroy\n respond_to do |format|\n format.html { redirect_to modelstates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @map_state = MapState.find(params[:id])\n @map_state.destroy\n\n respond_to do |format|\n format.html { redirect_to map_states_url }\n format.json { head :ok }\n end\n end", "def destroy\n @overtime_state = OvertimeState.find(params[:id])\n @overtime_state.destroy\n\n respond_to do |format|\n format.html { redirect_to overtime_states_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @process_state.destroy\n respond_to do |format|\n format.html { redirect_to process_states_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_state.destroy\n respond_to do |format|\n format.html { redirect_to user_states_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @robot_state = RobotState.find(params[:id])\n @robot_state.destroy\n\n respond_to do |format|\n format.html { redirect_to robot_states_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @usstate = Usstate.find(params[:id])\n @usstate.destroy\n\n respond_to do |format|\n format.html { redirect_to usstates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @corp_state = CorpState.find(params[:id])\n @corp_state.destroy\n\n respond_to do |format|\n format.html { redirect_to corp_states_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @maintain_state.destroy\n respond_to do |format|\n format.html { redirect_to maintain_states_url, notice: 'Maintain state was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @state = State.find(params[:id])\n @state.destroy\n\n respond_to do |format|\n format.html { redirect_to(states_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @program_state.destroy\n respond_to do |format|\n format.html { redirect_to program_states_url }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /warehouse_lists GET /warehouse_lists.xml
def index @warehouse_lists = get_warehouse_lists(:page => params[:page]) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @warehouse_lists } end end
[ "def show\n @warehouse_list = WarehouseList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @warehouse_list }\n end\n end", "def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @list_items }\n end\n end", "def index\n @warehouses = Warehouse.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @warehouses }\n end\n end", "def index\n @lists = List.find(:all)\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @lists }\n end\n end", "def index\n @lists = @user.lists\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lists }\n end\n end", "def index\n @packing_lists = PackingList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @packing_lists }\n end\n end", "def index\n @shopping_lists = @dwelling.shopping_lists\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shopping_lists }\n end\n end", "def index\n @product_lists = ProductList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_lists }\n end\n end", "def index\n @wish_lists = WishList.find(:all, :order => 'created_at DESC').paginate :per_page => 20, :page => params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @wish_lists }\n end\n end", "def index\n @thing_lists = ThingList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @thing_lists }\n end\n end", "def index\n @washlists = Washlist.all\n end", "def get_list(list_id:)\n JSON.parse(api_request(method: :get, path: \"lists/#{list_id}\"))\n end", "def index\n @whish_lists = WhishList.where('user_id=?',current_user.id)\n end", "def get_list(list)\n api_get(:list, {:list => list})\n end", "def index\n if show\n show.default_set_lists\n @show_set_lists = show.show_set_lists.all\n @tour = show.tour\n else\n @show_set_lists = ShowSetList.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @show_set_lists }\n format.json { render :json => @show_set_lists }\n end\n end", "def list_locations\n headers = default_headers\n headers['Accept'] = 'text/xml'\t# JSON locations not supported\n Nokogiri.XML(get('/locations', headers))\n end", "def show\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @list_item }\n end\n end", "def sitelist_data\n res = \"val/wxfcs/all/#{@format}/sitelist?\"\n url = \"#{@base_url}#{res}key=#{@apikey}\"\n pp url\n url = URI.parse(url)\n resp = Net::HTTP.get(url)\n pp resp\n data = ::JSON.parse(resp)\n data['Locations']['Location'] # Step into the array to get location list\nend", "def index\n @wishlist_items = WishlistItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @wishlist_items }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /warehouse_lists/1 GET /warehouse_lists/1.xml
def show @warehouse_list = WarehouseList.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @warehouse_list } end end
[ "def index\n @warehouse_lists = get_warehouse_lists(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @warehouse_lists }\n end\n end", "def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @list_items }\n end\n end", "def index\n @warehouses = Warehouse.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @warehouses }\n end\n end", "def index\n @lists = List.find(:all)\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @lists }\n end\n end", "def index\n @packing_lists = PackingList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @packing_lists }\n end\n end", "def show\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @list_item }\n end\n end", "def index\n @lists = @user.lists\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lists }\n end\n end", "def index\n @product_lists = ProductList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_lists }\n end\n end", "def index\n @wish_lists = WishList.find(:all, :order => 'created_at DESC').paginate :per_page => 20, :page => params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @wish_lists }\n end\n end", "def index\n @thing_lists = ThingList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @thing_lists }\n end\n end", "def show\n @admin_listing = Listing.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @admin_listing }\n end\n end", "def show\n @warehouse = Warehouse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @warehouse }\n end\n end", "def index\n @wishlist_items = WishlistItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @wishlist_items }\n end\n end", "def show\n @warehouse = Warehouse.find(params[:id])\n @stocks = Stock.where(:company_id => @company.id, :warehouse_id => params[:id]).page(params[:page]).per(20)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @warehouse }\n end\n end", "def index\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_items = @file_list.file_list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_list_items }\n end\n end", "def index\n @article_list = ArticleList.find(params[:article_list_id])\n @article_list_items = @article_list.article_list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @article_list_items }\n end\n end", "def index\n @shopping_lists = @dwelling.shopping_lists\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shopping_lists }\n end\n end", "def index\n @lsrs_cmp = LsrsCmp.order('WarehouseName')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lsrs_cmp }\n end\n end", "def show\n @warehouse_item = WarehouseItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @warehouse_item }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Iterates until reaches coordinate
def each_until(coordinate) raise UnexpectedUntilCoordinate if coordinate < self (y_param..coordinate.y).each do |j| (x_param..coordinate.x).each do |i| yield(Coordinate.new(i, j)) end end end
[ "def loop\n measurement = yield @position\n\n while true do\n position = control measurement\n\n measurement = yield position\n end\n end", "def gather_until_none(walker, coords, inventory_window)\n total_count = 0\n loop do\n # Gather as many as we find, going from one silt pile to\n # another.\n @drag_path = [coords]\n count = gather_nearest_until_none(inventory_window)\n total_count += count\n return total_count unless count > 0\n # Go back to the starting point and check again for more.\n walker.walk_path(@drag_path.reverse)\n walker.post_walk_pause\n end\n return total_count\n end", "def walk_loop(coords, repeat = 1)\n repeat.times do\n coords.each do|xy|\n\twalk_to(xy)\n\tif block_given?\n\t return :stop if yield == :stop \n\tend\n end\n end\n end", "def walk_back_and_forth(coords, repeat = 1)\n coords = coords.dup\n skip_it = false\n repeat.times do\n coords.each do |xy|\n\t# Contortions so we don't visit the endpoints twice.\n\tif skip_it\n\t skip_it = false\n\t next\n\tend\n\twalk_to(xy)\n\tif block_given?\n\t return :stop if yield == :stop \n\tend\n end\n coords.reverse!\n skip_it = true\n end\n end", "def get_valid_coordinates(first_move_coordinates)\n random_number = generate_random_number\n coordinates = generate_random_coordinates(random_number)\n while mine_coordinates.include?(coordinates) || coordinates == first_move_coordinates\n random_number = generate_random_number\n coordinates = generate_random_coordinates(random_number)\n end\n return coordinates\n end", "def hit\n r1 = Geo::Line.new(14.0,14.0,15.0,15.0)\n \n # r2 = Geo::Line.new(15,15,20,20)\n rota = Geo::LineSet.new\n rota << r1\n #rota << r2\n #rota._reindex\n g = 0\n #gps = Geo::Point.new(14.45, 14.45)\n gps = {\n :x => 14.47644,\n :y => 14.47645\n }\n catch :hit do\n while(g<360) do\n \n walk = xwalker(gps, g)#XX, YY, g)\n walker = Geo::Line.new(gps[:x], gps[:y], walk[:x], walk[:y])\n i = rota.intersects?(walker)\n puts \"#{g}º -> \" + i.to_s\n #throw :hit if i\n g+=45\n end\n end\nend", "def reveal_points(grid_values, start_point, let_first)\n game_state = \"running\"\n points_to_revile = [start_point]\n for i in points_to_revile\n t_start_point = i.map(&:clone).join(\"\").to_s.scan(/./).map {|e| e.to_i }\n t_grid_values = grid_values.map(&:clone)\n for i in t_grid_values\n i.delete_at(2)\n end\n point_index = t_grid_values.find_index(t_start_point.to_a)\n point = grid_values[point_index]\n if point[2] == 0 and let_first == 1\n poses_arroung = get_poses_arround(start_point)\n poses_arroung.delete(start_point) \n for i in poses_arroung\n points_to_revile << i\n end\n end\n if point[2] == \"X\"\n game_state = \"lost\"\n\n end\n if point[2] == \"S\"\n t_point = point.map(&:clone)\n poses_arroung = get_poses_arround(t_point)\n poses_arroung.delete(t_point)\n \n mines_next_to_point = 0 \n for i in poses_arroung\n t_mine_point = i.map(&:clone).join(\"\").to_s.scan(/./).map {|e| e.to_i }\n t_mine_values = grid_values.map(&:clone)\n for i in t_mine_values\n i.delete_at(2)\n end\n mine_point = grid_values[t_mine_values.find_index(t_mine_point.to_a)] \n if mine_point[2] == \"X\"\n mines_next_to_point = mines_next_to_point + 1\n end\n end\n if mines_next_to_point == 0\n for m in poses_arroung\n if points_to_revile.include?(m) == false\n points_to_revile << m\n end\n end\n end\n point[2] = mines_next_to_point\n grid_values[point_index] = point\n end\n end\n returned = [game_state, grid_values]\n return returned\nend", "def enumerate_around(start_x, start_y, func, i = 0)\n movements = {\n DIRECTION_NORTH: [ 0, -1],\n DIRECTION_NORTHEAST: [ 1, -1],\n DIRECTION_EAST: [ 1, 0],\n DIRECTION_SOUTHEAST: [ 1, 1],\n DIRECTION_SOUTH: [ 0, 1],\n DIRECTION_SOUTHWEST: [-1, 1],\n DIRECTION_WEST: [-1, 0],\n DIRECTION_NORTHWEST: [-1, -1]\n }\n\n movements.each do |direction, movements|\n x, y, points = start_x + movements[0], start_y + movements[1], []\n until (x < 0 or x > 7) or (y < 0 or y > 7) or (i != 0 && points.length == i)\n points << [x, y]\n x += movements[0]\n y += movements[1]\n end\n func.call(points, direction)\n end\n end", "def move \n while true \n choose_next_position \n if [:found, :fail].include? @result\n break \n end\n end\n end", "def computer_chooses_coordinate\n\n all_possible_coordinates = @human.board.cells.keys\n coordinate = all_possible_coordinates.sample\n\n loop do\n\n if @already_fired_upon_coordinates_computer.include?(coordinate) == false\n @human.board.cells[coordinate].fire_upon\n @already_fired_upon_coordinates_computer.push(coordinate)\n break\n end\n coordinate = all_possible_coordinates.sample\n end #end of loop\n\n status = @human.board.cells[coordinate].render\n\n case status\n when 'H'\n puts \"My shot on #{coordinate} was a hit.\"\n when 'M'\n puts \"My shot on #{coordinate} was a miss.\"\n when 'X'\n puts \"My shot on #{coordinate} sunk a ship.\"\n end #ends case\n end", "def take_around! y, x, color\n #puts \"take around #{x} #{y} (#{color})\"\n # check every directions\n T.each do |tuple|\n y2, x2 = y + tuple[0], x + tuple[1]\n next unless valid_xy? x2, y2\n c = @data[y2][x2]\n if c && c != color\n take_direction! tuple, y2, x2, color\n end\n end\n end", "def each_position()\n position = self\n until position.nil?\n yield( position )\n position = position.context\n end\n end", "def advance\n case bearing\n when :north\n coordinates[1] += 1\n when :east\n coordinates[0] += 1\n when :south\n coordinates[1] -= 1\n when :west\n coordinates[0] -= 1\n end\n end", "def doesArriveAtNextViaPoint()\n viaPoint = nextViaPoint() ;\n return true if(viaPoint.nil?) ;\n \n if(isStopped()) then\n location = fetchLocation() ;\n viaLocation = viaPoint.getLocation() ;\n if(location.isCloseEnough(viaLocation,false,\n getSavSimulator().stopMargin)) then\n return true ;\n else\n return false ;\n end\n else\n return false ;\n end\n end", "def run_until(&_condition)\n for i in 0..ps.size\n step\n return i if yield self\n end\n\n -1\n end", "def positions_to_check_for_event\n positions = [[@x, @y]]\n x2 = $game_map.round_x_with_direction(@x, @direction)\n y2 = $game_map.round_y_with_direction(@y, @direction)\n positions << [x2, y2]\n return positions unless $game_map.counter?(x2, y2)\n x3 = $game_map.round_x_with_direction(x2, @direction)\n y3 = $game_map.round_y_with_direction(y2, @direction)\n positions << [x3, y3]\n return positions\n end", "def loop_round_coordinates\n # If Map Loops Horizontally and Out of Map Range (No X Loop is Caterpillar)\n if $game_map.loop_horizontal? and not @no_x_loop_round and\n (@real_x < 0 or @real_x > $game_map.width * 128)\n # Correct Event's Position\n @x %= $game_map.width\n @real_x %= $game_map.width * 128\n end\n # If Map Loops Vertically and Out of Map Range (No Y Loop is Caterpillar)\n if $game_map.loop_vertical? and not @no_y_loop_round and\n (@real_y < 0 or @real_y > $game_map.height * 128)\n # Correct Event's Position\n @y %= $game_map.height\n @real_y %= $game_map.height * 128\n end \n end", "def get_valid_move\n while true\n move = get_move\n if valid_move?(move)\n return move\n else\n puts \"Position #{ move + 1 } is occupied...Enter a free position\"\n end\n end\n end", "def find_start_and_finish\n grid.each_with_index do |row, row_idx|\n row.each_with_index do |spot, col_idx|\n if spot == START_MARK\n @start = [row_idx, col_idx]\n elsif spot == END_MARK\n @finish = [row_idx, col_idx]\n end\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
def user_project_participation(project_id) self.participants.where(project_id: project_id).first end
def current_project_participant(project_id) # if self.has_accepted?(project_id) Participant.where(project_id: project_id, user_id: self.id).first # end end
[ "def participation(project)\n \tparticipations.find_by(project: project)\n end", "def project_membership_for(project)\n ProjectMembership.where(:user_id => self.id , :project_id => project.id ).first\n end", "def contribution(project)\n \tcontributions.find_by(participation: participation(project))\n end", "def team_member_by_id(user_id)\n users_projects.find_by_user_id(user_id)\n end", "def team_member_by_id(user_id)\n users_projects.find_by(user_id: user_id)\n end", "def team_participation\n Participation.find_by_team_id_and_match_id(self.athlete.team.id, self.match.id)\n end", "def projects_member\n \tProject.joins(:members).where(:members => {:user_id => id})\n\tend", "def participation\n\t\tin_progress_game_ids = Game.where(in_progress: true).ids\n\t\tself.participations.find_by game_id: in_progress_game_ids\n\tend", "def get_meeting_participaton(user_to_search)\n\t\tmeeting_participations.find_by(user_id: user_to_search.id)\n\tend", "def selected_project\n if @task and @task.project_id.to_i > 0\n selected_project = @task.project_id\n else\n selected_project = current_user.projects.find(:first, :order => 'name').id\n end\n \n\n return selected_project\n end", "def projects\n self.user.projects.where(:client_id => self.id.to_s)\n end", "def submitter_team\n @submitter_team ||= competition.teams.joins(:users).where({ users: { id: user.id } }).first\n end", "def show\n @participation = Participation.find(params[:id])\n end", "def participants #igger loudin\n participating_users.includes(:user).map(&:user)\n end", "def selected_project\n if @task.project_id > 0\n selected_project = @task.project_id\n last_project_id = TaskFilter.filter_ids(session, :last_project_id).first\n project_id = TaskFilter.filter_ids(session, :filter_project).first\n elsif last_project_id.to_i > 0 && Project.exists?(last_project_id)\n selected_project = last_project_id\n elsif project_id.to_i > 0 && Project.exists?(project_id)\n selected_project = project_id\n else\n selected_project = current_user.projects.find(:first, :order => 'name').id\n end\n \n begin\n selected_project = current_user.projects.find(selected_project).id \n rescue \n selected_project = current_user.projects.find(:first, :order => 'name').id\n end\n\n return selected_project\n end", "def participants_on_issue(project, id)\n get(\"/projects/#{url_encode project}/issues/#{id}/participants\")\n end", "def invite_users\n @project = Project.find(params[:id])\n end", "def my_participant_id\n return @my_participant_id\n end", "def participant_id\n return @participant_id\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /electronic_prescriptions POST /electronic_prescriptions.json
def create electronic_prescription_params[:status] = electronic_prescription_params[:status].to_i @electronic_prescription = ElectronicPrescription.new(electronic_prescription_params) respond_to do |format| if @electronic_prescription.save format.html { redirect_to @electronic_prescription, notice: 'Electronic prescription was successfully created.' } format.json { render :show, status: :created, location: @electronic_prescription } else format.html { render :new } format.json { render json: @electronic_prescription.errors, status: :unprocessable_entity } end end end
[ "def create\n\t\tnew_prescription = current_user.prescriptions.create!(rx_params)\n\t\trender json: new_prescription\n\tend", "def create\n @prescription = @user.prescriptions.build(params[:prescription])\n\n respond_to do |format|\n if @prescription.save\n format.json { render json: @prescription, status: :created, location: @prescription }\n else\n format.json { render json: @prescription.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @patient = Patient.find(params[:patient_id])\n @prescription = @patient.prescriptions.build(prescription_params)\n @prescription.formulary_status = FORMULARY_STATUSES.sample\n @prescription.date_prescribed = Time.zone.now\n @prescription.active = true\n\n respond_to do |format|\n if @prescription.save\n format.html { redirect_to @patient, notice: 'Prescription was successfully created.' }\n format.json { render :show, status: :created, location: @prescription }\n else\n format.html { render :new }\n format.json { render json: @prescription.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n begin\n @prescription = current_user.prescriptions.new(prescription_params)\n @prescription.save!\n render_success_response \"Prescription sent to admin successfully\"\n rescue => e\n bad_request_error(e.message)\n end\n end", "def create\n @patient = Patient.find(params[:patient_id])\n @prescription = @patient.prescriptions.build(prescription_params.merge({\n date_prescribed: Time.zone.now, \n active: true}))\n \n respond_to do |format|\n if @prescription.save\n if @prescription.pa_required\n start_pa(@prescription)\n end\n flash_message('Prescription successfully created')\n format.html { redirect_to @patient }\n format.json { render :show, status: :created, location: @prescription }\n else\n format.html { render :new }\n format.json { render json: @prescription.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @electronic_purse = ElectronicPurse.new(params[:electronic_purse])\n\n respond_to do |format|\n if @electronic_purse.save\n format.html { redirect_to(@electronic_purse, :notice => 'Electronic purse was successfully created.') }\n format.xml { render :xml => @electronic_purse, :status => :created, :location => @electronic_purse }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @electronic_purse.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_pre_arbitration(channel_token, unique_id)\n request(\"bogus_event/pre_arbitration/#{channel_token}/#{unique_id}\")\n end", "def create\n @pre_payment_req = PrePaymentReq.new(pre_payment_req_params)\n\n respond_to do |format|\n if @pre_payment_req.save\n format.html { redirect_to @pre_payment_req, notice: 'Pre payment req was successfully created.' }\n format.json { render :show, status: :created, location: @pre_payment_req }\n else\n format.html { render :new }\n format.json { render json: @pre_payment_req.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @prescribtion = Prescribtion.new(prescribtion_params)\n\n respond_to do |format|\n if @prescribtion.save\n format.html { redirect_to @prescribtion, notice: 'Prescribtion was successfully created.' }\n format.json { render :show, status: :created, location: @prescribtion }\n else\n format.html { render :new }\n format.json { render json: @prescribtion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pres = Pre.all\n @pre = Pre.new(params[:pre])\n\n respond_to do |format|\n if @pre.save\n format.html { redirect_to @pre, notice: 'Pre was successfully created.' }\n format.json { render json: @pre, status: :created, location: @pre }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pre.errors, status: :unprocessable_entity }\n end\n end\n\n\n end", "def create\n @property = Property.find(params[:property_id])\n @prenotation = @property.prenotations.create(prenotation_params)\n\n respond_to do |format|\n if @prenotation.save\n format.html { redirect_to property_prenotations_path(@property), notice: 'Prenotazione effettuata con successo.' }\n format.json { render :show, status: :created, location: @prenotation }\n else\n format.html { render :new }\n format.json { render json: @prenotation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pre_enrollment = PreEnrollment.new(pre_enrollment_params)\n\n respond_to do |format|\n if @pre_enrollment.save\n format.html { redirect_to @pre_enrollment, notice: 'Pre enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @pre_enrollment }\n else\n format.html { render :new }\n format.json { render json: @pre_enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pre_registration = PreRegistration.new(pre_registration_params)\n\n respond_to do |format|\n if @pre_registration.save\n format.html { redirect_to @pre_registration, notice: 'Pre registration was successfully created.' }\n format.json { render :show, status: :created, location: @pre_registration }\n else\n format.html { render :new }\n format.json { render json: @pre_registration.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @device_pre_test = DevicePreTest.new(device_pre_test_params)\n\n respond_to do |format|\n if @device_pre_test.save\n format.html { redirect_to @device_pre_test, notice: 'Device pre test was successfully created.' }\n format.json { render :show, status: :created, location: @device_pre_test }\n else\n format.html { render :new }\n format.json { render json: @device_pre_test.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @prescriptions = Prescription.all\n render json: @prescriptions\n end", "def create\n @presciption = @patient.presciptions.new(presciption_params)\n\n respond_to do |format|\n if @presciption.save\n format.html { redirect_to @patient, notice: 'Presciption was successfully created.' }\n format.json { render :show, status: :created, location: @presciption }\n else\n format.html { render :new }\n format.json { render json: @presciption.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @precioproducto = Precioproducto.new(params[:precioproducto])\n\n respond_to do |format|\n if @precioproducto.save\n format.html { redirect_to @precioproducto, notice: 'Precioproducto was successfully created.' }\n format.json { render json: @precioproducto, status: :created, location: @precioproducto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @precioproducto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @prestamo_instrumento = PrestamoInstrumento.new(params[:prestamo_instrumento])\n\n respond_to do |format|\n if @prestamo_instrumento.save\n format.html { redirect_to @prestamo_instrumento, notice: 'Prestamo instrumento was successfully created.' }\n format.json { render json: @prestamo_instrumento, status: :created, location: @prestamo_instrumento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @prestamo_instrumento.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @prereq = Prereq.new(prereq_params)\n\n respond_to do |format|\n if @prereq.save\n format.html { redirect_to @prereq, notice: 'Prereq was successfully created.' }\n format.json { render :show, status: :created, location: @prereq }\n else\n format.html { render :new }\n format.json { render json: @prereq.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /electronic_prescriptions/1 PATCH/PUT /electronic_prescriptions/1.json
def update electronic_prescription_params[:status] = electronic_prescription_params[:status].to_i respond_to do |format| if @electronic_prescription.update(electronic_prescription_params) format.html { redirect_to @electronic_prescription, notice: 'Electronic prescription was successfully updated.' } format.json { render :show, status: :ok, location: @electronic_prescription } else format.html { render :edit } format.json { render json: @electronic_prescription.errors, status: :unprocessable_entity } end end end
[ "def update\n @prescription = Prescription.find(params[:id])\n\n respond_to do |format|\n if @prescription.update_attributes(params[:prescription])\n format.json { head :no_content }\n else\n format.json { render json: @prescription.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @visit = Visit.find(params[:visit_id])\n @prescription = @visit.prescriptions.find(params[:id])\n\n respond_to do |format|\n if @prescription.update_attributes(params[:prescription])\n format.html { redirect_to visit_prescriptions_url }\n format.json { respond_with_bip(@prescription) }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @prescription.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @predepend.update(predepend_params)\n render json: {status: :success, pretask: @pretask}\n else\n render json: {status: :failed, pretask: @pretask}\n end\n end\n end", "def update\n respond_to do |format|\n if @prescription.update(prescription_params)\n format.html { redirect_to @prescription, notice: 'Prescription was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @prescription.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @preorder = Preorder.find(params[:id])\n\n respond_to do |format|\n if @preorder.update_attributes(params[:preorder])\n format.html { redirect_to @preorder, notice: 'Preorder was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @preorder.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @prepod = Prepod.find(params[:id])\n\n respond_to do |format|\n if @prepod.update_attributes(params[:prepod])\n # format.html { redirect_to @prepod, notice: 'Prepod was successfully updated.' }\n format.html { redirect_to \"/home\", notice: 'Prepod was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @prepod.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n get_event\n @event_prerequisite = @event.prerequisites.find(params[:id])\n @event_prerequisite.update_attributes(params[:event_prerequisite])\n\n respond_to do |format|\n format.json { respond_with_bip(@event_prerequisite) }\n end\n end", "def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to @premio, :notice => 'Premio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @prestep = Prestep.find(params[:id])\n @recipe_id=@prestep.recipe_id\n\n respond_to do |format|\n if @prestep.update_attributes(params[:prestep])\n format.html { redirect_to recipe_path(@prestep.recipe_id) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @prestep.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to @premio, notice: 'Premio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @premio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pre_payment_req.update(pre_payment_req_params)\n format.html { redirect_to @pre_payment_req, notice: 'Pre payment req was successfully updated.' }\n format.json { render :show, status: :ok, location: @pre_payment_req }\n else\n format.html { render :edit }\n format.json { render json: @pre_payment_req.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @precioproducto = Precioproducto.find(params[:id])\n\n respond_to do |format|\n if @precioproducto.update_attributes(params[:precioproducto])\n format.html { redirect_to @precioproducto, notice: 'Precioproducto was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @precioproducto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @serial_chronology.update(serial_chronology_params)\n format.html { redirect_to :back, notice: 'Serial chronology was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { redirect_to :back, notice: 'Serial chronology was NOT successfully updated.' }\n format.json { render json: @serial_chronology.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @receipt.update(receipt_params)\n format.html { redirect_to client_receipts_path(@receipt.client), notice: 'Receipt was successfully updated.' }\n format.json { render :show, status: :ok, location: url_receipt(@receipt) }\n else\n set_people\n format.html { render :edit }\n format.json { render json: @receipt.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @premiere.update(premiere_params)\n format.html { redirect_to @premiere, notice: 'Premiere was successfully updated.' }\n format.json { render :show, status: :ok, location: @premiere }\n else\n format.html { render :edit }\n format.json { render json: @premiere.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @precatory.update(precatory_params)\n format.html { redirect_to precatories_path, notice: 'Precatory was successfully updated.' }\n format.json { render :show, status: :ok, location: @precatory }\n else\n format.html { render :edit }\n format.json { render json: @precatory.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @precliente = Precliente.find(params[:id])\n\n respond_to do |format|\n if @precliente.update_attributes(params[:precliente])\n format.html { redirect_to @precliente, notice: 'Precliente was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @precliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pelicula = Pelicula.find(params[:id])\n @pelicula.update(update_params)\n render json: @pelicula, status: :ok\n end", "def patch(data, options={})\n raise NotImplementedError, \"We only patchs to singular resources.\" if count > 1\n first.patch(data, options)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /electronic_prescriptions/1 DELETE /electronic_prescriptions/1.json
def destroy @electronic_prescription.destroy respond_to do |format| format.html { redirect_to electronic_prescriptions_url, notice: 'Electronic prescription was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @prescription = Prescription.find(params[:id])\n @prescription.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @prescription.destroy\n respond_to do |format|\n format.html { redirect_to prescriptions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @visit = Visit.find(params[:visit_id])\n @prescription = @visit.prescriptions.find(params[:id])\n @prescription.destroy\n\n respond_to do |format|\n format.html { redirect_to visit_prescriptions_url() }\n format.json { head :ok }\n end\n end", "def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend", "def destroy\n @electroniccopy.destroy\n respond_to do |format|\n format.html { redirect_to electroniccopies_url, notice: 'Electroniccopy was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @electronic_purse = ElectronicPurse.find(params[:id])\n @electronic_purse.destroy\n\n respond_to do |format|\n format.html { redirect_to(electronic_purses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @prescription.destroy\n respond_to do |format|\n format.html { redirect_to prescriptions_url, notice: 'Prescription was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @demand.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @prestamo_instrumento = PrestamoInstrumento.find(params[:id])\n @prestamo_instrumento.destroy\n\n respond_to do |format|\n format.html { redirect_to prestamo_instrumentos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @prescription_detail.destroy\n respond_to do |format|\n format.html { redirect_to prescription_details_url, notice: 'Prescription detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @enonce = Enonce.find(params[:id])\n @enonce.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @uchronia = Uchronia.find(params[:id])\n @uchronia.destroy\n\n respond_to do |format|\n format.html { redirect_to uchronias_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @prepod = Prepod.find(params[:id])\n @prepod.destroy\n\n respond_to do |format|\n format.html { redirect_to prepods_url }\n format.json { head :ok }\n end\n end", "def destroy\r\n @electronica_asignatura.destroy\r\n respond_to do |format|\r\n format.html { redirect_to electronica_asignaturas_url, notice: 'La asignatura del programa de ingeniería eléctrica fue eliminada correctamente.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @json.destroy\n\n head :no_content\n end", "def destroy\n @requisition = Requisition.find(params[:id])\n @requisition.destroy\n\n respond_to do |format|\n format.html { redirect_to requisitions_url }\n format.json { head :no_content }\n end\n end", "def delete_mobile_carrier(args = {}) \n delete(\"/mobile.json/#{args[:carrierId]}\", args)\nend", "def destroy\n \n @prescription=Prescription.where(id: @prescription_row.id_prescription).first\n @prescription_row.destroy\n respond_to do |format|\n format.html { redirect_to @prescription, notice: 'Prescription row was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Greet displays a greeting.
def greet puts '------------------------' puts "Greetings to you #{@name}" end
[ "def greeting (name)\n\tputs \"Hello \" + name\t\nend", "def say_greeting\r\n greeting = \"\\t\\t Welcome to the Virtual Crazy 8-Ball game!\" +\r\n \"\\n\\n\\n\\n\\n\\n\\t To play: \" +\r\n \"\\n\\t Simply ask any question you desire to have answered and press ENTER.\" +\r\n \"\\n\\t The 8-Ball will work its magic to determine your fortune! \" +\r\n \"\\n\\t You may ask as many questions as you like and submit 'q' to end the game.\" +\r\n \"\\n\\n\\n\\n\\n\\n\\nPress Enter to continue. \\n\\n: \"\r\n print greeting\r\n end", "def greet(name)\n\tp \"Hello, #{name}!\"\nend", "def greets\n\t\t\tputs \"You are on floor #{@floor}\"\n\t\tend", "def say_greeting\r\n\t\tgreeting = \"\\t\\t Welcome to the Virtual Crazy 8-Ball\" +\r\n\t\t\"game\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\" +\r\n\t\t\"Instructions: Choose Yes or No to play the 8-Ball game!\\n\" +\r\n\t\t\"When prompted enter your question you wish to be answered.\" +\r\n\t\t\"\\n\\nPress Enter to continue. \\n\\n: \"\r\n\t\t\r\n\t\tprint greeting\r\n\tend", "def greet\n puts \"\n _______ ___ _______ _______ _______ _______ _______ _______ _______ \n| || | | || || _ || || || || |\n|_ _|| | | ||_ _|| |_| || ||_ _|| _ || ___|\n | | | | | | | | | || | | | | | | || |___ \n | | | | | _| | | | || _| | | | |_| || ___|\n | | | | | |_ | | | _ || |_ | | | || |___ \n |___| |___| |_______| |___| |__| |__||_______| |___| |_______||_______|\".force_encoding(\"US-ASCII\")\n\n puts \"\\n \\n \\n \\n\" \nend", "def greet_user\n print \"what is your name?\"\n name = gets.chomp!\n puts \"Hello #{name}\"\n end", "def greeting\n greetings = [\"Hello\", \"Hey\", \"Greetings\", \"Salutations\", \"Welcome\"]\n greetings[rand(greetings.size)]\n end", "def welcome(nick_name, name)\n puts \"Hello, my friends call me #{nick_name}, but I prefer #{name}.\"\nend", "def welcome \n\t\tp \"Hi! Welcome to #{@place_of_work}. My name is #{@name}.\"\n\tend", "def greet(m)\r\n m.reply(\"Hi\", true)\r\n end", "def greet\n\thello + \" \" + world\nend", "def welcome_everybody\n\tputs \"Hi there!\"\n\tputs \"You rock\"\n\tputs \"This is great\"\nend", "def greet()\n\t\tputs 'Available commands:'\n\t\tputs '{a}dd, {p}rint/{s}how, {u}pdate/{m}odify, {e}xit/{q}uit '\n\tend", "def greet(name, year_born)\n# 🢑 🢑 🢑\n# | | \n# | | ─ the () brackets specifies the INPUT variables\n# | \n# | ─ methods, just like variables, needs a name\n# \n# ─ `def` starts a method \"definition\"\n\n # The method content are put between `def` and `end`\n puts(\"Greetings #{name}! You were born in #{year_born}\")\n puts(\"It is nice to meet you!\")\n\n end", "def greet(current_user)\n\tcase current_user.state\n\twhen 0\t\t# Greeting for a new user\n\t\tputs <<-PARAGRAPH\nAwesome. I'm Hal, an intelligent Habit Coach bot designed to help you create habits.\n\nI use tests to help you reach your goals.\n\nFirst, let's talk a little bit about habits.\n\nDo you understand how habits work? Triggers, feedback, reminders, motivation? (y/n)\n\t\tPARAGRAPH\n\twhen 1\t\t# Greeting for returning user\n\t\tputs <<-PARAGRAPH\nWelcome back! What stage were you in before?\n(1= set habit, 2= set trigger, 3= set motivation, 4= set reminders, 5= set feedback)\n\t\tPARAGRAPH\n\tend\n\tstage(current_user)\nend", "def greeting\n speech = ESpeak::Speech.new(\"welcome to this system!\")\n speech.speak\n puts \"Hi,welcome to the Luxury Boarding Home!\"\nend", "def greet(name, age)\n\tif name == \"Jonathan\" && age >= 18\n\t\tputs \"Welcome\"\n\telse\n\tputs\t\"No eres mayor de edad\"\n\tend\nend", "def give_welcome_msg\n puts \"Welcome to parcel system\"\n puts \"------------------------\"\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Joke displays a joke.
def joke puts "#{@name} here is a joke for you:" puts '' puts "Teacher: Anyone who thinks he's stupid may stand up!" puts '' puts 'Nobody stands up' puts '' puts 'Teacher: Im sure there are some stupid students over here!!' puts '' puts 'Little Johnny stands up' puts '' puts "Teacher: Ohh, Johnny you think you're stupid?" puts '' puts "Little Johnny: No... i just feel bad that you're standing alone..." end
[ "def show\n\t\t@joke = Joke.find(params[:id])\n\tend", "def show\n @joke = Joke.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @joke }\n end\n end", "def joke; end", "def joke\n sample(jokes)\n end", "def print_my_jokes\n jokes = Joke.where(user: self)\n puts \"Your jokes are:\"\n jokes.each do |joke|\n Joke.print_a_joke(joke)\n end\n end", "def joke(id)\n path = id.nil? ? \"/\" : \"/j/#{id}\"\n resp = http.get(path).tap do |resp|\n if resp.body.status == 404\n raise FunnyGuy::HTTPError::NotFound, error_handler.response_values(resp.env)\n end\n end\n FunnyGuy::DataSource::ICanHasDadJoke::Joke.new resp.body\n end", "def find_my_joke\n print_my_jokes\n search_for_joke\n end", "def index\n @jokes = Joke.all\n end", "def joke_by_id(id)\n \n end", "def create_joke\n # prompt user for a joke & topic\n joke_setup = CLI.prompt(\"Please enter your joke setup:\")\n joke_punchline = CLI.prompt(\"Please enter the punchline:\")\n puts \"Type in your joke topic or create one!\\n\\n\"\n Topic.print_top_five_topics\n topic = CLI.prompt\n\n # find topic from all topics & create a new joke\n topic = Topic.find_or_create_by(topic: topic)\n new_joke = Joke.new(setup: joke_setup, punchline: joke_punchline, topic: topic, user: self)\n\n # send joke back, ask if they want to make changes or save?\n input = \"\"\n until input == \"Y\" || input == \"N\" do \n Joke.print_a_joke(new_joke)\n puts \"Topic: #{new_joke.topic.topic}\\n\\n\"\n input = CLI.prompt(\"Would you like to save this joke? (Y/N)\").upcase\n if input == \"Y\"\n new_joke.save\n puts \"Thanks! Your joke has been saved.\\n\\n\"\n elsif input == \"N\"\n puts \"Your joke has not been saved.\\n\\n\"\n else\n puts \"Invalid command. Please try again.\\n\\n\"\n end\n end\n end", "def show\n @myjoke = Myjoke.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @myjoke }\n end\n end", "def index\n @long_jokes = LongJoke.all\n end", "def edit_joke\n joke = find_my_joke\n if joke\n new_setup = CLI.prompt(\"\\nPlease enter your new setup, with changes:\")\n new_punchline = CLI.prompt(\"Please enter your new punchline, with changes:\")\n new_topic = CLI.prompt(\"Your topic was #{joke.topic.topic}. Please enter an updated topic:\")\n joke.update(setup: new_setup, punchline: new_punchline, topic: Topic.find_or_create_by(topic: new_topic))\n puts \"Thanks! We've updated your joke!\\n\\n\"\n else\n puts \"Sorry, we can't find your joke!\\n\\n\"\n end\n end", "def create\n\t @joke = Joke.new(joke_params)\n\t @joke.save\n\n\t respond_to do |format|\n\t if @joke.save\n\t format.html { redirect_to @joke, notice: 'Joke was successfully created. LOL!' }\n\t format.json { render :show, status: :created, location: @joke }\n\t else\n\t format.html { render :new }\n\t format.json { render json: @joke.errors, status: :unprocessable_entity }\n\t end\n\t end\n\tend", "def index\n @short_jokes = ShortJoke.all\n end", "def delete_joke\n joke = find_my_joke\n if joke\n joke.delete\n puts \"\\nThanks! Your joke has been deleted.\\n\\n\"\n else\n puts \"\\nSorry, we can't find your joke!\\n\\n\"\n end\n end", "def to_s # {{{\n @jokes.each do |joke|\n puts \"\"\n puts \"----[ #{joke.title} ]----\\n\\n\"\n puts \"#{joke.content}\\n\"\n puts \"----[ U: #{joke.ups} ]----[ D: #{joke.downs} ]---------\"\n puts \"\"\n end\n end", "def create\n @joke = Joke.new(joke_params)\n\n respond_to do |format|\n if @joke.save\n format.html { redirect_to @joke, notice: 'Joke was successfully created.' }\n format.json { render :show, status: :created, location: @joke }\n else\n format.html { render :new }\n format.json { render json: @joke.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n\t\t@joke = Joke.new\n\t\t@joke.save\n\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /splits GET /splits.json
def index @splits = Split.all end
[ "def split_trade\n @trade = Trade.find params[:id]\n @trade.split_trade(params[:splits].values)\n respond_to do |format|\n format.json { render json: {success: @trade.errors.blank?,message: @trade.errors.full_messages} }\n end\n end", "def index\n @item_splits = ItemSplit.all\n end", "def get_locations\n splits = SplitLocationFinder.splits(params).where.not(course_id: @event.course_id)\n render json: splits, each_serializer: SplitLocationSerializer\n end", "def index\n @test_splits = TestSplit.all\n end", "def index\n @transaction_splits = TransactionSplit.all\n end", "def index\n page_number = params[:page] ? params[:page][:number] : 1\n per_page = params[:per_page] ? params[:per_page] : 10\n\n @standings = Standing.paginate(page: page_number, per_page: per_page)\n\n render json: @standings\n end", "def index\n @games_leaderboards = Games::Leaderboard.all\n\n render json: @games_leaderboards\n end", "def index\n @pie_piece_transaction_splits = PiePieceTransactionSplit.all\n end", "def get_splits(ticker, args = {})\n if args.is_a? Hash\n start_date = args[:start_date] if args[:start_date]\n start_date ||= args[:s] if args[:s]\n\n end_date = args[:end_date] if args[:end_date]\n end_date ||= args[:e] if args[:e]\n\n period = args[:period] if args[:period]\n period ||= args[:p] if args[:p]\n end\n\n csv = @yahoo_client.get_csv(ticker, start_date, end_date, period, 'splits')\n create_splits_from_csv(csv)\n end", "def index\n @splittings = Splitting.all\n end", "def list_floorplans_for_building(args = {}) \n get(\"/floorplans.json/#{args[:buildingId]}/floors\", args)\nend", "def index\n @splitters = Splitter.all\n end", "def index\n @games_leaderboards_scores = Games::Leaderboards::Score.all\n\n render json: @games_leaderboards_scores\n end", "def create\n @split = Split.new(split_params)\n\n respond_to do |format|\n if @split.save\n format.html { redirect_to @split, notice: 'Split was successfully created.' }\n format.json { render :show, status: :created, location: @split }\n else\n format.html { render :new }\n format.json { render json: @split.errors, status: :unprocessable_entity }\n end\n end\n end", "def calculate_splits(num); end", "def show\n @breakdown = Breakdown.find(params[:id])\n \n @parts = @breakdown.parts\n @labours = @breakdown.labours\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @breakdown }\n end\n end", "def get_stages\n\t\trender :json=>{:success=>false, :msg=>'Missing race ID'} and return if (!params.has_key?(:id))\n\t\t\n\t\trace = Race.find_by_id(params[:id])\n\t\trender :json=>{:success=>false, :msg=>'Invalid race ID'} and return if (race.nil?)\n\t\t\n\t\tdata = []\n\t\tstages = Stage.where({:race_id=>race.id, :status=>STATUS[:ACTIVE]})\n\t\tstages.each do |stage|\n\t\t\tdata.push({\n\t\t\t\t:id => stage.id,\n\t\t\t\t:name => stage.name\n\t\t\t})\n\t\tend\n\t\t\n\t\trender :json=>{:success=>true, :data=>data}\n\tend", "def index\n @bet_scores = @match.bet_scores\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bet_scores }\n end\n end", "def show\n @split = Split.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @split }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /splits POST /splits.json
def create @split = Split.new(split_params) respond_to do |format| if @split.save format.html { redirect_to @split, notice: 'Split was successfully created.' } format.json { render :show, status: :created, location: @split } else format.html { render :new } format.json { render json: @split.errors, status: :unprocessable_entity } end end end
[ "def create\n @test_split = TestSplit.new(test_split_params)\n\n respond_to do |format|\n if @test_split.save\n format.html { redirect_to @test_split, notice: 'Test split was successfully created.' }\n format.json { render :show, status: :created, location: @test_split }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @test_split.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @splitwise = Splitwise.new(splitwise_params)\n\n respond_to do |format|\n if @splitwise.save\n format.html { redirect_to @splitwise, notice: 'Splitwise was successfully created.' }\n format.json { render :show, status: :created, location: @splitwise }\n else\n format.html { render :new }\n format.json { render json: @splitwise.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @transaction_split = TransactionSplit.new(transaction_split_params)\n\n respond_to do |format|\n if @transaction_split.save\n format.html { redirect_to @transaction_split, notice: 'Transaction split was successfully created.' }\n format.json { render :show, status: :created, location: @transaction_split }\n else\n format.html { render :new }\n format.json { render json: @transaction_split.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item_split = ItemSplit.new(item_split_params)\n\n respond_to do |format|\n if @item_split.save\n format.html { redirect_to @item_split, notice: 'Item split was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item_split }\n else\n format.html { render action: 'new' }\n format.json { render json: @item_split.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @split = Split.new(params[:split])\n\n respond_to do |format|\n if @split.save\n format.html { redirect_to(@split, :notice => 'Split was successfully created.') }\n format.xml { render :xml => @split, :status => :created, :location => @split }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @split.errors, :status => :unprocessable_entity }\n end\n end\n end", "def split_trade\n @trade = Trade.find params[:id]\n @trade.split_trade(params[:splits].values)\n respond_to do |format|\n format.json { render json: {success: @trade.errors.blank?,message: @trade.errors.full_messages} }\n end\n end", "def create\n @splitter = Splitter.new(splitter_params)\n\n respond_to do |format|\n if @splitter.save\n format.html { redirect_to @splitter, notice: 'Splitter was successfully created.' }\n format.json { render :show, status: :created, location: @splitter }\n else\n format.html { render :new }\n format.json { render json: @splitter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @split_rule = SplitRule.new(split_rule_params)\n\n respond_to do |format|\n if @split_rule.save\n format.html { redirect_to @split_rule, notice: 'Split rule was successfully created.' }\n format.json { render :show, status: :created, location: @split_rule }\n else\n format.html { render :new }\n format.json { render json: @split_rule.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pie_piece_transaction_split = PiePieceTransactionSplit.new(pie_piece_transaction_split_params)\n\n respond_to do |format|\n if @pie_piece_transaction_split.save\n format.html { redirect_to @pie_piece_transaction_split, notice: 'Pie piece transaction split was successfully created.' }\n format.json { render :show, status: :created, location: @pie_piece_transaction_split }\n else\n format.html { render :new }\n format.json { render json: @pie_piece_transaction_split.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @splits = Split.all\n end", "def create\n params[:newpart][:count].to_i.times{\n\n @newpart = Newpart.new(params[:newpart])\n @newpart.save\n }\n respond_to do |format|\n if @newpart.save\n #format.html { redirect_to @newpart, notice: 'Newpart was successfully created.' }\n format.json { render :json=> @newpart, :status=> :created }\n else\n #format.html { render action: \"new\" }\n format.json { render :json=> @newpart.errors, :status=> :unprocessable_entity }\n end\n end\n end", "def calculate_splits(num); end", "def create\n megam_rest.post_billings(to_hash)\n end", "def index\n @test_splits = TestSplit.all\n end", "def leaderboard\n result = service.save(params.permit!.to_h[:leaderboard])\n render json: {success: true}\n end", "def create\n needed_params[:number].split(\",\").each do |number|\n repited = Needed.new\n repited.number = number.to_i\n repited.save\n end\n\n respond_to do |format|\n format.html { redirect_to neededs_url, notice: 'Needed was successfully created.' }\n format.json { render :show, status: :created, location: @needed }\n end\n end", "def create_new_payment_split_record(sender, receiver, payment )\n\t\tsender.payment_splits.create(:user_id => sender, :receiver => receiver, :amount => payment)\n\tend", "def split_create\n @parent = Amoeba.find(params[:parent][:id])\n\n act_ids = params[:amoeba][:acts]\n act_objects = Act.find_acts(act_ids)\n\n @amoeba = Amoeba.new\n @amoeba.name = params[:amoeba][:name]\n @amoeba.talent = Talent.find(params[:amoeba][:talent])\n @amoeba.generation = params[:amoeba][:generation]\n @amoeba.acts = act_objects\n\n act_ids2 = params[:amoeba2][:acts]\n act_objects2 = Act.find_acts(act_ids2)\n\n @amoeba2 = Amoeba.new\n @amoeba2.name = params[:amoeba2][:name]\n @amoeba2.talent = Talent.find(params[:amoeba2][:talent])\n @amoeba2.generation = params[:amoeba2][:generation]\n @amoeba2.acts = act_objects2\n\n if @amoeba.save && @amoeba2.save\n @parent.destroy\n redirect_to amoebas_path\n else\n render text: \"Error!\"\n end\n end", "def segment_post(params)\n call_api(:post, __method__, params)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /splits/1 PATCH/PUT /splits/1.json
def update respond_to do |format| if @split.update(split_params) format.html { redirect_to @split, notice: 'Split was successfully updated.' } format.json { render :show, status: :ok, location: @split } else format.html { render :edit } format.json { render json: @split.errors, status: :unprocessable_entity } end end end
[ "def update\n respond_to do |format|\n if @split.update(split_params)\n format.html { redirect_to @split, notice: 'Split was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @split.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @split = Split.find(params[:id])\n\n respond_to do |format|\n if @split.update_attributes(params[:split])\n format.html { redirect_to(@split, :notice => 'Split was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @split.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @splitwise.update(splitwise_params)\n format.html { redirect_to @splitwise, notice: 'Splitwise was successfully updated.' }\n format.json { render :show, status: :ok, location: @splitwise }\n else\n format.html { render :edit }\n format.json { render json: @splitwise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @test_split.update(test_split_params)\n format.html { redirect_to @test_split, notice: 'Test split was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_split }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @test_split.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item_split.update(item_split_params)\n format.html { redirect_to @item_split, notice: 'Item split was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item_split.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch *args\n make_request :patch, *args\n end", "def update\n respond_to do |format|\n if @transaction_split.update(transaction_split_params)\n format.html { redirect_to @transaction_split, notice: 'Transaction split was successfully updated.' }\n format.json { render :show, status: :ok, location: @transaction_split }\n else\n format.html { render :edit }\n format.json { render json: @transaction_split.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, params: {}, headers: {})\n request_json :patch, path, params, headers\n end", "def update\n @supermarket = Supermarket.find(params[:id]) \n respond_to do |format|\n if @supermarket.update(supermarket_params)\n format.json { render json: @supermarket, status: :ok }\n end\n end\n end", "def update\n do_patch { return } # check if patch and do submission and return early if it is a patch (submission)\n # otherwise this is a PUT of the dataset metadata\n check_status { return } # check it's in progress, clone a submitted or raise an error\n respond_to do |format|\n format.json do\n dp = DatasetParser.new(hash: params['dataset'], id: @resource.identifier, user: @user)\n @stash_identifier = dp.parse\n ds = Dataset.new(identifier: @stash_identifier.to_s) # sets up display objects\n render json: ds.metadata, status: 200\n end\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n respond_to do |format|\n if @setbreak.update(setbreak_params)\n format.json { respond_with_bip @setbreak }\n else\n format.json { respond_with_bip @setbreak }\n end\n end\n end", "def update\n @span = Span.find(params[:id])\n respond_to do |format|\n if @span.update_attributes(params[:span])\n format.html { render(:json => {:success => true}) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @span.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @split_rule.update(split_rule_params)\n format.html { redirect_to @split_rule, notice: 'Split rule was successfully updated.' }\n format.json { render :show, status: :ok, location: @split_rule }\n else\n format.html { render :edit }\n format.json { render json: @split_rule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n scenario = Scenario.find(params[:id])\n scenario.update(scenario_params)\n scenario.steps = []\n json_response(step_builder(scenario), status: :updated)\n rescue => e\n render json: {error: e.message}, status: 422\n end", "def set_or_update_arrays_for_floorplan(args = {}) \n id = args['id']\n temp_path = \"/floorplans.json/{floorplanId}/arrays\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"floorplanId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n @slab = Slab.find(params[:id])\n\n respond_to do |format|\n if @slab.update_attributes(params[:slab])\n format.html { redirect_to @slab, :notice => 'Slab was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @slab.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @supercluster.update(supercluster_params)\n format.html { redirect_to @supercluster, notice: 'Supercluster was successfully updated.' }\n format.json { render :show, status: :ok, location: @supercluster }\n else\n format.html { render :edit }\n format.json { render json: @supercluster.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @skull.update(skull_params)\n format.html { redirect_to @skull, notice: 'Skull was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @skull.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /splits/1 DELETE /splits/1.json
def destroy @split.destroy respond_to do |format| format.html { redirect_to splits_url, notice: 'Split was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @split = Split.find(params[:id])\n @split.destroy\n\n respond_to do |format|\n format.html { redirect_to(splits_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @split.destroy\n respond_to do |format|\n format.html { redirect_to splits_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item_split.destroy\n respond_to do |format|\n format.html { redirect_to item_splits_url }\n format.json { head :no_content }\n end\n end", "def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend", "def destroy\n @test_split.destroy\n respond_to do |format|\n format.html { redirect_to test_splits_url, notice: 'Test split was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_segment_batch(segment_id_array)\n payload = segment_id_array.to_s\n url = \"#{@base_url}/segments_batch\"\n return RestClient::Request.execute(:method => :delete, :url => url, :payload => payload){|response, request, result| response }\n end", "def delete\n RestClient.delete \"#{@uri}/api/requests/request/#{@data['requestId']||@data['id']}\"\n puts ' Deleted request: '.red + \"#{@data['requestId']||@data['id']}\".light_blue\n end", "def destroy\n @transaction_split.destroy\n respond_to do |format|\n format.html { redirect_to transaction_splits_url, notice: 'Transaction split was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def deleteExecution(execution_id)\n uri = URI(RUNDECKSERVER + ':' + RUNDECKPORT + '/api/12/execution/' + execution_id)\n http = Net::HTTP.new(uri.host, uri.port)\n headers = {'Content-Type'=> 'application/jsonr','X-RunDeck-Auth-Token'=> API_KEY }\n r = http.delete(uri.path, headers) \n return r\nend", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @hdfs_path = HdfsPath.find(params[:id])\n @hdfs_path.destroy\n\n respond_to do |format|\n format.html { redirect_to hdfs_paths_url }\n format.json { head :ok }\n end\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def destroy\n @bones_segment.destroy\n respond_to do |format|\n format.html { redirect_to bones_segments_url, notice: 'Bones segment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @splitting.destroy\n respond_to do |format|\n format.html { redirect_to splittings_url, notice: 'Splitting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n delete_request($uri + \"/#{$key}/groups/#{group.id}/scenes/#{id}\")\n Scene.update_cache\n end", "def destroy\n @pie_piece_transaction_split.destroy\n respond_to do |format|\n format.html { redirect_to pie_piece_transaction_splits_url, notice: 'Pie piece transaction split was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @loadbalancer = Loadbalancer.find(params[:id])\n checkaccountobject(\"loadbalancers\",@loadbalancer)\n @loadbalancer.send_delete\n\n respond_to do |format|\n format.html { redirect_to loadbalancers_url }\n format.json { head :ok }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fetch recordings from their sources to local paths
def fetch @recordings.map do |uri, path| STDERR.puts("# Fetching #{uri} to #{path}") fetch = Mixlib::ShellOut.new( "curl --continue-at - --output #{path} #{uri}", live_stream: STDERR ) fetch.run_command { path: path, result: fetch.exitstatus, uri: uri } end end
[ "def fetch\n clean_load_dir\n pull_from_remote_buckets(@remote_buckets)\n pull_from_local_dirs(@local_dirs)\n load_dir_json_files\n end", "def fetch_files_from host\n\t\tfetcher = host[:fetcher]\n\t\tswitches = host[:switches]\n\t\tbase_path = host[:base_path]\n\t\tlist_files = {}\n\t\tfetcher.connect do\n\t\tswitches.each do |s|\n\t\t\tpath = base_path + \"/\" + s.to_s + \"/\"\n\t\t\tlist_files[s] = fetcher.list_files_from path\n\t\tend\n\t\tend\n\t\tlist_files\n\tend", "def get_sources\n response = execute_get(\"/reference/source\")\n Source.from_array(decode(response))\n end", "def data_sources\n src.collect{|v| v['source']}\n end", "def list\n find_sources_by_medium\n end", "def get_sources(workdir)\n @sources.each do |source|\n cur_source = Vanagon::Component::Source.source(source.url, { :ref => source.ref, :sum => source.sum }, workdir)\n cur_source.fetch\n cur_source.verify\n end\n end", "def backlog_saved_files source\n l = []\n @db.connect do \n sql = \"SELECT file_name FROM #{table_records(source,backlog: true)} \"\n res = @db.query(sql)\n res.each_hash do |row|\n l << CDR::File.new(row['file_name'])\n end\n end\n return l\n end", "def get_recordings\n recordings_json = @@api.get_recordings[:recordings]\n recordings_objects = []\n for recording in recordings_json\n recording_object = {}\n\n recording_url = recording[:playback][:format][:url]\n recording_id = recording[:recordID]\n\n recording_object['id'] = recording_id\n recording_object['url'] = recording_url\n\n recordings_objects.push(recording_object)\n end\n @recordings = recordings_objects\n end", "def fetch\n sources_loaders = []\n\n sources do |source|\n sources_loaders << source if source.match?\n end\n\n if sources_loaders.empty?\n # This shouldn't happen with the settings object or with any external plugins.\n # but lets add a guard so we fail fast.\n raise LogStash::InvalidSourceLoaderSettingError, \"Can't find an appropriate config loader with current settings\"\n else\n begin\n pipeline_configs = sources_loaders\n .collect { |source| Array(source.pipeline_configs) }\n .compact\n .flatten\n\n if config_debug?\n pipeline_configs.each { |pipeline_config| pipeline_config.display_debug_information }\n end\n\n if pipeline_configs.empty?\n logger.error(\"No configuration found in the configured sources.\")\n end\n\n SuccessfulFetch.new(pipeline_configs)\n rescue => e\n logger.error(\"Could not fetch all the sources\", :exception => e.class, :message => e.message)\n FailedFetch.new(e.message)\n end\n end\n end", "def fetch_song_files\n\t\t\tDir[self.parse_path_with_filter].each do |file_path|\n\t\t\t\tself.songs_to_process << file_path \n\t\t\tend\n\t\tend", "def load_sources\n @sources_by_digest = {}\n\n @api.each_source do |attributes, tenant|\n begin\n if (source_type = @source_types_by_id[attributes['source_type_id']]).nil?\n logger.error(\"Source #{attributes['id']}: Source Type not found (#{attributes['source_type_id']})\")\n metrics&.record_error(:source_type_not_found)\n next\n end\n\n unless source_type.supported_source_type?\n logger.debug(\"Source #{attributes['id']}: Source Type not supported (#{source_type['name']})\")\n next\n end\n\n if source_type.supports_availability_check?\n next unless attributes[\"availability_status\"] == \"available\"\n end\n\n if source_type[\"collector_image\"].nil?\n logger.error(\"Source #{attributes['id']}: Collector Image for Source Type not found (#{source_type['name']})\")\n metrics&.record_error(:image_not_found)\n next\n end\n\n Source.new(attributes, tenant, source_type, :from_sources_api => true).tap do |source|\n source.load_credentials(@api)\n\n @sources_by_digest[source.digest] = source if source.digest.present?\n end\n rescue => err\n logger.error(\"Failed to load source #{attributes[\"name\"]}: #{err}\\n#{err.backtrace.join(\"\\n\")}\")\n metrics&.record_error(:load_sources)\n end\n end\n\n logger.debug(\"Sources loaded: #{@sources_by_digest.values.count}\")\n end", "def list_sources\n log_message( \"Listing sources...\" ) unless @logging == false\n source_list = @connection.get( \"source\" )\n return source_list\n end", "def fetch_recordings(filter=nil, sync_scope=nil)\n filter ||= {}\n logger.info \"Fetching recordings on #{self.url} with filter: #{filter.inspect}\"\n\n sync_started_at = DateTime.now\n recordings = self.api.get_recordings(filter)\n\n if recordings and recordings[:recordings]\n\n # if no scope is set and there are no filters, set the scope to all recordings\n # in this server\n sync_scope = BigbluebuttonRecording.all if filter.blank? && sync_scope.nil?\n\n BigbluebuttonRecording.sync(self, recordings[:recordings], sync_scope, sync_started_at)\n end\n end", "def list_sources\n TwList.get_or_create(\"#{@account.username} # sources\")\n end", "def fetchfiles(params={})\n raise \"ERROR: Either :dir or :file must be supplied to fetchfiles method.\" unless params[:file] || params[:dir]\n\n localfilenames = []\n if params[:testdata_url]\n raise \":dir not handled for URL #{params[:testdata_url]}\" if params[:dir]\n\n source_url = URI(\"#{params[:testdata_url]}/#{params[:file]}\")\n destination_dir = params[:destination_dir] ? params[:destination_dir] : @testcase.dirs.downloaddir\n localfilename = params[:destination_file] ? params[:destination_file] : File.join(destination_dir, File.basename(params[:file]))\n\n RemoteFileUtils.download(source_url, localfilename)\n\n testcase_output(\"Downloaded #{source_url} to #{localfilename} on host #{`hostname`}\")\n localfilenames << localfilename\n else\n raise \":dir and :destination_file can not both be specified\" if params[:dir] && params[:destination_file]\n\n destination_dir = params[:destination_dir] ? params[:destination_dir] : @testcase.dirs.drbfiledir\n destination_dir = params[:destination_file] ? File.dirname(params[:destination_file]) : destination_dir\n FileUtils.mkdir_p(destination_dir)\n\n filereader = @testcase.create_filereader\n if params[:dir]\n filenames = Dir.glob(params[:dir]+\"/*\")\n elsif params[:file]\n filenames = [params[:file]]\n end\n filenames.each do |filename|\n localfilename = params[:destination_file] ? params[:destination_file] : File.join(destination_dir, File.basename(filename))\n unless File.exist?(localfilename) && File.size?(localfilename) == filereader.size?(filename) &&\n File.mtime(localfilename) == filereader.mtime(filename) &&\n Digest::MD5.digest(localfilename) == filereader.md5(filename)\n File.open(localfilename, \"w\") do |fp|\n filereader.fetch(filename) do |buf|\n fp.write(buf)\n end\n end\n File.utime(Time.now, filereader.mtime(filename), localfilename)\n end\n localfilenames << localfilename\n end\n end\n localfilenames\n end", "def prepare_sources\n SOURCES.each_pair do |suite, url|\n prepare_source_for(url, @freshen)\n end\n end", "def fetch_external_sources(podfile_state)\n verify_no_pods_with_different_sources!\n deps = dependencies_to_fetch(podfile_state)\n pods = pods_to_fetch(podfile_state)\n return if deps.empty?\n UI.section 'Fetching external sources' do\n deps.sort.each do |dependency|\n fetch_external_source(dependency, !pods.include?(dependency.root_name))\n end\n end\n end", "def possibly_record_source_urls_discovered(urls)\n if params[:record]\n urls.each do |url|\n note_data_provider_file_discovered(url)\n end\n end\n end", "def fetch_external_sources\n return unless allow_pre_downloads?\n\n verify_no_pods_with_different_sources!\n unless dependencies_to_fetch.empty?\n UI.section 'Fetching external sources' do\n dependencies_to_fetch.sort.each do |dependency|\n fetch_external_source(dependency, !pods_to_fetch.include?(dependency.name))\n end\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Load configuration from `path`. It should be a YAMLformatted file with this content: `base_uri`: the base URI common to all recordings `base_path`: the base local path common to all recordings `file_pattern`: a pattern to construct each file's name, in `format`'s format. The format may vary yeartoyear. `recordings`: a hash specifying the recordings, with this structure: : : In 2018, the recordings were named `speaker`.
def load_config(path) # Read and parse the YAML configuration file config = YAML.safe_load(File.read(path)) recordings = [] # Build a hash whose keys are URIs and values are local file paths # Iterate over the list of each speaker's recordings config['recordings'].map do |speaker, sessions| # Iterate over the list of sessions sessions.map do |session, parts| # Iterate over the list of session parts (1..parts).map do |part| # Assemble a [uri, path] list from the interpolated file name ->(file) do recordings << %w[uri path].map do |suffix| File.join(config["base_#{suffix}"], file) end end.call( format( config['file_pattern'], { speaker: speaker, session: session, part: part } ) ) end end end Hash[recordings] end
[ "def configure_from_yaml(path, opts = {})\n begin\n yml = YAML.load(File.read(path))\n yml = yml[opts[:hash]] unless opts[:hash].nil?\n configure_from_hash(yml)\n rescue Errno::ENOENT => e\n puts e.message\n end\n end", "def load path\n file = File.open(path, 'r')\n Setting.new(YAML::load(file))\n end", "def load_file(*paths)\n paths.each do |pattern|\n Dir.glob(pattern) do |file|\n yaml = config_for_env(YAML.load_file(file)) || {}\n yaml.each_pair do |key, value|\n for_env = config_for_env(value)\n set key, for_env unless value and for_env.nil? and respond_to? key\n end\n end\n end\n end", "def configure_with path_to_yaml_file\n begin\n config = YAML::load(IO.read(path_to_yaml_file))\n rescue Errno::ENOENT\n log.warn \"YAML config file not found: using defaults instead\"; return\n rescue Psych::SyntaxError\n log.warn \"YAML config file has invalid syntax: using defaults instead\"; return\n end\n\n configure(config)\n end", "def load_yaml_file(path)\n if (file = find_data_file(path))\n YAML.load_file(file)\n end\n end", "def load_config\n begin\n config = YAML.load_file(file_path)\n rescue Errno::ENOENT\n nil\n end\n end", "def parse(file_path)\n settings = YAML.load_file(file_path)\n load(settings[\"client\"])\n end", "def load_config(path)\n yml = nil\n begin\n yml = YAML.load_file(path)\n\n rescue => e\n STDERR.puts(\"Exception occured when trying to load file: #{path} : #{e.message}\")\n yml = nil\n end\n\n return yml\n end", "def set_yaml_path(path)\n @yaml_path = \"-f #{path}\"\n @yaml = YAML.load_file(path)\n end", "def load_config(base_dir, project_config_path)\n yaml = File.read(File.join(base_dir, project_config_path))\n YAML.load(yaml)\n end", "def parse_config_file config_path\n File.open(config_path, \"r\") do |file|\n case File.extname(file).delete(\".\")\n when \"json\" then JSON.parse(file.read)\n when \"yml\" then YAML.load_file(file)\n else\n file.close\n raise LoadError, \"Type of file is not supported.\"\n end\n end\n end", "def load_file(file_path)\n return unless File.fnmatch('**.json', file_path)\n handle = File.open(file_path)\n contents = handle.read\n config_hash = parse_contents(contents)\n settings.merge!(config_hash)\n end", "def load_recursive_from_pth(base_dir_pth)\n data = {}\n\n Dir.glob(base_dir_pth.join('**').join('*.yml')) do |yml_file_pth|\n File.open(yml_file_pth, 'r') { |yml_file| data.merge!(YAML::load(yml_file)) }\n end\n\n data\n end", "def config_path=(path)\n config_file = YAML.load_file(path)\n config.merge!(config_file)\n setup_rabbitmq_opts\n rescue Errno::ENOENT => e\n self.host = \"localhost\"\n logger.error \"Could not find a baton configuration file at #{path}\"\n end", "def load_yaml(path)\n YAML.load_file File.expand_path(\"../#{path}\", File.dirname(__FILE__))\n end", "def config_file(*paths)\n Dir.chdir(root || '.') do\n paths.each do |pattern|\n Dir.glob(pattern) do |file|\n raise UnsupportedConfigType unless ['.yml', '.yaml', '.erb'].include?(File.extname(file))\n\n logger.info \"loading config file '#{file}'\" if logging? && respond_to?(:logger)\n document = ERB.new(File.read(file)).result\n yaml = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(document) : YAML.load(document)\n config = config_for_env(yaml)\n config.each_pair { |key, value| set(key, value) }\n end\n end\n end\n end", "def load\n config_files.each do |file|\n config = YAML::load(File.open(file))\n @config.merge! config\n end\n end", "def load_file(path, recurse=false, &block)\n return load_file(path, recurse, &DEFAULT_LOAD) if recurse && !block_given?\n base = File.directory?(path) ? {} : (YAML.load_file(path) || {})\n \n if recurse\n # determine the files/dirs to load recursively\n # and add them to paths by key (ie the base\n # name of the path, minus any extname)\n paths = {}\n files, dirs = Dir.glob(\"#{path.chomp(File.extname(path))}/*\").partition do |sub_path|\n File.file?(sub_path)\n end\n\n # directories are added to paths first so they can be\n # overridden by the files (appropriate since the file\n # will recursively load the directory if it exists)\n dirs.each do |dir|\n paths[File.basename(dir)] = dir\n end\n\n # when adding files, check that no two files map to\n # the same key (ex a.yml, a.yaml).\n files.each do |filepath|\n key = File.basename(filepath).chomp(File.extname(filepath))\n if existing = paths[key]\n if File.file?(existing)\n confict = [File.basename(paths[key]), File.basename(filepath)].sort\n raise \"multiple files load the same key: #{confict.inspect}\"\n end\n end\n\n paths[key] = filepath\n end\n\n # recursively load each file and reverse merge\n # the result into the base\n paths.each_pair do |key, recursive_path|\n value = load_file(recursive_path, true, &block)\n yield(base, key, value)\n end\n end\n\n base\n end", "def load_yaml(path, environment = nil)\n env = environment ? environment.to_s : env_name\n YAML.load(ERB.new(File.new(path).read).result)[env]\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /school_cycle_has_subjects/1 PATCH/PUT /school_cycle_has_subjects/1.json
def update respond_to do |format| if @school_cycle_has_subject.update(school_cycle_has_subject_params) format.html { redirect_to ["asig",@school_cycle_has_subject], notice: 'School cycle has subject was successfully updated.' } format.json { render :show, status: :ok, location: @school_cycle_has_subject } else format.html { render :edit } format.json { render json: @school_cycle_has_subject.errors, status: :unprocessable_entity } end end end
[ "def update\n respond_to do |format|\n if @cycle_has_subject.update(cycle_has_subject_params)\n format.html { redirect_to @cycle_has_subject, notice: 'Cycle has subject was successfully updated.' }\n format.json { render :show, status: :ok, location: @cycle_has_subject }\n else\n format.html { render :edit }\n format.json { render json: @cycle_has_subject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @school_subject = @cursus.school_subjects.find(params[:id])\n\n respond_to do |format|\n if @school_subject.update_attributes(params[:school_subject])\n format.html { redirect_to( cursus_school_subjects_path(@cursus) ) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @school_subject.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @manual_subject = Manual::Subject.find(params[:id])\n\n respond_to do |format|\n if @manual_subject.update_attributes(params[:manual_subject])\n format.html { redirect_to @manual_subject, notice: 'Subject was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @manual_subject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @course_has_subject.update(course_has_subject_params)\n format.html { redirect_to @course_has_subject, notice: 'Course has subject was successfully updated.' }\n format.json { render :show, status: :ok, location: @course_has_subject }\n else\n format.html { render :edit }\n format.json { render json: @course_has_subject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @subject = Subject.find(params[:id])\n\n respond_to do |format|\n if @subject.update_attributes(params[:subject])\n\n format.html { redirect_to subjects_url, :notice => 'Subject was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @subject.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @title = \"Edit Subject\"\n @subject = Subject.find(params[:id])\n\n respond_to do |format|\n if @subject.update_attributes(params[:subject])\n format.html { redirect_to @subject, notice: 'Subject was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @work_has_subject = WorkHasSubject.find(params[:id])\n\n respond_to do |format|\n if @work_has_subject.update_attributes(params[:work_has_subject])\n flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.work_has_subject'))\n format.html { redirect_to(@work_has_subject) }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @work_has_subject.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @course_subject = CourseSubject.find(params[:id])\n\n respond_to do |format|\n if @course_subject.update_attributes(params[:course_subject])\n format.html { redirect_to @course_subject, notice: 'Course subject was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course_subject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @curriculums_subject = CurriculumsSubject.find(params[:id])\n\n respond_to do |format|\n if @curriculums_subject.update_attributes(params[:curriculums_subject])\n format.html { redirect_to @curriculums_subject, notice: 'Curriculums subject was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @curriculums_subject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @university_subject.update(university_subject_params)\n format.html { redirect_to @university_subject, notice: 'University subject was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @university_subject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @subject_heading_type_has_subject.update_attributes(params[:subject_heading_type_has_subject])\n format.html { redirect_to @subject_heading_type_has_subject, :notice => 'SubjectHeadingTypeHasSubject was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @subject_heading_type_has_subject.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @exam_subject.update(exam_subject_params)\n format.html { redirect_to @exam_subject, notice: 'Exam subject was successfully updated.' }\n format.json { render :show, status: :ok, location: @exam_subject }\n else\n format.html { render :edit }\n format.json { render json: @exam_subject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student_subject.update(student_subject_params)\n format.html { redirect_to @student_subject, notice: 'Student subject was successfully updated.' }\n format.json { render :show, status: :ok, location: @student_subject }\n else\n format.html { render :edit }\n format.json { render json: @student_subject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @subject = @client.subjects.find(params[:id])\n\n respond_to do |format|\n if @subject.update_attributes(params[:subject])\n flash[:notice] = 'Subject was successfully updated.'\n format.html { redirect_to client_subject_url(@client, @subject) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @subject.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @course_subject.update(course_subject_params)\n format.html { redirect_to @course_subject, notice: 'Course subject was successfully updated.' }\n format.json { render :show, status: :ok, location: @course_subject }\n else\n format.html { render :edit }\n format.json { render json: @course_subject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @subject = Subject.find(params[:id])\n\n respond_to do |format|\n if @subject.update_attributes(params[:subject])\n format.html { redirect_to [:admin, @subject], notice: 'Subject was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @admin_subject = Admin::Subject.find(params[:id])\n\n respond_to do |format|\n if @admin_subject.update_attributes(params[:admin_subject])\n format.html { redirect_to @admin_subject, notice: 'Subject was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_subject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @subject_summary = SubjectSummary.find(params[:id])\n\n respond_to do |format|\n if @subject_summary.update_attributes(params[:subject_summary])\n format.html { redirect_to @subject_summary, notice: 'Subject summary was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subject_summary.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @section_subject.update(section_subject_params)\n format.html { redirect_to @section_subject, notice: 'Section subject was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @section_subject.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /school_cycle_has_subjects/1 DELETE /school_cycle_has_subjects/1.json
def destroy @school_cycle_has_subject.destroy respond_to do |format| format.html { redirect_to asig_school_cycle_has_subjects_path, notice: 'School cycle has subject was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @cycle_has_subject.destroy\n respond_to do |format|\n format.html { redirect_to cycle_has_subjects_url, notice: 'Cycle has subject was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @manual_subject = Manual::Subject.find(params[:id])\n @manual_subject.destroy\n\n respond_to do |format|\n format.html { redirect_to manual_subjects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @university_subject.destroy\n respond_to do |format|\n format.html { redirect_to university_subjects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @subject_heading_type_has_subject.destroy\n\n respond_to do |format|\n format.html { redirect_to subject_heading_type_has_subjects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @section_subject.destroy\n respond_to do |format|\n format.html { redirect_to section_subjects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course_subject = CourseSubject.find(params[:id])\n @course_subject.destroy\n\n respond_to do |format|\n format.html { redirect_to course_subjects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @subject = Subject.find(params[:id])\n @subject.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_subjects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mysubject.destroy\n respond_to do |format|\n format.html { redirect_to mysubjects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_subject = Admin::Subject.find(params[:id])\n @admin_subject.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_subjects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @subject_competency = SubjectCompetency.find(params[:id])\n @subject_competency.destroy\n\n respond_to do |format|\n format.html { redirect_to subject_competencies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @curriculums_subject = CurriculumsSubject.find(params[:id])\n @curriculums_subject.destroy\n\n respond_to do |format|\n format.html { redirect_to curriculums_subjects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @subject = Subject.find(params[:id])\n @subject.destroy\n\n respond_to do |format|\n format.html { redirect_to subjects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @subject = Subject.find(params[:id])\n @subject.destroy\n\n respond_to do |format|\n format.html { redirect_to subjects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @csesubject = Csesubject.find(params[:id])\n @csesubject.destroy\n\n respond_to do |format|\n format.html { redirect_to csesubjects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @subjsect.destroy\n respond_to do |format|\n format.html { redirect_to subjsects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @subject_summary = SubjectSummary.find(params[:id])\n @subject_summary.destroy\n\n respond_to do |format|\n format.html { redirect_to subject_summaries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @subject = @client.subjects.find(params[:id])\n @subject.destroy\n\n respond_to do |format|\n flash[:notice] = 'Subject was successfully removed.' \n format.html { redirect_to(client_subjects_url(@client)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @exam_subject.destroy\n respond_to do |format|\n format.html { redirect_to exam_subjects_url, notice: 'Exam subject was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_sub_subject\n @sub_subject=SubSubject.find_by(:id=>params[:id])\n @sub_subject.destroy\n respond_to do |format|\n format.html { redirect_to subjects_url, notice: @sub_subject.show_name + ' was successfully deleted.' }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Instance methods transform categories hash into nested objects for view simplicity
def categories raw_categories.to_hashugar end
[ "def categories\n Hash[self.class.catalogs.map { |fld, klass|\n name = fld.gsub(/_id$/, '_name');\n [fld, {:id => self.send(fld), :name => self.send(name)}] rescue nil\n }.reject {|cat| cat.nil?}]\n end", "def extract_categories cats\n cats.inject Hash.new do |hash, tag|\n\n # iterate through groups if the tag belongs to multiple\n tag[\"groups\"].each do |group|\n name = group[\"name\"]\n hash[name] ||= []\n hash[name] << tag[\"name\"]\n end\n hash\n end\n end", "def populate_categories(structure, category_ids)\n struct = structure.deep_dup\n struct[\"sections\"].each do |s|\n next unless s[\"kind\"] == \"categories\"\n\n s[\"categories\"].each_with_index do |c, i|\n c[\"category\"][\"id\"] = category_ids[i]\n end\n end\n struct\nend", "def category_attributes\n @cat_attr_map ||= {\n :root => [1],\n :cat1 => [1, 2],\n :cat2 => [1, 15],\n :cat11 => [1, 2, 10, 11, 12, 13, 14, 15],\n :cat12 => [1, 2, 3],\n :cat13 => [1,2, 3, 15],\n :cat121 => [],\n :cat122 => [1, 2, 3, 4, 5],\n :cat123 => [1, 2, 3, 15],\n :cat131 => [1, 2, 3, 15],\n :cat1221 => [1, 2, 3, 4, 5, 6],\n :cat1222 => [1, 2, 3, 4, 5, 15]\n }\n end", "def category_tree\n @category_tree = {}\n get_category_browse_nodes.each do |n|\n build_category_tree(n)\n end\n @category_tree\n end", "def categories\n object.categories.map do |category|\n CategorySerializer.new(category, restaurant: object)\n end\n end", "def build_categories(product, mapped_categories)\n collection = []\n\n product[:categories].each do |category_name|\n mapped_categories.each do |mapped_category|\n build_category_tree(collection, category_name, mapped_category)\n end\n end\n\n collection\n end", "def get_categories_of(entry)\n entry.categories.map{|c| category_to_struct(c) }\n end", "def categories_by_taxonomy\n\n self.categories.inject({}) do |result, category|\n \n if result.has_key?(category.taxonomy.id.to_sym)\n result[category.taxonomy.id.to_sym] << category\n else\n result[category.taxonomy.id.to_sym] = [category]\n end\n \n result \n end \n\n end", "def categories(arg_)\n @config.lock\n\n objdata_ = _get_objdata(arg_)\n return nil unless objdata_\n hash_ = {}\n objdata_[2].each do |tup_, tupcats_|\n tupcats_.each do |cat_|\n hash_[cat_] = @categories[cat_][1].map{ |elem_| tup_[elem_] }\n end\n end\n hash_\n end", "def map_category_data(products, category_data)\n products.each do |product|\n product['categories'] = []\n categories = category_data[product['sku']]\n\n unless categories.nil?\n categories.map do |cat|\n product['categories'].push({\n '@type' => 'Thing',\n 'identifier' => cat['category_id']\n })\n end\n end\n end\n\n return products\n end", "def category\n ActiveModel::SerializableResource.new(object.category, each_serializer: CategoriesSerializer)\n end", "def category_attributes=(category_attributes) # setter\n # raise category_attributes.inspect\n category_attributes.keys.each do |key|\n categories.new(category_attributes[key])\n end\n end", "def attach_categories(pf_cat_entries, categories)\n pf_cat_entries.each do |product_entries|\n # Skip unless the product is found in self\n next unless self[product_entries]\n\n product_entries[1].each_with_index do |category, i|\n # self = { product_id: { Category0: 'foo', Category1: 'bar' } } etc\n self[product_entries[0]][\"Category#{i}\".to_sym] =\n categories[category.to_sym][:Path]\n end\n end\n end", "def category_map\n value_pairs = tags.map { |tag| [tag.category, tag] }.sort\n result = []\n last_cat = nil\n value_pairs.each do |cat, tag|\n if cat == last_cat\n result.last[1] << tag\n else\n result << [cat, [tag]]\n last_cat = cat\n end\n end\n result\n end", "def category\n ActiveModel::SerializableResource.new(object.category, each_serializer: CategoriesSerializer)\n end", "def populate_categories\n categories_from_data = Utils.pluralized_array_from_hash(data, 'category', 'categories')\n self.categories = (\n Array(categories) + categories_from_data\n ).map {|c| c.to_s.downcase}.flatten.uniq\n \n self.categories.delete(\"_i18n\")\n self.categories.delete(site.config['lang'])\n \n return self.categories\n end", "def categories_hash\n hash = {}\n self.categories_array.each do |category_pair|\n category = category_pair.split('>')[0]\n subcategory = category_pair.split('>')[1]\n hash[category] = [] if hash[category].nil?\n hash[category].push(subcategory) if !subcategory.nil? && !subcategory.empty?\n end\n hash\n end", "def category_tags(xml, categories)\n case categories\n when String\n xml.itunes :category, text: categories\n when Array\n categories.each { |c| category_tags xml, c }\n when OpenStruct\n category_tags xml, categories.to_h\n when Hash\n categories.each do |parent, subcategories|\n xml.itunes(:category, text: parent) do\n category_tags xml, subcategories\n end\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /ads POST /ads.json
def create @ad = Ad.new(ad_params) respond_to do |format| if @ad.save format.html { redirect_to @ad, notice: 'Ad was successfully created.' } format.json { render :show, status: :created, location: @ad } else format.html { render :new } format.json { render json: @ad.errors, status: :unprocessable_entity } end end end
[ "def create\n @ad = Ad.new(ad_params)\n\n if @ad.save\n render json: @ad, status: :created, location: @ad\n else\n render json: @ad.errors, status: :unprocessable_entity\n end\n end", "def create\n @ad = Ad.new(params[:ad])\n\n if @ad.save\n render json: @ad, status: :created, location: @ad\n else\n render json: @ad.errors, status: :unprocessable_entity\n end\n end", "def create_ad(params={})\n request(:post, '/api/ad-create/', params).data\n end", "def create\n @ad = Ad.new(ad_params)\n\n if @ad.save\n render :show, status: :created, location: @ad\n else\n render json: @ad.errors, status: :unprocessable_entity\n end\n end", "def create\n @ad = current_advertiser.ads.new(params[:ad])\n respond_to do |format|\n if @ad.save\n format.html { redirect_to(@ad, :notice => 'Ad was successfully created.') }\n format.xml { render :xml => @ad, :status => :created, :location => @ad }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ad.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @ads_entry = AdsEntry.new(params[:ads_entry])\n\n respond_to do |format|\n if @ads_entry.save\n format.html { redirect_to @ads_entry, notice: 'Ads entry was successfully created.' }\n format.json { render json: @ads_entry, status: :created, location: @ads_entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ads_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @test_ad = TestAd.new(test_ad_params)\n\n respond_to do |format|\n if @test_ad.save\n format.html { redirect_to @test_ad, notice: 'Test ad was successfully created.' }\n format.json { render :show, status: :created, location: @test_ad }\n else\n format.html { render :new }\n format.json { render json: @test_ad.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n render json: @ads = Ad.all\n end", "def create\n @ad_post = AdPost.new(params[:ad_post])\n\n respond_to do |format|\n if @ad_post.save\n format.html { redirect_to @ad_post, notice: 'Ad post was successfully created.' }\n format.json { render json: @ad_post, status: :created, location: @ad_post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ad_post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @advert = Advert.new(params[:advert])\n\n respond_to do |format|\n if @advert.save\n format.html { redirect_to @advert, notice: 'Advert was successfully created.' }\n format.json { render json: @advert, status: :created, location: @advert }\n else\n format.html { render action: \"new\" }\n format.json { render json: @advert.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @advertisement = Advertisement.new(advertisement_params)\n respond_to do |format|\n if @advertisement.save\n format.html { redirect_to @advertisement, notice: 'Advertisement was successfully created.' }\n format.json { render :show, status: :created, location: @advertisement }\n else\n format.html { render :new }\n format.json { render json: @advertisement.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @adsense = Adsense.new(adsense_params)\n\n respond_to do |format|\n if @adsense.save\n format.html { redirect_to @adsense, notice: 'Adsense was successfully created.' }\n format.json { render :show, status: :created, location: @adsense }\n else\n format.html { render :new }\n format.json { render json: @adsense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @main_ad = MainAd.new(main_ad_params)\n\n respond_to do |format|\n if @main_ad.save\n format.html { redirect_to @main_ad, notice: 'Main ad was successfully created.' }\n format.json { render :show, status: :created, location: @main_ad }\n else\n format.html { render :new }\n format.json { render json: @main_ad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @advert = current_admin.adverts.create(advert_params)\n\n respond_to do |format|\n if @advert.save\n format.html { redirect_to @advert, notice: 'Advert was successfully created.' }\n format.json { render :show, status: :created, location: @advert }\n else\n format.html { render :new }\n format.json { render json: @advert.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ad_click = AdClick.new(ad_click_params)\n\n respond_to do |format|\n if @ad_click.save\n format.html { redirect_to @ad_click, notice: 'Ad click was successfully created.' }\n format.json { render :show, status: :created, location: @ad_click }\n else\n format.html { render :new }\n format.json { render json: @ad_click.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ad = Ad.new(params[:ad])\n\n respond_to do |format|\n if @ad.save\n flash[:notice] = 'Ad was successfully created.'.l\n format.html { redirect_to ad_url(@ad) }\n format.xml { head :created, :location => ad_url(@ad) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ad.errors.to_xml }\n end\n end\n end", "def create\n @adcom = Adcom.new(adcom_params)\n\n respond_to do |format|\n if @adcom.save\n format.html { redirect_to @adcom, notice: 'Adcom was successfully created.' }\n format.json { render :show, status: :created, location: @adcom }\n else\n format.html { render :new }\n format.json { render json: @adcom.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @ads = Ad.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ads }\n end\n end", "def create\n @advert = current_user.adverts.new(advert_params)\n\n respond_to do |format|\n if @advert.save\n format.html { redirect_to @advert, notice: 'Advert was successfully created.' }\n format.json { render :show, status: :created, location: @advert }\n else\n format.html { render :new }\n format.json { render json: @advert.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Todo: Anyone can write or view the list of reviews for a movie, but only an admin or the user who created a review should be allowed to edit or delete it Implement this by removing the edit and delete buttons on the reviewshow page except for Admins, and create a link on the user profile page to My Reviews. Create a new view for the current user's reviews with options to edit and delete there.
def index @reviews = @movie.reviews end
[ "def edit\n @movie = Movie.find(params[:movie_id])\n \n @review = @movie.reviews.find(params[:id])\n end", "def show\n @movie = Movie.find(params[:id])\n @reviews = @movie.reviews.order('updated_at DESC')\n end", "def show\n @movie = Movie.find(params[:movie_id])\n \n #find a review in movies 1 that has id=2\n @review = @movie.reviews.find(params[:id])\n end", "def show\n @user = current_user\n @review = Review.joins(:movie).includes(:movie)\n .find_by_id(params[:id])\n\n @comments = @review.review_comments.map do |comment|\n if @user != nil\n belongs_to_user = @user.id == comment.user_id\n else\n belongs_to_user = false\n end\n {\n id: comment.id,\n body: comment.body,\n author: comment.user.nickname,\n author_image: comment.user.image,\n belongs_to_user: belongs_to_user\n }\n end\n if @user != nil\n @review_likes = ReviewLike.where(\"user_id = ? AND review_id = ?\", @user.id, @review.id)\n if @review_likes.empty?\n review_like_id = 'null'\n review_liked = false\n else\n review_like_id = @review_likes[0].id\n review_liked = true\n end\n else\n review_like_id = 'null'\n review_liked = 'null'\n end\n\n review = {\n title: @review.title,\n id: @review.id,\n likes: @review.likes,\n body: @review.body,\n genre: @review.genre,\n movie: @review.movie,\n belongs_to_user: @review.user == @user,\n review_like_id: review_like_id,\n review_liked: review_liked\n }\n render json: {review: review, comments: @comments}\n end", "def create\n @review = Review.new(review_params)\n @review.user_id = current_user.id\n @review.movie_id = @movie.id\n\n respond_to do |format|\n #If the review is saved, it redirects to the movie page and shows the notice.\n if @review.save\n format.html { redirect_to @movie, notice: t('review.create') }\n format.json { render :show, status: :created, location: @review }\n #If the review is not saved, it refreshes the create review page.\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n @movie = Movie.find(params[:movie_id])\n \n #populate a review asscoiated with movie 1 with form data\n # movie will be associated with the review\n @review = @movie.reviews.build(params.require(:review).permit(:details))\n if @review.save\n redirect_to movie_review_url(@movie,@review)\n else\n render :action => \"new\"\n end\n end", "def edit\n movie = Movie.find(params[:movie_id])\n @review = Review.find(params[:id])\n @movie = Movie.find(params[:movie_id])\n end", "def index\n @admin_reviews = Review.all\n end", "def reviews\n @cuid = isSignedIn ? current_user.id : nil\n @u = User.find_by(id: params[:uid])\n @rs = getUserReviews(params[:uid])\n end", "def edit\r\n\t\t@current_area = \"reviews\"\r\n\t\t@current_menu = \"reviews\"\r\n\r\n\t\tif request.post?\r\n\t\t\t@review = Review.find(params[:id].to_i)\r\n\r\n\t\t\tflash_message = \"\"\r\n\t\t\tif params[:show] == \"Show\"\r\n\t\t\t\t@review[:allowed] = \"y\"\r\n\t\t\t\tflash_message = \"The review of #{@review.product} by #{@review.user} will now be visible to shoppers\"\r\n\t\t\telsif params[:hide] == \"Hide\"\r\n\t\t\t\t@review[:allowed] = \"n\"\r\n\t\t\t\tflash_message = \"The review of #{@review.product} by #{@review.user} will now be hidden from shoppers\"\r\n\t\t\telsif params[:edit] == \"Edit\"\r\n\t\t\t\t@review[:comments] = params[:review][:comments]\r\n\t\t\t\tflash_message = \"Comments in the review of #{@review.product} by #{@review.user} edited\"\r\n\t\t\tend\r\n\r\n\t\t\tif @review.save\r\n\t\t\t\tflash[:notice] = flash_message\r\n\t\t\t\tredirect_to :action => :list\r\n\t\t\telse\r\n\t\t\t\tflash[:error] = \"Unable to save moderation\"\r\n\t\t\tend\r\n\t\telse\r\n\t\t\t@review = Review.find(params[:id].to_i)\r\n\t\tend\r\n\tend", "def index\n @visitor_reviews = VisitorReview.all\n end", "def edit\n @review = Review.find(params[:id])\n \n if current_user.id == @review.user_id\n @review\n else\n redirect_to root_path, :alert => \"Access Denied\"\n end\n end", "def edit\n\t\t@reviews = @share.reviews.order(priority: :asc)\n\t\t@reviewToAlter = Review.find(params[:id])\n\tend", "def show\n redirect_to \"#{movie_path(params[:id])}/reviews\"\n end", "def index\n @reviewers = Reviewer.all\n end", "def review_list\n object.reviews.map do |review|\n {\n id: review.id,\n user: {\n id: review.user_id,\n name: User.find(review.user_id).name\n },\n content: review.content\n }\n end\n end", "def index\n\t\t@reviews = @share.reviews.order(priority: :asc)\n\t\t@reviewToAlter = @share.reviews.new\n\tend", "def design_review_reviewers\n \n @design = Design.find(params[:id])\n @design_reviews = @design.design_reviews.sort_by { |dr| dr.review_type.sort_order } \n @review_roles = Role.get_review_roles + Role.get_manager_review_roles\n \n # Do not display a review role that is not set up to review the\n # design.\n @review_roles.delete_if { |r| @design.role_review_count(r) == 0 }\n \n @review_roles_locked = []\n @review_roles.each_with_index do |r, i|\n @review_roles_locked[i] = @design.role_open_review_count(r) == 0\n end\n \n end", "def create\n @review = Review.find(params[:review_id])\n @comment = @review.comments.create(comment_params)\n @comment.update(user_id: current_user.id)\n if (@review.category == \"Album\")\n redirect_to albumreview_path(@review)\n elsif (@review.category == \"Movie\")\n redirect_to review_path(@review)\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /numbers POST /numbers.json
def create @number = Number.new(params[:number]) respond_to do |format| if @number.save format.json { render json: @number, status: :created } else format.json { render json: @number.errors, status: :unprocessable_entity } end end end
[ "def create\n Rails.logger.info ['API: number assignment requested', {request: request_loginfo}]\n\n affiliate_user_to_project_if_yet\n\n @number = build_new_number\n if @number.save\n marking_if_mark_requested number_params[:mark]\n render json: @number\n else\n render json: { message: @number.errors.values.join(' ') }.to_json, status: :bad_request\n end\n end", "def create\n @num = Num.new(num_params)\n\n respond_to do |format|\n if @num.save\n format.html { redirect_to @num, notice: \"Num was successfully created.\" }\n format.json { render :show, status: :created, location: @num }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @num.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_number_array()\n # Parameters for the API call\n integers = APIHelper.json_deserialize(\n '[1,2,3,4,5]'\n )\n\n # Perform the API call through the SDK function\n result = @controller.number_array(integers)\n\n # Test response code\n assert([*200..208].include? @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def create\n @tnumber = Tnumber.new(params[:tnumber])\n\n respond_to do |format|\n if @tnumber.save\n format.html { redirect_to @tnumber, :notice => 'Tnumber was successfully created.' }\n format.json { render :json => @tnumber, :status => :created, :location => @tnumber }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @tnumber.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n needed_params[:number].split(\",\").each do |number|\n repited = Needed.new\n repited.number = number.to_i\n repited.save\n end\n\n respond_to do |format|\n format.html { redirect_to neededs_url, notice: 'Needed was successfully created.' }\n format.json { render :show, status: :created, location: @needed }\n end\n end", "def create\n @test_number = TestNumber.new(params[:test_number])\n @app = App.find(params[:app_id])\n @app.test_numbers << @test_number\n\n respond_to do |format|\n if @test_number.save\n format.html { redirect_to app_test_numbers_path, notice: 'Test number was successfully created.' }\n format.json { render json: @test_number, status: :created, location: @test_number }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test_number.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_number_array()\n # Parameters for the API call\n integers = JSON.parse('[1,2,3,4,5]')\n\n # Perform the API call through the SDK function\n result = self.class.controller.number_array(integers)\n\n # Test response code\n assert([*200..208].include? @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n assert_not_nil(result)\n expected_body = JSON.parse('{\"passed\":true}')\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def create\n @tnumber = Tnumber.new(params[:tnumber])\n\n respond_to do |format|\n if @tnumber.save\n format.html { redirect_to @tnumber, notice: 'Tnumber was successfully created.' }\n format.json { render json: @tnumber, status: :created, location: @tnumber }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tnumber.errors, status: :unprocessable_entity }\n end\n end\n end", "def numbers\r\n NumbersController.instance\r\n end", "def save_numbers(phone_numbers)\n unless phone_numbers == nil\n phone_numbers.each do |number|\n number.each do |key, value|\n phone = @contact.numbers.create(num_type: key.to_s, number: value)\n end\n end\n end\n end", "def index\n @service_numbers = ServiceNumber.all\n\n render json: @service_numbers\n end", "def create\n @number = Number.new(params[:number])\n\n respond_to do |format|\n if @number.save\n format.html { redirect_to(@number, :notice => 'Number was successfully created.') }\n format.xml { render :xml => @number, :status => :created, :location => @number }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @number.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @numbering = Numbering.new(numbering_params)\n\n respond_to do |format|\n if @numbering.save\n format.html { redirect_to @numbering, notice: 'Numbering was successfully created.' }\n format.json { render :show, status: :created, location: @numbering }\n else\n format.html { render :new }\n format.json { render json: @numbering.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @auto_number = AutoNumber.new(auto_number_params)\n\n respond_to do |format|\n if @auto_number.save\n format.html { redirect_to @auto_number, notice: \"Created new number: #{@auto_number.file_name}\" }\n format.json { render :show, status: :created, location: @auto_number }\n else\n format.html { render :new }\n format.json { render json: @auto_number.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @random_number = RandomNumber.new(params[:random_number])\n\n respond_to do |format|\n if @random_number.save\n format.html { redirect_to @random_number, notice: 'Random number was successfully created.' }\n format.json { render json: @random_number, status: :created, location: @random_number }\n else\n format.html { render action: \"new\" }\n format.json { render json: @random_number.errors, status: :unprocessable_entity }\n end\n end\n end", "def render_success_response_json_with_number(number, status = :created)\n render json: { reading_id: number }, status: status\n end", "def butch_create(phone_numbers, custom_account_id = nil)\n pipe.put do |request|\n request.url \"accounts/#{custom_account_id || account_id}/phone_numbers/collection\"\n request.headers['X-Auth-Token'] = auth_token\n request.body = { data: {numbers: phone_numbers} }\n end.body\n end", "def create\n @number_running = NumberRunning.new(number_running_params)\n\n respond_to do |format|\n if @number_running.save\n format.html { redirect_to @number_running, notice: 'Number running was successfully created.' }\n format.json { render :show, status: :created, location: @number_running }\n else\n format.html { render :new }\n format.json { render json: @number_running.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @special_number = SpecialNumber.new(params[:special_number])\n\n respond_to do |format|\n if @special_number.save\n format.html { redirect_to @special_number, notice: 'Special number was successfully created.' }\n format.json { render json: @special_number, status: :created, location: @special_number }\n else\n format.html { render action: \"new\" }\n format.json { render json: @special_number.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /numbers/1 DELETE /numbers/1.json
def destroy @number = Number.where(:value => params[:number][:value]).first @number.destroy respond_to do |format| format.json { head :no_content } end end
[ "def destroy\n @num.destroy\n respond_to do |format|\n format.html { redirect_to nums_url, notice: \"Num was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @static_number.destroy\n respond_to do |format|\n format.html { redirect_to static_numbers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_number = ClientNumber.find(params[:id])\n @client_number.destroy\n\n respond_to do |format|\n format.html { redirect_to client_numbers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @numberdetail = Numberdetail.find(params[:id])\n @numberdetail.destroy\n\n respond_to do |format|\n format.html { redirect_to numberdetails_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_number = TestNumber.find(params[:id])\n @test_number.destroy\n\n respond_to do |format|\n format.html { redirect_to app_test_numbers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tnumber = Tnumber.find(params[:id])\n @tnumber.destroy\n\n respond_to do |format|\n format.html { redirect_to tnumbers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @nonexistent_number.destroy\n respond_to do |format|\n format.html { redirect_to nonexistent_numbers_url, notice: \"Nonexistent number was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @numerical = Numerical.find(params[:id])\n @numerical.destroy\n\n respond_to do |format|\n format.html { redirect_to numericals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @phone1 = Phone1.find(params[:id])\n @phone1.destroy\n\n respond_to do |format|\n format.html { redirect_to phone1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @operation_number = OperationNumber.find(params[:id])\n @operation_number.destroy\n\n respond_to do |format|\n format.html { redirect_to operation_numbers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n\n head :no_content\n end", "def delete(path, params={}); make_request(:delete, host, port, path, params); end", "def delete(num)\n #TODO error checking\n successful = false\n @req.execute(\"DELETE FROM bookRequestes WHERE requestID = ?\", num)\n successful = true\n successful\n end", "def destroy\n @phone_number = PhoneNumber.find(params[:id])\n @phone_number.destroy\n\n respond_to do |format|\n format.html { redirect_to phone_numbers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @special_number = SpecialNumber.find(params[:id])\n @special_number.destroy\n\n respond_to do |format|\n format.html { redirect_to special_numbers_url }\n format.json { head :no_content }\n end\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @numerator = Numerator.find(params[:id])\n @numerator.destroy\n\n respond_to do |format|\n format.html { redirect_to numerators_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @one = One.find(params[:id])\n @one.destroy\n\n respond_to do |format|\n format.html { redirect_to ones_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @number_call = NumberCall.find(params[:id])\n @number_call.destroy\n\n respond_to do |format|\n format.html { redirect_to number_calls_url }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /contentperpages GET /contentperpages.json
def index @contentperpages = Contentperpage.all end
[ "def pages\n self.list(:pages)\n end", "def pages\n get(\"v1/account/#{@email}/pages\")\n end", "def index\n @pages = Page.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end", "def publishing_api_paginates_content(content_items, per_page, document_klass, search_query: nil)\n total_pages = content_items.length / per_page\n total_pages += 1 unless content_items.length.remainder(per_page).zero?\n if total_pages.zero?\n publishing_api_has_no_content(document_klass, search_query)\n else\n content_items.each_slice(per_page).with_index.map do |page_items, index|\n body = {\n results: page_items,\n total: content_items.length,\n pages: total_pages,\n current_page: index + 1,\n }\n query_params = {\n page: (index + 1).to_s,\n document_type: document_klass.document_type,\n }\n query_params[:q] = search_query if search_query.present?\n\n stub_request(:get, \"#{GdsApi::TestHelpers::PublishingApi::PUBLISHING_API_V2_ENDPOINT}/content\")\n .with(query: hash_including(query_params))\n .to_return(status: 200, body: body.to_json, headers: {})\n end\n end\n end", "def get_pages(options = nil)\n @client.raw('get', '/content/pages', options)\n end", "def index\n @content_elements = Page.find(params[:page_id]).content_elements\n \n respond_to do |format|\n format.json { render :json => @content_elements }\n format.xml { render :xml => @content_elements }\n end\n end", "def num_pages\n \n # Retrieve postings that match the given conditions\n postings = getPostings(params)\n \n # Escapes the case when @postings is nil\n num_pages = postings.blank? ? 0 : postings.num_pages\n \n respond_to do |format|\n format.json { render json: num_pages }\n end\n \n end", "def count_page\n num_pages = current_cookbook.num_pages\n render json: {num_pages: num_pages}\n end", "def index\r\n page = 1\r\n if params.has_key?(:page)\r\n page = params[:page]\r\n end\r\n\r\n @content_pages = ContentPage.display_all_by_page(page)\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @content_pages }\r\n end\r\n end", "def posts_per_page\n 20\n end", "def index\n @pages = Page.all\n render json: @pages, status: 200\n end", "def resource_per_page\n 10\n end", "def max_per_page\n 200\n end", "def index\n @collection_pages = @collection.collection_pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @collection_pages }\n end\n end", "def index\n @pages = current_site.pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end", "def pages_in_space(space_key: nil)\n parameters = {\n limit: 1000,\n expand: 'children,ancestors'\n }\n target_url = @base_url + \"/space/#{space_key}/content/page\"\n resp = Typhoeus.get(target_url, params: parameters, userpwd: \"#{@user}:#{@pass}\")\n\n if resp.response_code == 200\n r = JSON.parse(resp.body)\n results = JSON.parse(resp.body)['results']\n end\n end", "def pages\n @pages \n end", "def pages\n get(\"v1/event/#{@id}/pages\")\n end", "def default_per_page\n JsonApiServer.configuration.default_per_page\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /contentperpages/1 PATCH/PUT /contentperpages/1.json
def update respond_to do |format| if @contentperpage.update(contentperpage_params) format.html { redirect_to @contentperpage, notice: 'Contentperpage was successfully updated.' } format.json { render :show, status: :ok, location: @contentperpage } else format.html { render :edit } format.json { render json: @contentperpage.errors, status: :unprocessable_entity } end end end
[ "def update\n authorize @page_content.page, :update?\n\n respond_to do |format|\n if @page_content.update(page_content_params)\n format.json { render :show, status: :ok, location: @page_content }\n else\n format.json { render json: @page_content.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contentperpage.save\n format.html { redirect_to @contentperpage, notice: 'Contentperpage was successfully created.' }\n format.json { render :show, status: :created, location: @contentperpage }\n else\n format.html { render :new }\n format.json { render json: @contentperpage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_page(page_id, content, version: nil)\n info = page_info(page_id)\n version = info['version']['number'] + 1 if version.nil?\n log_debug \"Update Confluence page #{page_id}...\"\n call_api(\"rest/api/content/#{page_id}\", :put) do |request|\n request['Content-Type'] = 'application/json'\n request.body = {\n type: 'page',\n title: info['title'],\n body: {\n storage: {\n value: content,\n representation: 'storage'\n }\n },\n version: { number: version }\n }.to_json\n end\n end", "def update\n @page = current_cms.pages.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:big_cms_page])\n format.html { render :action => \"edit\" }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @page = ContentPage.find(params[:id])\n respond_to do |format|\n if @page.update_attributes(params[:content_page])\n @editingPage = false\n format.html { redirect_to show_content_pages_path(@page.id), notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { redirect_to edit_content_pages_path(@page.id), alert: 'Unable to update Page successfully.'}\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @content_page = ContentPage.find(params[:id])\n\n respond_to do |format|\n if @content_page.update_attributes(params[:content_page])\n format.html { redirect_to @content_page, notice: 'Content page has been updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @content_page.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @page_chunk = PageChunk.find(params[:id])\n #TODO: Not sure why \"undefined\" is a key.\n #TODO: multiple editable section on one page not working; the content for the last\n # is always \n @page_chunk.content = params[:content][:undefined][:value]\n @page_chunk.save!\n\n render text: \"\"\n=begin\n respond_to do |format|\n if @page_chunk.update(page_chunk_params)\n format.html { redirect_to @page_chunk, notice: 'Page chunk was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @page_chunk.errors, status: :unprocessable_entity }\n end\n end\n=end\n end", "def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.json { render json: @page.errors, status: :unprocessable_entity }\n format.xml { render xml: @page.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to [:admin, @page], notice: 'Страница успешно создана.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pagecontent = @page.pagecontents.find(params[:id])\n\n respond_to do |format|\n if @pagecontent.update_attributes(params[:pagecontent])\n flash[:notice] = 'Pagecontent was successfully updated.'\n format.html {redirect_to(page_pagecontents_path(@page)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pagecontent.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_page(page, content)\n path = create_path page\n $LOG.verbose \"Updating page with content '#{page.output_path}'\" if $LOG.verbose?\n payload = create_payload page, content\n patch path, payload\n end", "def update\n respond_to do |format|\n if @page_spec.update(page_spec_params)\n format.html { redirect_to @page_spec, notice: 'Page spec was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @page_spec.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pages_article = PagesArticle.find(params[:id])\n\n respond_to do |format|\n if @pages_article.update_attributes(params[:pages_article])\n format.html { redirect_to @pages_article, notice: 'Pages article was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pages_article.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pages_has_article = PagesHasArticle.find(params[:id])\n\n respond_to do |format|\n if @pages_has_article.update_attributes(params[:pages_has_article])\n format.html { redirect_to @pages_has_article, notice: 'Pages has article was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pages_has_article.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @nested_page = Nested::Page.find(params[:id])\n\n respond_to do |format|\n if @nested_page.update_attributes(params[:nested_page])\n format.html { redirect_to @nested_page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @nested_page.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cms_page = CmsPage.find(params[:id])\n params[:cms_page][:parent_id] = 0 if params[:cms_page][:parent_id].blank?\n respond_to do |format|\n if @cms_page.update_attributes(params[:cms_page])\n expire_page \"/#{@cms_page.path}\"\n flash[:notice] = 'CMS Page was successfully updated.'\n format.html { redirect_to(['admin', @cms_page]) }\n format.xml { head :ok }\n else\n\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cms_page.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @page = current_user.pages.with_slug!(params[:id])\n @page.attributes = params[:page]\n\n respond_to do |format|\n if @page.valid?\n @page.sections.destroy_all\n @page.update_attributes(params[:page])\n format.html { redirect_to @page, :notice => 'Page was successfully updated.' }\n format.json { render :json => {} }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @page.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cms_page.update(cms_page_params)\n format.html { redirect_to @cms_page, notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @cms_page }\n else\n format.html { render :edit }\n format.json { render json: @cms_page.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cms_page.update(cms_page_params)\n format.html { redirect_to admin_pages_path, notice: 'Cms page was successfully updated.' }\n format.json { render :show, status: :ok, location: @cms_page }\n else\n format.html { render :edit }\n format.json { render json: @cms_page.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /contentperpages/1 DELETE /contentperpages/1.json
def destroy @contentperpage.destroy respond_to do |format| format.html { redirect_to contentperpages_url, notice: 'Contentperpage was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @content_page = ContentPage.find(params[:id])\n @content_page.destroy\n\n respond_to do |format|\n format.html { redirect_to content_pages_url }\n format.json { head :no_content }\n end\n end", "def delete_page(id)\n @client.raw('delete', \"/content/pages/#{id}\")\n end", "def destroy\n @page = current_cms.pages.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(big_cms_pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @pagecount.destroy\n respond_to do |format|\n format.html { redirect_to pagecounts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_page = Admin::Page.find(params[:id])\n @admin_page.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_page_sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end", "def destroy\n @page = Page.get(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page_chunk.destroy\n respond_to do |format|\n format.html { redirect_to page_chunks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pagecontent = @page.pagecontents.find(params[:id])\n @pagecontent.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_pagecontents_path(@page)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @page_content = PageContent.find(params[:id])\n @page_content.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_contents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @nested_page = Nested::Page.find(params[:id])\n @nested_page.destroy\n\n respond_to do |format|\n format.html { redirect_to nested_pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @doc_page = DocPage.find(params[:id])\n @doc_page.destroy\n\n respond_to do |format|\n format.html { redirect_to doc_pages_url }\n format.json { head :no_content }\n end\n end", "def destroy_rest\n @page_usage = PageUsage.find(params[:id])\n @page_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_usages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @content_page = ContentPage.find(params[:id])\n @content_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(content_pages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @r_pages_to_entry.destroy\n respond_to do |format|\n format.html { redirect_to r_pages_to_entries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pages_article = PagesArticle.find(params[:id])\n @pages_article.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_articles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page_section = Admin::PageSection.find(params[:id])\n @page_section.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_page_sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page_fetch = PageFetch.find(params[:id])\n @page_fetch.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_fetches_url) }\n format.xml { head :ok }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds authentication information to the request based on the challenge from the response.
def respond_to_challenge(request, response) authenticate_header = response['www-authenticate'].downcase authenticate_header.sub!(/^digest /, '') @authentication_params = authenticate_header.split(", ").inject({}) { |h, field| key, value = field.split("=") h[key] = value.gsub(/^"|"$/, '') # strip quotes. h } add_cookies!(request) authenticate_request!(request) request.each{|k,v| puts "#{k}: #{v}" } # Resend the request @client.request(request) end
[ "def add_authentication(_, request)\n request.headers['X-User-Email'] = self.class.api_user_email\n request.headers['X-User-Token'] = self.class.api_token\n end", "def continue_with_auth(request_id:, auth_challenge_response:)\n {\n method: \"Fetch.continueWithAuth\",\n params: { requestId: request_id, authChallengeResponse: auth_challenge_response }.compact\n }\n end", "def handle_authentication_response(response)\n result = { }\n\n response.body.each_line do |line|\n if line.include? '='\n line.chomp!\n key, value = line.split('=')\n result[key] = value\n end\n end\n\n result\n end", "def challenge\n decode_challenge\n respond\n end", "def challenge\n @challenge = decode_challenge\n respond\n end", "def require_authentication( challenge )\n\t\tfinish_with( HTTP::AUTH_REQUIRED, \"Requires authentication.\", www_authenticate: challenge )\n\tend", "def challengeauth(m, challenge)\n # Q is the only trusted user.\n return unless m.user && m.user.nick == 'Q'\n\n debug I18n.identify.challenge(challenge)\n\n username = config[:username].irc_downcase(:rfc1459)\n password = config[:password][0, 10]\n\n sha256 = OpenSSL::Digest::SHA256.new\n key = sha256.hexdigest(\"#{ username }:#{ sha256.hexdigest(password) }\")\n response = OpenSSL::HMAC.hexdigest('SHA256', key, challenge)\n User(Q).privmsg(\"CHALLENGEAUTH #{ username } #{ response } HMAC-SHA-256\")\n end", "def header(response)\n uri = response.env[:url]\n uri.user = CGI.escape @user\n uri.password = CGI.escape @password\n\n realm = response.headers['www-authenticate']\n method = response.env[:method].to_s.upcase\n\n Net::HTTP::DigestAuth.new.auth_header(uri, realm, method)\n end", "def auth_response\n @auth_response ||= self.authenticate\n end", "def sign_response(challenge)\n client_data_json = client_data(::U2F::ClientData::AUTHENTICATION_TYP, challenge)\n JSON.dump(\n clientData: ::U2F.urlsafe_encode64(client_data_json),\n keyHandle: ::U2F.urlsafe_encode64(key_handle_raw),\n signatureData: auth_signature_data(client_data_json)\n )\n end", "def prepare_basic_auth(request)\n user = @options[:user] || nil\n pass = @options[:pass] || nil\n\n request.basic_auth user, pass\n request\n end", "def handle_login_challenge_response(response_data)\n if k = response_data['k']\n enc_master_key = base64_to_a32(k)\n self.master_key = decrypt_key(enc_master_key, password_key)\n end\n if privk = response_data['privk']\n self.rsa_private_key = decrypt_base64_to_str(privk, master_key)\n self.decomposed_rsa_private_key = decompose_rsa_private_key(rsa_private_key)\n if csid = response_data['csid']\n self.sid = decrypt_session_id(csid,decomposed_rsa_private_key)\n end\n end\n end", "def process_type1_auth(ntlm, request, response)\n t1 = request.ntlm_token\n t2 = ntlm.accept_security_context(t1)\n\n response.start(401) do |head,out|\n head['WWW-Authenticate'] = \"NTLM #{t2}\"\n end\n \n response.ntlm_finished\n end", "def authenticate(request)\n request.basic_auth @username, @password\n end", "def unpack_challenge(authenticate)\n if authenticate =~ /Basic\\srealm=\\\"([^\\\"]*)\\\"/\n return Regexp.last_match[1]\n else\n if authenticate =~ /^Basic/\n fail(UnwellformedHeader, \"Can't parse the WWW-Authenticate header, it's probably not well formed\")\n else\n fail(ArgumentError, 'HTTPAuth::Basic can only unpack Basic Authentication headers')\n end\n end\n end", "def basic_authentication usr, pwd\n\t\tstr = [\"#{usr}:#{pwd}\"].pack(\"*m\")\n\t\tstr = \"Basic #{str}\"\n\t\t@request_headers[\"Authorization\"]=str\n\tend", "def auth_method(response)\n response['WWW-Authenticate'].strip.split(' ')[0].downcase.to_sym\n end", "def response_for_inauthentic_request(env)\n handle_head(env) do\n body = { 'errors' => { 'mauth' => ['Unauthorized'] } }\n [401, { 'Content-Type' => 'application/json' }, [JSON.pretty_generate(body)]]\n end\n end", "def send_auth(res, opts, t, persist)\n if opts['username'].nil? or opts['username'] == ''\n if self.username and not (self.username == '')\n opts['username'] = self.username\n opts['password'] = self.password\n else\n opts['username'] = nil\n opts['password'] = nil\n end\n end\n\n return res if opts['username'].nil? or opts['username'] == ''\n supported_auths = res.headers['WWW-Authenticate']\n\n # if several providers are available, the client may want one in particular\n preferred_auth = opts['preferred_auth']\n\n if supported_auths.include?('Basic') && (preferred_auth.nil? || preferred_auth == 'Basic')\n opts['headers'] ||= {}\n opts['headers']['Authorization'] = basic_auth_header(opts['username'],opts['password'] )\n req = request_cgi(opts)\n res = _send_recv(req,t,persist)\n return res\n elsif supported_auths.include?('Digest') && (preferred_auth.nil? || preferred_auth == 'Digest')\n temp_response = digest_auth(opts)\n if temp_response.kind_of? Rex::Proto::Http::Response\n res = temp_response\n end\n return res\n elsif supported_auths.include?('NTLM') && (preferred_auth.nil? || preferred_auth == 'NTLM')\n opts['provider'] = 'NTLM'\n temp_response = negotiate_auth(opts)\n if temp_response.kind_of? Rex::Proto::Http::Response\n res = temp_response\n end\n return res\n elsif supported_auths.include?('Negotiate') && (preferred_auth.nil? || preferred_auth == 'Negotiate')\n opts['provider'] = 'Negotiate'\n temp_response = negotiate_auth(opts)\n if temp_response.kind_of? Rex::Proto::Http::Response\n res = temp_response\n end\n return res\n end\n return res\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Shorthand for "public && public_write"
def fully_public? public && public_write end
[ "def public?\n rights == 'public'\n end", "def public_writer?\n options[:writer] == :public\n end", "def public_write! if_metageneration_match: nil\n update_predefined_acl! \"publicReadWrite\", if_metageneration_match: if_metageneration_match\n end", "def writable?() end", "def public?\r\n is? ACC_PUBLIC\r\n end", "def public?\n self.privacy == PUBLIC\n end", "def public_writer?\n @writer_visibility == :public\n end", "def public?\r\n is_live and !priv? and !draft?\r\n end", "def public_reader?\n options[:reader] == :public\n end", "def write?(person, client)\n return read?(person, client) && (owner == person || ! read_only || (!person.nil? && person.moderator?(client)))\n end", "def public?\n @public\n end", "def everyone(read, write)\n apply(PUBLIC, read, write)\n permissions[PUBLIC]\n end", "def set_public_write(value)\n value = value ? true : false\n update_attributes public_write: value\n # save\n end", "def is_writeable_by( user ) \n self.accepts_role? :owner, user\n end", "def writable?\n new? ? (root? || parent.access?(:create)) : access?(:write)\n end", "def writable(*fields)\n added_fields = add_fields(@write_mask,\"writable\",fields)\n allow(*fields)\n @write_mask = added_fields if(@write_mask.eql?(WILDCARD))\n added_fields\n end", "def is_public?\n return true if self.statut == \"public\"\n end", "def public?( revset=nil )\n\t\treturn self.phase( revset ).values.all?( :public )\n\tend", "def writer?(user)\n public_write || permitted?(writers_join_table, user)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as +format_name+ but with id tacked on.
def unique_format_name string_with_id(format_name) end
[ "def unique_format_name\n format_name + \" (#{id || \"?\"})\"\n end", "def unique_partial_format_name\n string_with_id(partial_format_name)\n end", "def format_identifier\n self.identifier.to_s\n end", "def format_identifier\n self.identifier.to_s\n end", "def format_name\n return self.name\n end", "def formatted_id\n sprintf(\"job_%010d\", id)\n end", "def id_format(object)\n object.id_format || object.self_link_uri\n end", "def id2name() end", "def format_identifier(identifier)\n identifier.empty? ? identifer : \"|%s|\" % identifier\n end", "def to_s\n id.nil? ? name : \"#{name}:#{id}\"\n end", "def unique_format_name\n title = all_subjects.map(&:format_name).uniq.sort.join(\" & \")\n if title.blank?\n :image.l + \" ##{id || \"?\"}\"\n else\n title + \" (#{id || \"?\"})\"\n end\n end", "def idify\n \"#{self.group.name.gsub(/[ ]/, '').underscore}_#{self.name.gsub(/[ ]/, '').underscore}\"\n end", "def format_key\n formats = CustomFields::AutoNumbering.format_parts(self.format)\n\n formats.select{|f| (f =~ /(\"|#)/).nil? }.join('-')\n end", "def id_to_name\n @id_to_name ||= build_hash('id', 'name')\n end", "def make_id_to_name\n build_hash('id', 'name')\n end", "def id\n \"field_#{name}\"\n end", "def format_id(id)\n /(\\d+)/.match(id)\n end", "def make_id\n \"#{self.class.name.downcase}#{id}\"\n end", "def idfy(name)\n name = 'x' + name unless /^[a-zA-Z]/ =~ name\n name.scan(/[-a-zA-Z0-9_:.]+/).join('_')\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as +partial_text_name+ but with id tacked on.
def unique_partial_text_name string_with_id(partial_text_name) end
[ "def unique_text_name\n text_name + \" (#{id || \"?\"})\"\n end", "def get_full_name_with_id\n \"#{editable_name} (#{id})\"\n end", "def text_with_id( text, id )\n assert_not text.nil?\n assert_not id.nil?\n assert text.is_a? String\n assert id.is_a? Integer\n \"#{ text } [#{ id }]\"\n end", "def label_with_id\n text_and_id( :label )\n end", "def full_name_id\n \"#{last_name}, #{first_name} (DON#{id})\"\n end", "def display_name\n if original_name.nil?\n id\n else\n original_name.text.nil? ? id: original_name.text\n end\n end", "def append_name_with_id\n tname = get_testcase_name\n #Remove data drivern label from tc name\n tname.gsub!(/\\[.*\\]/, \"\")\n tl_id = Common.get_testlink_id(tname)\n tc_name = name\n tc_name = tc_name.insert(-2, \":#{FWConfig::TESTLINK_PROJECT_PREFIX}#{tl_id}\")\n end", "def id\n \"field_#{name}\"\n end", "def unique_partial_format_name\n string_with_id(partial_format_name)\n end", "def full_name_with_id\n id.to_s + \": \" + first_name + \" \" + last_name\n end", "def name(quest_id = Class)\n return super() if quest_id == Class\n\n return nil.to_s unless id_valid?(quest_id)\n return text_get(45, quest_id)\n end", "def id2name() end", "def process_partial name, args, line\n if name == \"\" or !(string? name or symbol? name)\n return\n end\n\n names = name.value.to_s.split(\"/\")\n names[-1] = \"_\" + names[-1]\n process_template template_name(names.join(\"/\")), args, nil, line\n end", "def partial; self.class.name.underscore; end", "def html_id!\n gsub!(/[^0-9a-zA-Z\\-_]/, '_')\n prepend('a') if self[0] !~ /[a-zA-Z]/\n self\n end", "def residential_complex_name(id)\n unless where(:id => id).empty?\n where(:id => id).first.name\n end\n end", "def full_name_with_id\n id.to_s + \": \" + user.first_name + \" \" + user.last_name\n end", "def iname=(text)\n replace_element_text('name', text.nil? ? '' : text)\n end", "def text_name\n display_name.to_s\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Same as +partial_format_name+ but with id tacked on.
def unique_partial_format_name string_with_id(partial_format_name) end
[ "def unique_format_name\n format_name + \" (#{id || \"?\"})\"\n end", "def unique_format_name\n string_with_id(format_name)\n end", "def format_identifier\n self.identifier.to_s\n end", "def format_identifier\n self.identifier.to_s\n end", "def get_full_name_with_id\n \"#{editable_name} (#{id})\"\n end", "def format_name\n return self.name\n end", "def custom_humanize\n end_with?('_id') ? (humanize + \" ID\") : humanize\n end", "def full_name_with_id\n id.to_s + \": \" + first_name + \" \" + last_name\n end", "def full_name_id\n \"#{last_name}, #{first_name} (DON#{id})\"\n end", "def unique_partial_text_name\n string_with_id(partial_text_name)\n end", "def format_identifier(identifier)\n identifier.empty? ? identifer : \"|%s|\" % identifier\n end", "def fname_for(id)\n \"#{fprefix(id)}.json\"\n end", "def unique_format_name\n title = all_subjects.map(&:format_name).uniq.sort.join(\" & \")\n if title.blank?\n :image.l + \" ##{id || \"?\"}\"\n else\n title + \" (#{id || \"?\"})\"\n end\n end", "def formatted_id\n sprintf(\"job_%010d\", id)\n end", "def id2name() end", "def id_format(object)\n object.id_format || object.self_link_uri\n end", "def id\n \"field_#{name}\"\n end", "def idify\n \"#{self.group.name.gsub(/[ ]/, '').underscore}_#{self.name.gsub(/[ ]/, '').underscore}\"\n end", "def partial_format(string, substitutions); end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a Hash containing all the descriptive text fields. (See also the counterpart writermethod +all_notes=+.)
def all_notes result = {} self.class.all_note_fields.each do |field| value = send(field).to_s result[field] = value.presence end result end
[ "def fields_description\n\t\treturn self.class.fields.keys.collect do |name|\n\t\t\tval = self.instance_variable_get( \"@#{name}\" )\n\t\t\t\"%s: %s\" % [\n\t\t\t\tname,\n\t\t\t\ttruncate_string( val.inspect, 20 )\n\t\t\t]\n\t\tend.join( ' ' )\n\tend", "def personal_information\n hash = {}\n frm.table(:class=>\"chefEditItem\", :index=>1).rows.each do |row|\n hash.store(row[0].text, row[1].text)\n end\n return hash\n end", "def get_summary\n unless valid?\n return {\n :Type => '',\n :Subtype => '',\n :Key => '',\n :Name => '',\n }\n end\n fields = {}\n fields[:Type], fields[:Subtype] = rec_type_str(',', true).split(',')\n type = fields[:Type].downcase\n\n fields_xpath = [\n # [:HASH_KEY, [XPATH_FOR_OBJECT, XPATH_FOR_DELETED_OBJECT] ]\n [ :Key,\n [\"registryObjects/registryObject/key\", \"header/identifier\" ],\n ],\n [ :Name,\n [\"registryObjects/registryObject/[[PRIMARY_RECORD_TYPE_TAG]]/name/namePart\", \"\" ],\n ],\n ]\n\n is_deleted_index = @rec_type == REC_TYPE_DELETED ? 1 : 0\n\n fields_xpath.each{|ref, xpaths|\n text_elements = []\n xpath_str = xpaths[is_deleted_index].gsub(XPATH_PRIMARY_RECORD_TYPE_TAG, type)\n @doc.elements.each(xpath_str.to_s_xpath){|e| text_elements << e.text}\n fields[ref] = text_elements.join(', ')\n }\n fields\n end", "def humanise_metadata\n\n out = {}\n @md.each_pair do |key, val|\n out[humanise_attribute_name(key).to_sym] = val\n end\n\n out\n\n end", "def public_information\n hash = {}\n frm.table(:class=>\"chefEditItem\", :index=>0).rows.each do |row|\n hash.store(row[0].text, row[1].text)\n end\n return hash\n end", "def details\n {\n change_note: edition.most_recent_change_note,\n tags: {\n browse_pages: [],\n topics: specialist_sectors,\n }\n }\n end", "def details\n details = {}\n frm.table(:class=>\"itemSummary\").rows.each do |row|\n details.store(row.th.text, row.td.text)\n end\n return details\n end", "def descriptions\n @descriptions ||= {}\n end", "def metadata\n out_hash = {}.with_indifferent_access\n %i[doi upload_type publication_date title creators description access_right license\n keywords notes related_identifiers method locations communities].each do |meth|\n next if meth == 'doi' && @use_zenodo_doi\n\n result = send(meth)\n out_hash[meth] = result unless result.blank?\n end\n out_hash\n end", "def formatted_metadata\n metadata = {}\n \n METADATA_FIELDS.each { |f| metadata[f] = send(f) }\n \n format_hash(metadata.reject { |k,v| v.nil? })\n end", "def asciidoc_attributes\n { 'author' => author_name,\n 'email' => author_email,\n 'project-name' => project_name,\n 'package-name' => package_name,\n 'package-version' => version,\n 'package-description' => description,\n 'package-summary' => summary,\n 'project-url' => project_url \n }.reject{|k,v| v.nil? }\n end", "def basic_info_data\n hash = {}\n target_div = self.div(:class=>\"s3d-contentpage-title\", :text=>\"Basic Information\").parent.parent.div(:id=>\"displayprofilesection_body\")\n target_div.divs(:class=>\"displayprofilesection_field\").each { |div| hash.store(div.span(:class=>\"s3d-input-label\").text, div.span(:class=>\"field_value\").text) }\n return hash\n end", "def descriptions\n @timing_hash.keys\n end", "def get_qc_field_descriptions\n @qc_field_descs = {}\n QcFieldDescription.all.each do |desc|\n @qc_field_descs[ desc.qc_field.to_sym ] = desc\n end\n end", "def metadata\n out_hash = {}.with_indifferent_access\n %i[doi upload_type publication_date title creators description access_right license\n keywords notes related_identifiers method locations communities].each do |meth|\n next if meth == 'doi' && @dataset_type != :data\n\n result = send(meth)\n out_hash[meth] = result unless result.blank?\n end\n out_hash\n end", "def general_metadata_hash\r\n metadata = Hash.new\r\n metadata[:filename] = @datafile.file_file_name\r\n metadata[:downloads] = 0\r\n\r\n metadata[:title] = clean_string(general_metadata_sheet[*WBF[:meta_title_pos]])\r\n metadata[:abstract] = clean_string(general_metadata_sheet[*WBF[:meta_abstract_pos]])\r\n metadata[:comment] = clean_string(general_metadata_sheet[*WBF[:meta_comment_pos]])\r\n metadata[:usagerights] = clean_string(general_metadata_sheet[*WBF[:meta_usagerights_pos]])\r\n metadata[:published] = clean_string(general_metadata_sheet[*WBF[:meta_published_pos]])\r\n metadata[:spatialextent] = clean_string(general_metadata_sheet[*WBF[:meta_spatial_extent_pos]])\r\n metadata[:temporalextent] = clean_string(general_metadata_sheet[*WBF[:meta_temporalextent_pos]])\r\n metadata[:taxonomicextent] = clean_string(general_metadata_sheet[*WBF[:meta_taxonomicextent_pos]])\r\n metadata[:design] = clean_string(general_metadata_sheet[*WBF[:meta_design_pos]])\r\n metadata[:dataanalysis] = clean_string(general_metadata_sheet[*WBF[:meta_dataanalysis_pos]])\r\n metadata[:circumstances] = clean_string(general_metadata_sheet[*WBF[:meta_circumstances_pos]])\r\n return metadata\r\n end", "def extra_description\n attributes_description + content_description + count_description\n end", "def non_pdf_metadata_fields\n [:create_date, :has_model, :representative, :depositor, :relative_path, :import_url,\n :date_uploaded, :date_created, :date_modified, :modified_date, :source_metadata,\n :viewing_direction, :viewing_hint]\n end", "def description\n description = {}\n for name in @hash.keys\n text = @hash[name].last.description\n if @hash[name].last.depends and @hash[name].last.depends.length > 0\n depends = ' [' + @hash[name].last.depends.join(', ') + ']'\n else\n depends = nil\n end\n description[name] = (text ? text : '') + (depends ? depends : '')\n end\n return description\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Update all the descriptive text fields via Hash. hash = name.all_notes hash[:look_alikes] = "new value" name.all_notes = hash
def all_notes=(notes) self.class.all_note_fields.each do |field| send("#{field}=", notes[field]) end end
[ "def notes=(value)\n @notes = value\n end", "def add_hike_details\r\n WashingtonHikes::Scraper.scrape_wta_hike_description(self.url).each {|key, value| self.send((\"#{key}=\"), value)}\r\n end", "def set_NotesInfo(value)\n set_input(\"NotesInfo\", value)\n end", "def notes=(notes)\n self.service.editObject({ \"notes\" => notes.to_s })\n self.refresh_details()\n end", "def personal_notes=(value)\n @personal_notes = value\n end", "def notes=(new_notes)\n\t\t\t@notes = new_notes.clone\n\t\tend", "def []=(key, value)\n\t\t\t@notes[key] = value\n\t\tend", "def person_notes=(value)\n @person_notes = value\n end", "def changing_alan\n\tprogrammer_hash = \n \t\t{\n :grace_hopper => {\n :known_for => \"COBOL\",\n :languages => [\"COBOL\", \"FORTRAN\"]\n },\n :alan_kay => {\n :known_for => \"Object Orientation\",\n :languages => [\"Smalltalk\", \"LISP\"]\n },\n :dennis_ritchie => {\n :known_for => \"Unix\",\n :languages => [\"C\"]\n }\n }\n #change what Alan Kay is :known_for to the value of the alans_new_info variable. \n alans_new_info = \"GUI\"\n programmer_hash[:alan_kay][:known_for] = alans_new_info\n \n # Return changed hash\n programmer_hash\nend", "def setNotes(notes)\r\n\t\t\t\t\t@notes = notes\r\n\t\t\t\tend", "def update_answer_hash(standards={},text=\"\")\r\n h = {}\r\n h['standards'] = standards\r\n h['text'] = text\r\n self.text = h.to_json\r\n end", "def add_attribute_changed_notes\n if self.valid?\n # 'advance_charge_paid' attribute\n if self.advance_charge_paid_changed?\n charge_paid_note = self.advance_charge_paid? ?\n I18n.t(\"views.pickup_order.advance_charges_paid\").capitalize :\n I18n.t(\"views.pickup_order.advance_charges_not_paid\").capitalize\n self.add_note(Note::RECORD_UPDATE, NoteType::NOTE_TYPE_CODE_LOT, charge_paid_note, Employee.current, true)\n end\n\n # If any holds were added (pickup or sale holds), add the appropriate system note(s).\n if self.hold_for_pickup_changed? && !self.hold_for_pickup_change.any?(&:nil?)\n note_text =\n if self.hold_for_pickup?\n (I18n.t(\"controllers.vehicle.notes.pickup_hold_added_for\") +\n \" #{self.hold_for_pickup_date.strftime('%-d.%-m.%Y')}.<br/>\" +\n I18n.t(\"controllers.vehicle.notes.reason\") +\n \": #{self.hold_for_pickup_reason}\")\n else\n I18n.t(\"controllers.vehicle.notes.pickup_hold_removed\")\n end\n self.add_note(Note::RECORD_UPDATE, NoteType::NOTE_TYPE_CODE_LOT, note_text, Employee.current, true)\n end\n if self.hold_for_sale_changed? && !self.hold_for_sale_change.any?(&:nil?)\n note_text =\n if self.hold_for_sale?\n (I18n.t(\"controllers.vehicle.notes.sale_hold_added_for\") +\n \" #{self.sale_hold_action_date.strftime('%-d.%-m.%Y')}.<br/>\" +\n I18n.t(\"controllers.vehicle.notes.reason\") +\n \": #{self.sale_hold_comment}\")\n else\n I18n.t(\"controllers.vehicle.notes.sale_hold_removed\")\n end\n self.add_note(Note::RECORD_UPDATE, NoteType::NOTE_TYPE_CODE_LOT, note_text, Employee.current, true)\n end\n\n # If any holds (pickup or sale) are present and the hold date was changed, add a system note.\n if self.hold_for_pickup_date_changed? && !self.hold_for_pickup_date_change.any?(&:nil?)\n note_text =\n I18n.t(\"controllers.vehicle.notes.pickup_hold_date_changed\",\n original_date: self.hold_for_pickup_date_change[0].strftime(\"%-d.%-m.%Y\"),\n new_date: self.hold_for_pickup_date_change[1].strftime(\"%-d.%-m.%Y\"))\n self.add_note(Note::RECORD_UPDATE, NoteType::NOTE_TYPE_CODE_LOT, note_text, Employee.current, true)\n end\n if self.sale_hold_action_date_changed? && !self.sale_hold_action_date_change.any?(&:nil?)\n note_text =\n I18n.t(\"controllers.vehicle.notes.sale_hold_date_changed\",\n original_date: self.sale_hold_action_date_change[0].strftime(\"%-d.%-m.%Y\"),\n new_date: self.sale_hold_action_date_change[1].strftime(\"%-d.%-m.%Y\"))\n self.add_note(Note::RECORD_UPDATE, NoteType::NOTE_TYPE_CODE_LOT, note_text, Employee.current, true)\n end\n\n # Add a system note if the high bid amount has been changed.\n if self.high_bid_amount_changed?\n original_high_bid = (self.yard.present? && self.yard.facility.present? && self.yard.facility.address.present? && self.yard.facility.address.country.present?) ?\n number_to_currency(self.high_bid_amount_change[0] || 0.0, precision: 2, unit: self.yard.facility.address.country.currency) :\n number_to_currency(self.high_bid_amount_change[0] || 0.0, precision: 2)\n new_high_bid = (self.yard.present? && self.yard.facility.present? && self.yard.facility.address.present? && self.yard.facility.address.country.present?) ?\n number_to_currency(self.high_bid_amount_change[1] || 0.0, precision: 2, unit: self.yard.facility.address.country.currency) :\n number_to_currency(self.high_bid_amount_change[1] || 0.0, precision: 2)\n self.add_note(Note::RECORD_UPDATE, NoteType::NOTE_TYPE_CODE_LOT,\n I18n.t(\"controllers.vehicle.notes.high_bid_amount_changed\",\n original_high_bid: original_high_bid, new_high_bid: new_high_bid),\n Employee.current, true)\n end\n\n # Add a system note if the member has been changed.\n if self.member_id_changed?\n=begin\n original_member = Member.find_by_id(self.member_id_change[0])\n new_member = Member.find_by_id(self.member_id_change[1])\n if original_member.present? && new_member.present?\n note_text = I18n.t(\"controllers.vehicle.notes.member_changed\",\n original_member: \"<a href='#{member_path(original_member)}' target='_blank'>#{original_member.display_name} (##{original_member.member_uid})</a>\",\n new_member: \"<a href='#{member_path(new_member)}' target='_blank'>#{new_member.display_name} (##{new_member.member_uid})</a>\")\n self.add_note(Note::RECORD_UPDATE, NoteType::NOTE_TYPE_CODE_LOT, note_text, Employee.current, true)\n end\n=end\n end\n end\n end", "def update_answer_hash(standards = {}, text = '')\n h = {}\n h['standards'] = standards\n h['text'] = text\n self.text = h.to_json\n end", "def set_Notes(value)\n set_input(\"Notes\", value)\n end", "def update_attributes\n find_postlike.update_attributes(\n name: request_body[\"title\"],\n description: request_body[\"body\"],\n date: request_body[\"date\"],\n start_time: request_body[\"starts_at\"],\n end_time: request_body[\"ends_at\"],\n venue: request_body[\"venue\"],\n address: request_body[\"address\"],\n tag_list: request_body[\"tags\"])\n end", "def updateNote(key,noteText)\n refreshToken\n path = \"/api/note?key=#{key}\\&auth=#{@token}\\&email=#{@email}&modify=#{ERB::Util.url_encode(Time.now.strftime(\"%Y-%m-%d %H:%M:%S\"))}\"\n data = noteText\n payload = Base64.encode64(data)\n response, data = agent.post(path,payload)\n\n unless response.code.to_i == 200\n raise \"Failed to update Note \\'#{key}\\'\"\n end\n return response.body\n end", "def edit_joke\n joke = find_my_joke\n if joke\n new_setup = CLI.prompt(\"\\nPlease enter your new setup, with changes:\")\n new_punchline = CLI.prompt(\"Please enter your new punchline, with changes:\")\n new_topic = CLI.prompt(\"Your topic was #{joke.topic.topic}. Please enter an updated topic:\")\n joke.update(setup: new_setup, punchline: new_punchline, topic: Topic.find_or_create_by(topic: new_topic))\n puts \"Thanks! We've updated your joke!\\n\\n\"\n else\n puts \"Sorry, we can't find your joke!\\n\\n\"\n end\n end", "def update_attributes\n find_postlike.update_attributes(\n title: request_body[\"title\"],\n description: request_body[\"body\"],\n price_in_cents: request_body[\"price\"]\n )\n end", "def set_Notes(value)\n set_input(\"Notes\", value)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find out how much descriptive text has been written for this object. Returns the number of fields filled in, and how many characters total. num_fields, total_length = name.note_status
def note_status field_count = size_count = 0 all_notes.each_value do |v| if v.present? field_count += 1 size_count += v.strip_squeeze.length end end [field_count, size_count] end
[ "def description_length(pr)\n pull_req = pull_req_entry(pr)\n title = unless pull_req['title'].nil? then pull_req['title'] else ' ' end\n body = unless pull_req['body'].nil? then pull_req['body'] else ' ' end\n (title + ' ' + body).gsub(/[\\n\\r]\\s+/, ' ').split(/\\s+/).size\n end", "def name_length\n name.length\n end", "def length\n @length ||= self.name.size\n end", "def full_name_length\n @full_name_length ||= @data[88, 4].unpack('N*')[0]\n end", "def text_number_of_chars\n @text.text.number_of_chars\n end", "def num_fields\n @fields.size\n end", "def num_fields\n fields.length\n end", "def description_complexity(build)\n pull_req = pull_req_entry(build[:pull_req_id])\n (pull_req['title'] + ' ' + pull_req['body']).gsub(/[\\n\\r]\\s+/, ' ').split(/\\s+/).size\n end", "def note_count\n @notes.size\n end", "def description_complexity(pr)\n pull_req = pull_req_entry(pr[:id])\n (pull_req['title'] + ' ' + pull_req['body']).gsub(/[\\n\\r]\\s+/, ' ').split(/\\s+/).size\n end", "def message_length; complete_message.length; end", "def default_field_lengths\n field_lengths = @headers ? @headers.inject({}) {|h,(k,v)| h[k] = String.size(v); h} :\n @fields.inject({}) {|h,e| h[e] = 1; h }\n @rows.each do |row|\n @fields.each do |field|\n len = String.size(row[field])\n field_lengths[field] = len if len > field_lengths[field].to_i\n end\n end\n field_lengths\n end", "def length\n return @fields_update.length\n end", "def text_length\n @text_length ||= @data[4, 4].unpack('N*')[0]\n end", "def length\n text.length\n end", "def number_of_characters\n @text.length\n end", "def default_field_lengths\n field_lengths = @headers ? @headers.inject({}) {|h,(k,v)| h[k] = String.size(v); h} : {}\n @rows.each do |row|\n @fields.each do |field|\n len = String.size(row[field])\n field_lengths[field] = len if len > field_lengths[field].to_i\n end\n end\n field_lengths\n end", "def get_length_stats\n total_input_length = statuses.reduce(0) {|total, status| status.input_length.nil? ? total : (total + status.input_length)}\n green_length = statuses.inject(0) {|total, status| status.green? ? total + status.entity.length : total}\n green_length_percent = 0\n green_length_percent = green_length / total_input_length * 100 if total_input_length > 0\n return total_input_length, green_length, green_length_percent\n end", "def field_count\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retreive object representing the source (if applicable). Presently, this only works for Project drafts and User's personal descriptions. All others return +nil+.
def source_object case source_type # (this may eventually be replaced with source_id) when "project" then project when "source" then nil # (haven't created "Source" model yet) when "user" then user end end
[ "def source_object\n Source.find_by_name(source)\n end", "def source\n @sources.first if defined?(@sources)\n end", "def source\n @source ||= PublicEarth::Db::Source.for_user(self)\n end", "def external_source_detail\n return @external_source_detail\n end", "def source_get\n db_select 'source'\n end", "def source\n @source ||= @application.klass_by_name(@association.active_record.name)\n end", "def initialize_description_source\n @description.license = @user.license\n\n # Creating a draft.\n if params[:project].present?\n project = Project.find(params[:project])\n if @user.in_group?(project.user_group)\n @description.source_type = \"project\"\n @description.source_name = project.title\n @description.project = project\n @description.public = false\n @description.public_write = false\n else\n flash_error(:runtime_create_draft_create_denied.\n t(title: project.title))\n redirect_to(project_path(project.id))\n end\n\n # Cloning an existing description. Only occurs on names?\n elsif params[:clone].present?\n clone = find_description!(params[:clone])\n if in_admin_mode? || clone.is_reader?(@user)\n @description.all_notes = clone.all_notes\n @description.source_type = \"user\"\n @description.source_name = \"\"\n @description.project_id = nil\n @description.public = false\n @description.public_write = false\n else\n flash_error(:runtime_description_private.t)\n redirect_to(name_path(@description.parent_id))\n end\n\n # Otherwise default to \"public\" description.\n else\n @description.source_type = \"public\"\n @description.source_name = \"\"\n @description.project_id = nil\n @description.public = true\n @description.public_write = true\n end\n end", "def object\n find.first\n end", "def content_source\n return @content_source\n end", "def source_review\n @source_review || (SourceReview.find_by_source_id_and_member_id(self.story.primary_source.id, self.member.id) if self.story && self.story.primary_source && self.member)\n end", "def source\n @source || link()\n end", "def external_source\n return @external_source\n end", "def source\n (input.respond_to?(:source) && input.source) || input\n end", "def get_source( source_id )\n log_message( \"Getting source #{source_id}...\" ) unless @logging == false\n @connection.get( \"source/#{source_id}\" )\n end", "def relevant_id\n @source.respond_to?(:id) ? @source.id : @source.object_id\n end", "def source\n result_hash['src']\n end", "def find_source_entry\n @source_entry = SourceGlossaryEntry.find params[:source_id]\n end", "def source_object_name\n return @source_object_name\n end", "def source\n IITSource.new(@ole.Source)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Does this Description belong to a given Project?
def belongs_to_project?(project) (source_type == "project") && (project_id == project.id) end
[ "def project?\n course_type_name == \"project\"\n end", "def has_project?\n !project_id.nil? && project.visible\n end", "def construction_project?\n self.category_ids.include?(4)\n end", "def is_for_project?\n not self.project.nil?\n end", "def is_assigned?(project)\n projects.include?(project)\n end", "def project?\n true\n end", "def project_exists?(name)\n projects.include?(name)\n end", "def has_project?(name)\n available_projects.has_key?(name)\n end", "def package_project_valid?\n Project.first(:code => metadata[\"dmd-project\"], :account => {:code => metadata[\"dmd-account\"]}) != nil\n end", "def exists? machinename\n\t\tproject = @projects.read ['id'], ['machinename', machinename]\n\t\tproject.count > 0 ? true : false\n\tend", "def project_create?\n is_project_create\n end", "def can_manage_project(project)\n @project = project\n @project.user_id == self.id ? true : false\n end", "def create_project?\n return true if self.admin? # admin always true\n \n # False if they have not paid and they have added at least one project\n return false if self.subscription.nil? && self.projects.count >= 1\n \n # False if they have not paid\n return false if self.subscription.nil? && 14.days.ago > self.created_at \n return true\n end", "def contributed_to?(project)\n \t!contribution(project).nil?\n end", "def shares_project?(other_item)\n projects = if other_item.is_a?(Project) || other_item.is_a?(Enumerable)\n Array(other_item)\n else\n other_item.projects\n end\n\n (self.projects & projects).any?\n end", "def suitable_for?(discipline)\n name = name_discipline(discipline)\n count = self.disciplines.count(:conditions => ['name = ?', name])\n return count > 0\n>>>>>>> 336471e6be257cf55c9afa2a65f928fde34e41fe:app/models/project.rb\n end", "def active?\n self.project_active\n end", "def donated_to?(project)\n self.donations.exists?(project_id: project.id)\n end", "def isChildproject(childproject, parentproject)\r\n\t\tisChild = false\r\n\t\tif (childproject.id != parentproject.id)\r\n\t\t\tif (childproject.is_descendant_of?(parentproject))\r\n\t\t\t\tisChild = true\r\n\t\t\tend\r\n\t\tend\t\r\n\t\treturn isChild\r\n\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List of all the writers for this description, as ids.
def writer_ids group_user_ids(writers_join_table) end
[ "def writers\n handle(@client.get(\"writers\")) { |result| result[\"writers\"] }\n end", "def writers\n names = full_credits.at(\"a[name='writers']\").parent.parent.parent.parent.css(\"a[href^='/name/nm']\").map { |node| node.text } rescue []\n links = full_credits.at(\"a[name='writers']\").parent.parent.parent.parent.css(\"a[href^='/name/nm']\").map { |node| node[\"href\"] } rescue []\n imdb_ids = links.map { |link| link.parse_imdb_id } unless links.empty?\n \n array = []\n 0.upto(names.size - 1) do |i|\n array << {:imdb_id => imdb_ids[i], :name => names[i]}\n end\n \n array\n end", "def index\n @writers = Writer.all\n end", "def availables\n @rewriters.values\n end", "def index # This is being used for admins to see writers assigned to them\n @writers = Writer.where(inactive: false)\n @outlets = Outlet.where(inactive: false)\n end", "def get_project_coworkers\n @project.writers\n end", "def index\n @expert_writers = ExpertWriter.all\n end", "def writers\n top_writers = get_nodes(\"div[text()*='Writer']//a\")\n if top_writers.empty? || top_writers.last.start_with?('See more')\n all_writers\n else\n top_writers\n end\n end", "def index\n @exepert_writers = ExeprtWriter.all\n end", "def index\n @omdb_writers = OmdbWriter.all\n end", "def recording_producer_ids\n param_role_extractor(:recording_contributors, :producers)\n end", "def writer(*names)\n names.each { |name| attribute name, :writer }\n end", "def ids_writer(ids); end", "def writers #:nodoc:\n readers.select do |io|\n io.respond_to?(:pending_write?) && io.pending_write?\n end\n end", "def list_available_rewriters\n Rewriter.availables.each do |rewriter|\n print rewriter.name + \" \"\n end\n puts\n end", "def recording_depositor_ids\n param_role_extractor(:recording_contributors, :depositors)\n end", "def ids_reader\n reader\n @target.map(&:id)\n end", "def ids\n contents.ids\n end", "def driver_ids\n\t\tdrivers.map{|d| d.id.to_s + \"_\" + self.id.to_s}\n\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List of all the readers for this description, as ids.
def reader_ids group_user_ids(readers_join_table) end
[ "def ids_reader\n reader\n @target.map(&:id)\n end", "def get_project_readers\n @project.readers\n end", "def ids_reader; end", "def author_ids\n @instance.client.listAuthorsOfPad(padID: @id)[:authorIDs] || []\n end", "def index\n @readers = Reader.all\n end", "def identifier_uris\n return @identifier_uris\n end", "def index\n @rfid_readers = RfidReader.all\n end", "def ids\n contents.ids\n end", "def ids\n parent.attributes.fetch(resource_name, [])\n end", "def ids\n @ids ||= term.list_ids.sort\n end", "def ids\n @ids ||= term.list_ids.sort\n end", "def table_readers\n data_session.table_readers\n end", "def author_ids\n diff[:authors]\n end", "def ids_reader\n predicate = reflection.options.fetch(:has_member_relation)\n if loaded?\n target.map(&:id)\n else\n owner.resource.query({ predicate: predicate })\n .map { |s| ActiveFedora::Base.uri_to_id(s.object) } | target.map(&:id)\n end\n end", "def recipe_ids\n self.recipes.map(&:recipe_id)\n end", "def riders\n result = []\n self.books.each do |book|\n book.plans.each do |plan|\n plan.riders.each do |rider|\n result << rider\n end\n end\n end\n\n result\n end", "def oids\n\t\treturn self.each_oid.to_a\n\tend", "def dor_read_rights\n public_xml_doc.xpath('//rightsMetadata/access[@type=\"read\"]/machine/*').map(&:name)\n end", "def ids_reader\n if loaded?\n load_target.reject(&:marked_for_destruction?).map(&:id)\n else\n load_from_solr.map(&:id)\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is a given user an writer for this description?
def writer?(user) public_write || permitted?(writers_join_table, user) end
[ "def writer_user? email\n lookup_access_role_scope_value :writer, :user, email\n end", "def is_writer?\n self.role? :writer\n end", "def is_readable_by( user )\n if self.is_public || self.accepts_role?( :owner, user ) \n return true\n else\n return( self.accepts_role? :reader, user ) \n end#end if\n end", "def writer_group? email\n lookup_access_role_scope_value :writer, :group, email\n end", "def current_user_is_creator?(dictionary)\n if dictionary.creator == current_user.email\n return true\n else \n return false\n end\n end", "def is_writeable_by( user ) \n self.accepts_role? :owner, user\n end", "def can_be_written_by?(user)\n case handle.specific.class.name.demodulize\n when 'User'\n user === handle.specific\n when 'Team', 'Community'\n user.can_write?(handle.specific, :posts)\n else\n false\n end\n end", "def readable_by? user\n check_access(user, READABLE_BY_AUTH, READABLE)\n end", "def creator_user?(raffle)\n current_user == creator_user(raffle)\n end", "def edited_by?(user)\n lecture.edited_by?(user)\n end", "def can_edit?(user)\n user && self.creator_id == user.id\n end", "def readable_by?(user)\n user.in_session?(resource) || user.admin_for?(resource.course)\n end", "def is_contributor\n user = UserAdmin.find_by_user_id(current_user.id)\n if user and user.level >0\n return true || false\n end\n end", "def is_contributor?\n !contributor_role.nil?\n end", "def contributor?\n self.contributor\n end", "def is_reviewer?\n self.reviewer_role != nil\n end", "def is_contributor?(story)\n User.role_for_story(self, story.id) == \"loggedout\" || User.role_for_story(self, story.id) == \"reader\"\n end", "def viewable_by?(u)\n return true if self.public?\n return false unless u\n user_id = (u.is_a?(User) ? u.id : u)\n\n return true if self.creator_id == user_id\n\n #private roll user didn't create, must be a follower to view\n return self.following_users.any? { |fu| fu.user_id == user_id }\n end", "def owner?(user, document)\n if [Report].include?(document.class)\n false\n elsif user == document\n true\n elsif !document.respond_to?(:user)\n false\n else\n document.user == user\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is a given user an reader for this description?
def is_reader?(user) public || permitted?(readers_join_table, user) end
[ "def reader_user? email\n lookup_access_role_scope_value :reader, :user, email\n end", "def is_reviewer?(user)\n review_result = self.design_review_results.detect { |drr| drr.reviewer == user }\n review_result != nil\n end", "def is_readable_by( user )\n if self.is_public || self.accepts_role?( :owner, user ) \n return true\n else\n return( self.accepts_role? :reader, user ) \n end#end if\n end", "def readable_by? user\n check_access(user, READABLE_BY_AUTH, READABLE)\n end", "def is_reviewer?\n self.reviewer_role != nil\n end", "def recommended_reviewer?(user)\n recommended_reviewers.where(user: user).present?\n end", "def reader_logged_in?\n !current_reader.nil?\n end", "def reader_group? email\n lookup_access_role_scope_value :reader, :group, email\n end", "def readable_by?(user)\n user.in_session?(resource) || user.admin_for?(resource.course)\n end", "def is_questioner?\n self.game.is_questioner(:reader)\n end", "def reader_view? view\n lookup_access_view view\n end", "def is_role_reviewer?(role, user)\n user == self.get_role_reviewer(role)\n end", "def author?(user)\n authors.member?(user)\n end", "def reviewable_by?(user_id)\n user_id = user_id.id if user_id.is_a?(User)\n has_role(user_id, :reviewer)\n end", "def reader_special? group\n lookup_access_role_scope_value :reader, :special, group\n end", "def read? reader\n self.received_messages.find(:all, :conditions => [\"recipient_id = ? \", reader]).each { |each| return false unless each.read? }\n return true\n end", "def author?(user)\n self.user == user\n end", "def user?\n get_mode == :user\n end", "def read?(person, client)\n if (! self.priv)\n return self.client == client\n end\n return (self.client == nil || self.client == client) &&\n (owner == person || owner.contacts.include?(person) || (!person.nil? && person.moderator?(client)))\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Give a User or UserGroup writer privileges.
def add_writer(arg) chg_permission(writers, arg, :add) end
[ "def add_writer_user email\n add_access_role_scope_value :writer, :user, email\n end", "def add_writer_group email\n add_access_role_scope_value :writer, :group, email\n end", "def permits_write_access_for(user)\n permits_access_for(user, :w)\n end", "def permits_write_access_for(user)\n end", "def allows_write_access_for?(user)\n self.group.allows_write_access_for?(user)\n end", "def writer?(user)\n public_write || permitted?(writers_join_table, user)\n end", "def can_write=(value)\n set_privileges('d', value) unless value\n set_privileges('w', value)\n end", "def is_writer?\n self.role? :writer\n end", "def add_writer_iam_member identity\n add_access_role_scope_value :writer, :iam_member, identity\n end", "def add_writer_special group\n add_access_role_scope_value :writer, :special, group\n end", "def allows_write_access_for?(user)\n permission = user.permissions.detect {|p| p.group == self.root || p.group == self}\n permission && permission.allows_write?\n end", "def is_writeable_by( user ) \n self.accepts_role? :owner, user\n end", "def add_writer_domain domain\n add_access_role_scope_value :writer, :domain, domain\n end", "def can_write?(user)\n return true if (has_key?(user.id) and self[user.id].can_write?)\n user.groups.each do |group|\n return true if can_write?(group)\n end if user.is_a?(Ecore::User)\n false\n end", "def writer_user? email\n lookup_access_role_scope_value :writer, :user, email\n end", "def add_moderators\n self.users << User.with_role(User::ROLES[:moderator])\n end", "def grant_privileges(username=false, database=false, *privileges)\n grant_or_revoke_privileges('GRANT', username, database, privileges)\n end", "def assign\n navigate\n on Permissions do |add|\n # See the roles method defined below...\n roles.each do |inst_var, role|\n get(inst_var).each do |username|\n unless add.user_row(username).present? && add.assigned_role(username).include?(role)\n add.user_name.set username\n add.role.select role\n add.add\n add.user_row(username).wait_until_present\n end\n end\n end\n add.save\n # TODO: Add some logic here to use in case the user is already added to the list (so use add_roles)\n end\n end", "def permits_write_access_for(user)\n return true if user.is_admin? \n return true if @instance.respond_to?(:user_group_id) && (@instance.user_group_id == user.user_group_id)\n return false if @instance.respond_to?(:locked) && @instance.locked \n return false if @instance.respond_to?(:deleted) && @instance.deleted\n return true if ((user.writeable_category_ids() & (@instance.category_ids)).length > 0)\n return false \n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Give a User or UserGroup reader privileges.
def add_reader(arg) chg_permission(readers, arg, :add) end
[ "def make_reader!( user )\n self.accepts_role :reader, user\n end", "def assign_reader(user_id)\n add_user(user_id)\n end", "def permits_read_access_for(user)\n permits_access_for(user, :r)\n end", "def assign_reader(user_id)\n\t\tadd_user(user_id)\n\tend", "def add_reader_user email\n add_access_role_scope_value :reader, :user, email\n end", "def is_reader?(user)\n public || permitted?(readers_join_table, user)\n end", "def add_reader_group email\n add_access_role_scope_value :reader, :group, email\n end", "def add_reader_special group\n add_access_role_scope_value :reader, :special, group\n end", "def grant_access(user_identifier)\n Scribd::Security.grant_access user_identifier, self\n end", "def is_readable_by( user )\n if self.is_public || self.accepts_role?( :owner, user ) \n return true\n else\n return( self.accepts_role? :reader, user ) \n end#end if\n end", "def add_writer_user email\n add_access_role_scope_value :writer, :user, email\n end", "def add_reader_iam_member identity\n add_access_role_scope_value :reader, :iam_member, identity\n end", "def add_administrator(reader)\n GroupMembership\n .find_or_initialize_by(group: self, reader: reader)\n .tap do |group_membership|\n group_membership.status = :admin\n group_membership.save! if group_membership.changed?\n end\n end", "def set_read_users(users, eligible_users)\n set_entities(:read, :person, users, eligible_users)\n end", "def permits_write_access_for(user)\n end", "def authorise_read\n authorize! :read, UserAgreement\n end", "def contributor\n reader\n can :dashboard # allow access to dashboard\n can :access, :rails_admin\n can :manage, Post\n end", "def ensure_reviewer_or_owner!\n return if this_user == @user || this_user.permission?(:reviewer)\n\n no_permission\n end", "def permits?( priv, user = User.current )\n (priv, associate) = disassemble_priv( priv )\n check_user_set!(user, priv, associate)\n user.can?( priv, associate )\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Revoke a User's or UserGroup's writer privileges.
def remove_writer(arg) chg_permission(writers, arg, :remove) end
[ "def revoke_privileges(username=false, database=false, *privileges)\n grant_or_revoke_privileges('REVOKE', username, database, privileges)\n end", "def remove_writer_user email\n remove_access_role_scope_value :writer, :user, email\n end", "def revoke_all_access!\n user_name = app_credentials[:user]\n enable_read_only!\n drop_user(user_name) # never written to binlog, so no risk of it replicating\n end", "def revoke_permission(username)\n return unless owner?\n\n uri = Util.append_to_uri_path(links[:sec_perms], username)\n @server.delete(uri, @credentials)\n end", "def revoke_admin\n authorize! @user\n @user.roles = @user.roles - [\"admin\"]\n @user.save\n redirect_to @user, notice: t(\"user.revoked_admin\", name: @user.username)\n end", "def revoke_admin\n authorize! @user\n @user.roles = @user.roles - ['admin']\n @user.save\n redirect_to @user, notice: t('user.revoked_admin', name: @user.username)\n end", "def revoke_access(authorizer,authorized)\n if has_access?(authorizer)\n if owner.eql? authorized\n raise(\"User '#{authorized}' is the owner of this document!\")\n end\n\n authorization = authorizations.find do |authorization|\n authorization.authorized.eql? authorized\n end\n\n unless authorization\n raise(\"User '#{authorized}' does not have access to the document\")\n end\n \n unless authorization.authorizer.eql? authorizer\n raise(\"User '#{authorizer}' is not allowed to revoke access for User '#{authorized}'\")\n end\n\n authorizations.delete(authorization)\n else\n raise(UnauthorizedUser,\"User '#{authorizer}' does not have appropriate clearance\")\n end\n end", "def remove_revoked_grant revoke\n Array(revoke.roles).each do |role|\n Array(revoke.members).each do |member|\n requested.delete [ role.roleid, member.roleid ]\n requested_with_admin_flag.delete [ role.roleid, member.roleid, true ]\n requested_with_admin_flag.delete [ role.roleid, member.roleid, false ]\n end\n end\n end", "def del_right_for_user(user)\n @rights.each do |r| \n if r.user == user\n @rights.delete r\n end\n end\n end", "def revoke_user_grant(database, user)\n \n sql = \"REVOKE ALL PRIVILEGES ON `#{database}`.* FROM #{full_name(user)}\"\n\n display_command(sql) if @show\n \n begin\n @dbh.query(sql) if @run\n flush_privileges\n return true\n rescue => e\n display_error(e) if @debug\n return false\n end\n \n end", "def revoke!(roles, resource)\n remove_authorizations roles, resource do |conditions|\n Permit::Config.authorization_class.delete_all conditions\n end\n end", "def remove_writer_group email\n remove_access_role_scope_value :writer, :group, email\n end", "def revoke_privileges(role_name, privileges, options = nil)\n policy = create_policy(options, AdminPolicy, default_admin_policy)\n command = AdminCommand.new\n command.revoke_privileges(@cluster, policy, role_name, privileges)\n end", "def revoke_schema_privileges(schemas, privileges, roles, options = {})\n execute PostgreSQLRevokePrivilege.new(self, :schema, schemas, privileges, roles, options, :ignore_schema => true).to_sql\n end", "def revoke(roles, resource)\n remove_authorizations roles, resource do |conditions|\n Permit::Config.authorization_class.destroy_all conditions\n end\n end", "def revoke_admin_rights(member)\r\n fail \"#{member.email} is not a admin of this organisation\" unless admins[member.email]\r\n fail \"not enough admins left\" unless self.admin_count > 1\r\n self.admins.delete(member.email)\r\n end", "def revoke_all_permissions\n update_column(:admin, nil)\n UserPermission.where(user_id: id).each(&:destroy)\n end", "def revoke_admin\r\n self.transaction do \r\n # Need to make sure we're not resetting the password.\r\n self.password = nil\r\n self.is_admin = false\r\n self.permissions.each {|p| p.destroy }\r\n self.save\r\n end\r\n end", "def user_revoke_role(user, role)\n request.handle(:auth, 'user_revoke_role', [user, role])\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is the given User an author?
def author?(user) authors.member?(user) end
[ "def author?(user)\n self.user == user\n end", "def current_user_is_author?\n current_user && current_user.is_author\n end", "def has_author?(author)\n ret = false\n @authors.each{ |auth| ret = true if auth == author }\n ret\n end", "def author?\n !author.nil? && !author.empty?\n end", "def is_author?( author = '' )\n return false unless @is_author\n\n return true if author.blank?\n\n author_obj = get_queried_object\n\n author = [author].map {|a| a.to_s}\n\n if author.include?(author_obj.id.to_s)\n return true\n elsif author.include?(author_obj.nickname)\n return true\n elsif author.include?(author_obj.user_nicename)\n return true\n end\n false\n end", "def is_author?\n true if current_user.level == author_level\n end", "def current_author?(author)\n author == current_author\n end", "def authored_by?(user)\n author == user || user.user_groups.include?(user_group)\n end", "def is_author_of?(name)\n self.is_author? and !self.programs.find_by_name(name).nil?\n end", "def author?\n @author ||= @lines.any? do |line|\n break true if line =~ /maintainer/i # \"Maintainer(s): \"\n break true if line =~ /author/i # \"Author(s): \"\n break true if line =~ /\\w@\\w/i # email address\n break true if line =~ /(?:^| )by:? /i # \"By John Doe\"\n\n false\n end\n end", "def author_required?\n true\n end", "def manageable_by(user)\n self.author == user\n end", "def is_the_author_of_the_post(post)\n post.author_id == current_author.id\n end", "def verify_user_is_author\n unless current_user == @comment.author\n flash[:danger] = \"Can not modify someone else's post!\"\n redirect_to root_path\n end\n end", "def post_author(post)\n user_signed_in? && current_user.id == post.user_id\n end", "def invitable_to?(user)\n return false unless pending?\n return false if authors.include?(user)\n end", "def existance_of_author\n if author.nil? or not User.confirmed.find_by_id(author.id)\n errors.add :author, I18n.t(\"activerecord.errors.story.attributes.author.existance\")\n end\n end", "def logged_in?\n !current_author.nil?\n end", "def ==(author)\n if author.is_a? Author\n name == author.name\n else\n false\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is the given User an editor?
def editor?(user) editors.member?(user) end
[ "def current_user_is_editor?(node)\n current_user_has_role?('editor', node)\n end", "def is_editor?\n @role && @role.match(/editor|manager/)\n end", "def is_editor?\n role == \"editor\"\n end", "def editor?\n has_role? :editor\n end", "def is_editor?\n if current_user || current_user_api\n respond_to do |format|\n format.html{\n return current_user.nivel_acceso == 'editor'\n }\n format.json{\n return current_user_api.nivel_acceso == 'editor'\n }\n end\n end\n end", "def editable_by?(user)\n return true unless has_limited_editors?\n\n (editor_roles & user.alchemy_roles).any?\n end", "def can_edit?(user)\n return true if check_creator(user)\n return true if user.any_role?('editor', 'manager')\n return true if !self.content_permissions.by_user(user).blank?\n return true if self.parent && self.parent.can_add_content?(user)\n false\n end", "def editable?\r\n return true if user.content_manager?\r\n if story.submitted?\r\n return false\r\n elsif user.organization?\r\n return true if user.organization == story.organization\r\n end\r\n return story.editor == user if story.uploaded?\r\n return story.authors.include?(user)\r\n false\r\n end", "def displayable_to_user?(user, cat=catalog)\n at_least_editor = user.catalog_role_at_least?(cat, 'editor')\n at_least_editor || !restricted?\n end", "def edited_by?(user)\n lecture.edited_by?(user)\n end", "def last_editor?(c_utor)\n case self.contributor_type\n when \"User\"\n return (self.contributor_id == c_utor.id && self.contributor_type == c_utor.class.name)\n # TODO some new types of \"contributors\" may be added at some point - this is to cater for that in future\n # when \"Network\"\n # return self.contributor.owner?(c_utor.id) if self.contributor_type.to_s\n else\n # unknown type of contributor - definitely not the owner \n return false\n end\n end", "def medium_editor?(medium)\n current_user.admin || medium.edited_with_inheritance_by?(current_user)\n end", "def edited_with_inheritance_by?(user)\n return true if editors.include?(user)\n return true if teachable&.lecture&.editors&.include?(user)\n return true if teachable&.lecture&.teacher == user\n return true if teachable&.course&.editors&.include?(user)\n false\n end", "def is_editor(project_id)\n roles = UserProjectRole.where(:user_id=>self.id, :project_id=>project_id, :role=>'editor').size\n return roles > 0\n end", "def can_edit?(user)\n user && self.creator_id == user.id\n end", "def editable?(user)\n\n return false if user.nil?\n\n return (user.admin?(User::AUTH_ADDRESSBOOK) or self.owner_id == user.id)\n end", "def current_user_is_final_editor?(node)\n current_user_has_role?('final_editor', node)\n end", "def assure_editor_is_not_creator\n if editors.include? creator\n [ false, \"creator is always an editor\" ]\n else\n true\n end\n end", "def mayEdit? ( other_user )\n if ( (not other_user.valid?) or ( other_user.is_a?(User) == false ) )\n # d \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n # d \"basic check failed\"\n # d other_user.type\n # d \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n return false\n end\n user = getUser()\n if ( other_user == user )\n return true\n end\n if ( ( self.public_policy == Dfile::PP_MAYEDIT ) )\n return true\n end\n if self.special_users\n special = self.special_users[other_user.id.to_s]\n if special\n if ( ( special == Dfile::PP_MAYEDIT ) )\n return true\n end\n end\n end\n return false\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a User on as an "author". Saves User if changed. Returns nothing.
def add_author(user) return if authors.member?(user) authors.push(user) SiteData.update_contribution(:add, authors_join_table, user.id) return unless editors.member?(user) editors.delete(user) SiteData.update_contribution(:del, editors_join_table, user.id) end
[ "def add_author\n add_author_editor \"author\"\n end", "def add_author_or_editor\n return unless !@save_without_our_callbacks && (user = User.current)\n\n authors.empty? && author_worthy? ? add_author(user) : add_editor(user)\n end", "def set_author_values_for(user)\n self.author = user\n self.name = user.full_name\n end", "def add_authors(current_user)\n claims.each do |claim|\n if claim.author.nil?\n claim.author = current_user\n save\n end\n end\n end", "def set_author_id\n self.author_id = user_id\n end", "def fill_author_from_user!\n f_name = user.first_name\n l_name = user.last_name\n orcid = (user.orcid.blank? ? nil : user.orcid)\n email = user.email\n\n # TODO: This probably belongs somewhere else, but without it here, the affiliation sometimes doesn't exist\n StashDatacite::AuthorPatch.patch! unless StashEngine::Author.method_defined?(:affiliation)\n\n affiliation = user.affiliation\n affiliation = StashDatacite::Affiliation.from_long_name(long_name: user.tenant.long_name) if affiliation.blank? &&\n user.tenant.present? && !%w[dryad localhost].include?(user.tenant.abbreviation.downcase)\n StashEngine::Author.create(resource_id: id, author_orcid: orcid, affiliation: affiliation,\n author_first_name: f_name, author_last_name: l_name, author_email: email)\n # disabling because we no longer wnat this with UC Press\n # author.affiliation_by_name(user.tenant.short_name) if user.try(:tenant)\n end", "def add_post(post)\n post.author = self\n end", "def add_post(post)\n post.author = self \n end", "def author=(author)\n @author = @repo.actor author\n @author.authored_commits << self\n end", "def author\n self.role = :author\n save\n end", "def add_post(post)\n post.author = self #\n end", "def add_author(name, email = nil)\n @authors << {:name => name, :email => email}\n end", "def save_author\n self.author = custom_author if self.author == \"other\" \n end", "def set_author_id\n if self.author_id.blank?\n self.author_id = self.user_id\n end\n end", "def author=(value)\n @author = value\n end", "def be_sure_author_exists(author, current_user)\n person = nil\n person = Person.find(author.person_id) unless author.person_id.nil?\n person = Person.get_or_create(author.name, current_user) if person.nil?\n author.person = person\n author.name = person.complete_name_with_org\n # logger.debug \"========> Author's person: #{author.person.inspect} id: #{author.person_id}.\"\n end", "def add_user(u)\n run_callbacks :user_added do\n puts \" adding user\"\n @users << u\n end\n end", "def add_author(user_id)\r\n CSV.foreach('users.csv', headers: true, header_converters: :symbol) do |row|\r\n csv_user_id = row[:user_id]\r\n if user_id == csv_user_id \r\n @author = row[:name]\r\n end\r\n end\r\n end", "def create_user_for_image\n u = User.init_based_on_username(author)\n return false if !u.save\n self.user = u\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
:section: Callbacks Callback that updates editors and/or authors after a User makes a change. If the Name has no author and they've made sufficient contributions, they get promoted to author by default. In all cases make sure the user is added on as an editor.
def add_author_or_editor return unless !@save_without_our_callbacks && (user = User.current) authors.empty? && author_worthy? ? add_author(user) : add_editor(user) end
[ "def add_author(user)\n return if authors.member?(user)\n\n authors.push(user)\n SiteData.update_contribution(:add, authors_join_table, user.id)\n return unless editors.member?(user)\n\n editors.delete(user)\n SiteData.update_contribution(:del, editors_join_table, user.id)\n end", "def set_author_name\n # Handles toggling between fake and real names (at edit)\n if anonymouse_changed?\n if self.anonymouse?\n self.author_name = Faker::Name.name\n else\n self.author_name = self.user.name\n end\n end\n # Handles\n if !self.anonymouse?\n self.author_name = self.user.name\n end\n end", "def change_author(new_author)\n return if rank == \"Group\"\n\n new_author2 = new_author.blank? ? \"\" : \" #{new_author}\"\n self.author = new_author.to_s\n self.search_name = text_name + new_author2\n self.sort_name = Name.format_sort_name(text_name, new_author)\n self.display_name = Name.format_autonym(text_name, new_author, rank,\n deprecated)\n end", "def set_author_name\n # Handles toggling between fake and real names (at edit)\n if attribute_changed?(:anonymouse)\n if anonymouse?\n self.author_name = Faker::Name.name\n\n else\n self.author_name = self.user.name\n\n end\n end\n # Handles\n if !anonymouse?\n self.author_name = self.user.name\n end\n end", "def add_author\n add_author_editor \"author\"\n end", "def set_author_values_for(user)\n self.author = user\n self.name = user.full_name\n end", "def assign_editor(user_id)\n\t\tadd_user(user_id, true)\n\tend", "def check_author\n if self.author.blank?\n self.author = 'anon'\n end\n end", "def add_author_editor(type)\n contribs = @bib.contributor.select do |c|\n c.entity.is_a?(Person) && c.role.any? { |e| e.type == type }\n end.map &:entity\n\n return unless contribs.any?\n\n @item.send \"#{type}=\", concat_names(contribs)\n end", "def commit_author(snippet)\n return migration_bot_user if snippet_content_size_over_limit?(snippet)\n return migration_bot_user if @invalid_signature_error\n\n if Gitlab::UserAccessSnippet.new(snippet.author, snippet: snippet).can_do_action?(:update_snippet)\n snippet.author\n else\n migration_bot_user\n end\n end", "def set_ContributorName(value)\n set_input(\"ContributorName\", value)\n end", "def author\n self.role = :author\n save\n end", "def set_AuthorUsername(value)\n set_input(\"AuthorUsername\", value)\n end", "def set_AuthorName(value)\n set_input(\"AuthorName\", value)\n end", "def set_Contributor(value)\n set_input(\"Contributor\", value)\n end", "def editor_add(editor_new)\n if (@project == nil or editor_new == nil)\n return false\n end\n \n if Collaborator.exists?(:user_id => editor_new.id, :project_id => @project.id) #avoids duplicate editors\n user = Collaborator.where(user_id: editor_new.id).first\n user.update_attributes(:editor => true)\n return true\n end\n \n colab = Collaborator.new\n colab.update_attributes(:project_id => @project.id, :project_name => @project.name,\n :user_id => editor_new.id, :user_email => editor_new.email, :editor => true)\n colab_add_to_docs(editor_new)\n return true\n end", "def add_reviewer_on_github\n @github_connection.add_assignee(@repo, @number, @title, @body, @githubname) if @number && @githubname\n end", "def notify_only_author?(user)\n for_commit? && commit_author &&\n commit_author.email != user.email\n end", "def set_author_name\n self.secondary_key = self.integration.gh_client.users.get(self.primary_key).name\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns only value part of value block
def value(block_num = nil) v, _ = value_with_addr(block_num) v end
[ "def unparsed_value; end", "def get_literal_value()\n @hash[:value]\n end", "def process_field_value(value)\r\n value\r\n end", "def value() end", "def raw_value\n @value\n end", "def value(*) end", "def vlets() [ @value ]; end", "def complete_value\n if last_token_is(COMPARISON_OPERATORS)\n token = tokens[tokens.size - 2]\n val = ''\n else\n token = tokens[tokens.size - 3]\n val = tokens[tokens.size - 1]\n end\n\n field = definition.field_by_name(token)\n return [] unless field && field.complete_value\n\n return complete_set(field) if field.set?\n return complete_date_value if field.temporal?\n return complete_key_value(field, token, val) if field.key_field\n\n special_values = field.special_values.select { |v| v =~ /\\A#{val}/ }\n special_values + complete_value_from_db(field, special_values, val)\n end", "def processed_value\n @value\n end", "def value\n return members_as_value ? list(:member) : @value\n end", "def data_value()\n (single_data_value?) ? @data.value[0] : @data.value\n end", "def potential_values\n @original_document[value_field]\n end", "def value_data\n return @value_data\n end", "def value\n data[1]\n end", "def each_value() yield @value; end", "def value_content\n self.value.nil? ? \"\" : self.value.ann_content\n end", "def value_structure(&block)\n insert_structure(nil, &block)\n end", "def returning value, &block\n yield value\n value\n end", "def value\n unless @processed\n @processed = true\n until (nested = constants_from_value).empty?\n nested.each {|n| @value.gsub!(value_regex(n),find_value_for_constant(n)) }\n end\n end\n\n @value\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The method should return the number of pairs of elements that sum to 0.
def pairs_to_zero(nums) # Write your code here c = [] a = nums.select { |n| c.push(n) if n < 0 } nums.delete_if { |n| c.push(n) if n < 0 } i = 0 pairs = 0 a = a.map { |n| n*-1 } loop do if nums.count(a[i]) > 0 pairs += 1 end i += 1 break if i == a.length end return pairs end
[ "def pairs_to_zero(nums)\n\n count = 0\n newArr = []\n\n for i in 0..nums.length do\n for j in 1..nums.length do\n if nums[i].to_i + nums[j].to_i == 0\n count = count + 1\n end\n end\n end\n return count-2\nend", "def opposite_count(nums)\n zeros = 0\n\n nums.each_with_index do |ele1, idx1|\n nums.each_with_index do |ele2, idx2|\n if ele1 + ele2 == 0 && idx1 < idx2\n zeros += 1\n end\n end\n end\n return zeros\nend", "def two_sum\n zero_sum_pairs = []\n last_index = self.length - 1\n 0.upto(last_index) do |i|\n (i + 1).upto(last_index) do |j|\n zero_sum_pairs << [i, j] if (self[i] + self[j] == 0)\n end\n end\n zero_sum_pairs\n end", "def strange_sums(nums_arr)\n pairs = []\n\n (0...nums_arr.length).each do |idx_1|\n (idx_1...nums_arr.length).each do |idx_2|\n pairs << [nums_arr[idx_1], nums_arr[idx_2]]\n end\n end\n\n pairs.select { |sub_arr| sub_arr.sum == 0 }.count\nend", "def pair_zeros(arr)\n arr.select.each_with_index do |num, idx|\n num != 0 || (num == 0 && count(arr, num, idx) % 2 == 1)\n end\nend", "def opposite_count(array)\n count = 0 \n array.combination(2).to_a.each do |nums|\n count += 1 if nums.sum == 0\n end\n\n count\nend", "def opposite_count(nums)\n\n new = [] \n\n nums.each_with_index do |num1, idx1|\n nums.each_with_index do |num2, idx2|\n\n if idx1 < idx2\n if num1 + num2 == 0 \n new << [num1, num2]\n end \n end \n\n end \n end \n return new.length\n\nend", "def pair_sum_count(num)\n pairs = []\n self.each_with_index do |ele1, i1|\n self.each_with_index do |ele2, i2|\n if i1 < i2\n pairs << [ele1, ele2]\n end\n end\n end\n pairs.count { |ele| ele.sum == num }\n end", "def strange_sums(arr)\n count = 0\n\n return 0 if arr.length == 1\n\n arr.each_with_index do |ele_1, idx1|\n arr.each_with_index do |ele_2, idx2|\n if idx2 > idx1\n count += 1 if ele_1 + ele_2 == 0\n end\n end\n end\n count\nend", "def pairs(arr)\n arr_pairs = []\n idx = 0\n loop do\n arr_pairs << arr.slice(idx..idx + 1)\n idx += 2\n break if idx >= arr.size\n end\n count = 0\n arr_pairs.each do |pair|\n next if pair.size < 2\n count += 1 if (pair[0] - pair[1]).abs == 1\n end\n count\nend", "def strange_sums(arr)\n count = 0\n\n (0...arr.length).each do |idx_1|\n (idx_1+1...arr.length).each do |idx_2|\n count += 1 if (arr[idx_1] + arr[idx_2]) == 0\n end\n end\n count\nend", "def num_potential_pairs\n potential_pairs.size\n end", "def pairs(array)\n result = 0\n \n array.uniq.each do |num|\n appearences = array.count(num)\n result += (appearences / 2) \n end\n result\nend", "def number_of_zeros\r\n total_zeros = 0\r\n @seminarians.each do |sem|\r\n zeros = sem.number_of_zeros\r\n total_zeros += zeros\r\n end\r\n\r\n #Divide by 2 to correct the fact that each was counted twice\r\n return total_zeros/2\r\n end", "def zero_sum_sub_arrays(xs)\n return 0 if xs.size < 2\n\n (2..xs.size)\n .flat_map { |n| xs.each_cons(n).to_a }\n .select { |xs| xs.sum == 0 }\n .size\nend", "def span_count ary\n ([0] + ary).lazy\n .each_cons(2)\n .count{|c,n| c == 0 && n != 0 }\nend", "def face_pairs_count\n face_count_values.count(2)\n end", "def countPairs()\n\n return true\n\n\n\n\nend", "def two_sum(nums)\n\n # Iterate through each number in the incoming array\n nums.each do |first|\n \n # If we've hit the end of the array, return - there is nothing left to compare\n return if nums.index(first) == nums.length - 1\n\n # Nested loop, compare every other value to the prior loop's value\n nums.each do |second|\n \n # Don't let first & second share the same index, skip that case\n next if nums.index(first) == nums.index(second)\n\n # Check for summing to 0\n if first + second == 0\n result = []\n result << nums.index(first)\n result << nums.index(second)\n # Return the indices of the numbers that sum to 0\n return result\n end\n\n end\n end\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
subtract attrs_skip from attrs
def ext_attrs(values, attrs_skip = []) result = values.except *attrs_always_skip return result end
[ "def skip!(name)\n options = { skip: true }\n add_attribute(name, options)\n end", "def exclude_attrs\n # This handle especial case: round and team doesn't have update action\n user_exclusion = if record_is_a?(:round) || record_is_a?(:team)\n @exclude_attrs_on_create\n else\n (@exclude_attrs_on_create & @exclude_attrs_on_update)\n end\n\n user_exclusion +\n must_exclude_attrs +\n @rename_attrs.keys +\n @associations.keys\n end", "def skip_attributes(hash, attrs = SKIP_ATTRIBUTES, content_key = ContentKey)\n hash.each do |key, value|\n if attrs.include? key\n hash.delete(key)\n elsif value.is_a? Hash\n hash[key] = skip_attributes(value, attrs, content_key)\n elsif value.is_a? Array and value[0].is_a? Hash\n value.each_with_index do |array_value, index|\n value[index] = skip_attributes(array_value, attrs, content_key)\n end\n end\n end\n ( hash.one? and hash[content_key] ) ? hash[content_key] : ( hash.empty? ? nil : hash )\n end", "def must_exclude_attrs\n required[:must_exclude_attrs]\n end", "def blacklist_attributes!(attributes)\n self.attributes_blacklist += attributes - (fixed_attributes + internal_attributes)\n end", "def except_attributes(*args)\n options = args.extract_options!\n set_option_value(:except_attributes, args.map{|a| a.to_sym}, options)\n end", "def removed_attributes\n operand.operand.header - operand.header\n end", "def attr_excluded?(_attr_name)\n false\n end", "def removed_attributes\n operand.header - operation.header\n end", "def except(*skips)\n relation_with values.except(*skips)\n end", "def removed_attributes\n operand.header - header\n end", "def remove_attr(name); end", "def skipped_attributes(klass)\n if klass.const_defined?(BLACKLISTED_ATTRIBUTES)\n attrs = klass.const_get(BLACKLISTED_ATTRIBUTES)\n if attrs.include? klass_primary_key(klass)\n raise OptAR::Errors::PrimaryKeyBlacklistedError\n end\n attrs\n else\n []\n end\n end", "def filter_skip_attributes_from_payload(obj)\n if obj.is_a? Hash\n obj.map do |k, v|\n if k == \"skip_attribute\" && v\n return ''\n else\n obj[k] = filter_skip_attributes_from_payload(v)\n if obj[k].blank?\n obj.delete(k)\n end\n end\n end\n elsif obj.is_a? Array\n obj.each_with_index do |o, i|\n obj[i] = filter_skip_attributes_from_payload(o)\n end\n end\n return obj\n end", "def ignoring(*attributes)\n attributes.each do |attr_name|\n @_attributes.delete(attr_name.to_sym)\n end\n end", "def ignore_attributes_without_value(ignore)\n do_command(\"ignoreAttributesWithoutValue\", [ignore,])\n end", "def pop \n\t\tsuper\n\t\t@no_of_attributes -= 1\n\t\t@sum -= @removed_number\n\t\t@removed_number\n\tend", "def rubyamf_set_non_attributes attrs, base_attrs\n not_attributes = attrs.keys.select {|k| !base_attrs.include?(k)}\n not_attributes.each do |k|\n setter = \"#{k}=\"\n next if setter !~ /^[a-z][A-Za-z0-9_]*=/ # Make sure setter doesn't start with capital, dollar, or underscore to make this safer\n if respond_to?(setter)\n send(setter, attrs.delete(k))\n else\n RubyAMF.logger.warn(\"RubyAMF: Cannot call setter for non-attribute on #{self.class.name}: #{k}\")\n end\n end\n end", "def excluded_attributes(*list)\n raise AllowedExcludedError unless allowed_obj_attributes.empty?\n excluded_obj_attributes.concat(list.map(&:to_s))\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Run startup tasks, then start the functions framework server in the background. The startup tasks and target function will be looked up in the global registry.
def start target, &block require "functions_framework/server" if target.is_a? ::FunctionsFramework::Function function = target else function = global_registry[target] raise ::ArgumentError, "Undefined function: #{target.inspect}" if function.nil? end globals = function.populate_globals server = Server.new function, globals, &block global_registry.startup_tasks.each do |task| task.call function, globals: globals, logger: server.config.logger end globals.freeze server.respond_to_signals server.start end
[ "def start!\n message \"Launching minimum_instances\"\n launch_minimum_instances\n message \"Waiting for master to boot up\" \n \n wait_for_all_instances_to_boot\n \n setup_cloud\n end", "def run\n return self if error?\n case @what_to_do\n when :version\n puts ::FunctionsFramework::VERSION\n when :help\n puts @option_parser\n when :verify\n begin\n load_function\n puts \"OK\"\n rescue ::StandardError => e\n error! e.message\n end\n else\n begin\n start_server.wait_until_stopped\n rescue ::StandardError => e\n error! e.message\n end\n end\n self\n end", "def start!\n unless @server.running?\n @server.start_background\n Chef::Config[:chef_server_url] = @server.url\n end\n end", "def startup\nend", "def startup_tasks\n @mutex.synchronize { @start_tasks.dup }\n end", "def start\n run_all if options[:all_on_start]\n end", "def start\n swiftinit_run('start', true)\n end", "def run\n name = local_name\n\n notice \"this is a #{name} task\"\n\n services = PowerMitten::Configuration.services_for name\n\n start_services services\n\n trap 'INT' do stop_services end\n trap 'TERM' do stop_services end\n\n @threads.each do |thread|\n thread.join\n end\n end", "def before_create\n start_thread { start_webserver }\n start_thread { start_regserver }\n end", "def start(opts = {})\n bad_keys = opts.keys - START_OPTS\n raise \"Unknown options to Hastur.start: #{bad_keys.join(\", \")}!\" unless bad_keys.empty?\n\n unless @prevent_background_thread ||\n (opts.has_key?(:background_thread) && !opts[:background_thread])\n start_background_thread\n end\n\n @process_registration_done = true\n register_process Hastur.app_name, {}\n end", "def x_start\n run_callbacks :execute do\n # binding.pry\n context.resource_runtimes.each do |runtime|\n runtime.execute(:start)\n # binding.pry\n # runtime.start do |queue|\n # binding.pry\n # queue.run\n # queue.map(&:to_a).flatten.each do |msg|\n # Cnfs.logger.warn(msg)\n # end\n # end\n end\n end\n end", "def run\n start_service\n print_status(\"Local FTP: #{lookup_lhost}:#{datastore['SRVPORT']}\")\n start_http\n @http_service.wait\n end", "def start\n # we trap CTRL+C in the console and kill the server\n trap(\"INT\") { BeEF::Core::Server.instance.stop }\n \n # starts the web server\n @http_server.start\n end", "def start(*args)\n logger.info('Starting load generation and monitoring on targets...')\n redeploy = (args.empty? ? false : true)\n current_project.start(redeploy)\n\n show_load_agents\n show_target_hosts\n end", "def setup_and_run\n setup\n run\n end", "def exec_setup\n exec_task_traverse 'setup'\n end", "def start()\n raise ValidateError.new(\"#{full_name} not validated.\") unless @prepared\n @tasks.each_value { |task| task.start() }\n end", "def run\n setup\n main\n ensure\n shutdown\n end", "def run\n if daemonize\n run_background\n else\n run_foreground\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Classlevel client class config. Note: late evaluation of `client_class` blocks allows us using classlevel configs in those blocks, e.g.: class ConfigurableOnClassLevel < Netzke::Base class_attribute :title self.title = "Default" client_class do |c| c.title = self.title end end ConfigurableOnClassLevel.title = "Overridden"
def client_class_config return @client_class_config if @client_class_config @client_class_config = Netzke::Core::ClientClassConfig.new(self, called_from) (@configure_blocks || []).each do |block, dir| @client_class_config.dir = dir block&.call(@client_class_config) end @client_class_config end
[ "def set_client_class(cls)\n @@client_class = cls\n end", "def client_class\n @client_class ||= client_class_name.constantize\n end", "def server_side_config_options\n [:klass, :client_config]\n end", "def defclass\n rule(Stone::AST::Statement::Class).sep('class').identifier(reserved)\n .option(rule.sep('extends').identifier(reserved))\n .ast(class_body)\n end", "def included(klass)\n set_config_defaults\n\n klass.class_eval do\n include ::Collapsium::Config\n end\n end", "def on_class(const, superclass, bodystmt)\n beging = find_scanner_event(:@kw, 'class')\n ending = find_scanner_event(:@kw, 'end')\n\n bodystmt.bind(\n find_next_statement_start((superclass || const)[:ec]),\n ending[:sc]\n )\n\n {\n type: :class,\n body: [const, superclass, bodystmt],\n sl: beging[:sl],\n sc: beging[:sc],\n el: ending[:el],\n ec: ending[:ec]\n }\n end", "def client_class\n ActiveSupport::Inflector.constantize(@client_class_name)\n end", "def nest_class=(nest_class) # :nodoc:\n unless nest_class.kind_of?(Class) && nest_class.ancestors.include?(Configurable)\n raise ArgumentError, \"not a Configurable class: #{nest_class}\"\n end\n \n @nest_class = nest_class\n end", "def define_class(class_name, superclazz=Object)\n clazzDef = ClassDef.new\n clazzDef.class_name = class_name\n clazzDef.class_ancestors = superclazz\n return clazzDef\n end", "def class_options(options=nil)\n @class_options ||= from_superclass(:class_options, Thor::CoreExt::OrderedHash.new)\n build_options(options, @class_options) if options\n @class_options\n end", "def build_subclass(model_class, options)\n ConfiguredBackend.build(self, model_class, options)\n end", "def http_client=(klass)\n @http_client = setup_custom_class(klass, required_methods: :fetch)\n end", "def class_eval(*args, &block)\n\t\tsingleton_class.class_eval(*args, &block)\n\tend", "def configurable_class\n ancestors[ancestors.find_index(ActiveGraphQL::Model) - 1]\n end", "def print_class(name, parent_klass, &block)\n print_block(name, parent_klass, :class, &block)\n end", "def class_builder(context=nil)\n @class_builder ||= Constant.new(self, context)\n end", "def auto_create_class( key = true, parent = Object, &block )\n auto_constructor( key ) do | cname |\n parent = const_get(parent) unless parent.is_a? Class\n new_constant = Class.new( parent )\n new_constant.send(:include, AutoCode)\n ret = const_set( cname, new_constant )\n new_constant.module_eval( &block ) if block\n ret\n end\n end", "def access_class\n proptoken 'CLASS', [\"PUBLIC\", \"PRIVATE\", \"CONFIDENTIAL\"], \"PUBLIC\"\n end", "def define_klass(&block)\n @current_klass = defined_klass.new\n @current_klass.instance_exec(&block) if block_given?\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Hash containing configuration for all child components to be instantiated at the JS side
def js_components @js_components ||= eagerly_loaded_components.inject({}) do |out, name| instance = component_instance(name.to_sym) out.merge(name => instance.js_config) end end
[ "def js_configure(c)\n # Merge in component config options, besides those that are only meant for the server side\n # c.merge!(config.reject{ |k,v| self.class.server_side_config_options.include?(k.to_sym) })\n c.merge!(normalized_config)\n\n # Unique id of the component\n c.id = js_id\n\n # Configuration for all of our non-lazy-loaded children specified here. We can refer to them in +items+ so they get instantiated by Ext.\n c.netzke_components = js_components unless js_components.empty?\n\n # Endpoints (besides the default \"deliver_component\" - JavaScript side already knows about it)\n endpoints = self.class.endpoints.keys - [:deliver_component]\n\n # pass them as strings, not as symbols\n c.endpoints = endpoints.map(&:to_s) unless endpoints.empty?\n\n # Inform the JavaScript side if persistent_config is enabled\n # res[:persistent_config] = persistence_enabled?\n\n # Include our xtype\n c.xtype = self.class.js_config.xtype\n\n # Include our alias: Ext.createByAlias may be used to instantiate the component.\n c.alias = self.class.js_config.class_alias\n\n # So we can use getComponent(<component_name>) to retrieve a child component\n c.item_id ||= name\n\n c.i18n = js_translate_properties if js_translate_properties.present?\n\n c.netzke_plugins = plugins.map{ |p| p.to_s.camelcase(:lower) } if plugins.present?\n\n # we need to pass them as strigs, not as symbols\n c.tools = c.tools.map(&:to_s) if c.tools.present?\n\n c.flash = session[:flash] if session[:flash].present?\n end", "def js_components\n @js_components ||= eagerly_loaded_components.inject({}) do |out, (name, config)|\n instance = component_instance(name.to_sym)\n out.merge(name => instance.js_config)\n end\n end", "def setup\n {\n :widget => self.widget_name,\n :widget_id => self.widget_id,\n :config => self.config.to_hash\n }\n end", "def make_plugin_hash; end", "def plugin_hash; end", "def setup_components\n Configurators::Base.descendants.each do |klass|\n klass.new(config).setup\n end\n end", "def setup_components\n config\n .internal\n .configurators\n .each { |configurator| configurator.call(config) }\n end", "def child_components()\n @child_components\n end", "def initialize\n @configurations = {}\n end", "def descriptor()\n delegation = lambda { |key| \"#{key || :parent}-first\" }\n path_elements = lambda do |xml, libs|\n libs.each { |lib| xml.tag! \"path-element\", \"lib/#{lib.to_s.pathmap('%f')}\" }\n end\n xml = Builder::XmlMarkup.new(:indent=>2)\n xml.instruct!\n xml.jbi :xmlns=>\"http://java.sun.com/xml/ns/jbi\", :version=>\"1.0\" do\n xml.component :type=>component.type.to_s.sub(\"_\", \"-\"),\n \"component-class-loader-delegation\"=>delegation[component.delegation],\n \"bootstrap-class-loader-delegation\"=>delegation[bootstrap.delegation] do\n xml.identification do\n xml.name component.name\n xml.description component.description\n end\n xml.tag!(\"component-class-name\", component.class_name)\n xml.tag!(\"component-class-path\") { path_elements[xml, component.libs] }\n xml.tag!(\"bootstrap-class-name\", bootstrap.class_name)\n xml.tag!(\"bootstrap-class-path\") { path_elements[xml, bootstrap.libs] }\n end\n end\n end", "def hivercs\n dynamic_hivercs + static_hivercs\n end", "def weak_children_config\n @weak_children_config ||= {}\n end", "def rpc_evasion\n { \"modules\" => self.framework.evasion.keys }\n end", "def config\n memoize(:config) do\n result = super\n result.fetch(:callbacks, :require, []).each do |c_loader|\n require c_loader\n end\n result\n end\n end", "def weak_children_config\n @weak_children_config ||= {}\n end", "def widget_options\n app_options = {}\n app_options[:level] ||= {}\n app_options[:level].merge! @level.properties.camelize_keys\n app_options.merge! view_options.camelize_keys\n app_options\n end", "def js_class(cached = [])\n # Defining the scope if it isn't known yet\n res = js_full_scope == \"Netzke.classes\" ? \"\" : %Q{\n if (!#{js_full_scope}) {\n Ext.ns(\"#{js_full_scope}\");\n }\n }\n\n if js_inheritance?\n # Using javascript inheritance\n res << <<-END_OF_JAVASCRIPT\n // Costructor\n #{js_full_class_name} = function(config){\n #{js_full_class_name}.superclass.constructor.call(this, config);\n };\n END_OF_JAVASCRIPT\n \n # Do we specify our own extend properties (overrriding js_extend_properties)? If so, include them, if not - don't re-include those from the parent!\n res << (singleton_methods(false).include?(\"js_extend_properties\") ? %Q{\n Ext.extend(#{js_full_class_name}, #{superclass.js_full_class_name}, #{js_extend_properties.to_nifty_json});\n } : %Q{\n Ext.extend(#{js_full_class_name}, #{superclass.js_full_class_name});\n })\n \n res << <<-END_OF_JAVASCRIPT\n Ext.reg(\"#{js_xtype}\", #{js_full_class_name});\n END_OF_JAVASCRIPT\n \n else\n # Menus\n js_add_menus = \"this.addMenus(#{js_menus.to_nifty_json});\" unless js_menus.empty?\n \n res << <<-END_OF_JAVASCRIPT\n // Constructor\n #{js_full_class_name} = function(config){\n // Do all the initializations that every Netzke widget should do: create methods for API-points,\n // process actions, tools, toolbars\n this.commonBeforeConstructor(config);\n // Call the constructor of the inherited class\n #{js_full_class_name}.superclass.constructor.call(this, config);\n // What every widget should do after calling the constructor of the inherited class, like\n // setting extra events\n this.commonAfterConstructor(config);\n };\n Ext.extend(#{js_full_class_name}, #{js_base_class}, Ext.applyIf(#{js_extend_properties.to_nifty_json}, Ext.widgetMixIn));\n Ext.reg(\"#{js_xtype}\", #{js_full_class_name});\n END_OF_JAVASCRIPT\n end\n \n res\n end", "def initialize_properties()\n # Find all superclasses\n classes = []\n clazz = self.class\n while !clazz.nil?\n classes << clazz\n clazz = clazz.superclass\n end\n classes.reverse!\n \n # Add properties from each component class\n classes.each do |clazz|\n add_properties(PropertyRegistry.get_properties(clazz))\n end\n end", "def component_config(component_name)\n @config[\"components\"][component_name.to_s]\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
All the JScode required by this instance of the component to be instantiated in the browser, excluding cached code. It includes JSclasses for the parents, eagerly loaded child components, and itself.
def js_missing_code(cached = []) code = dependency_classes.inject('') do |r, k| cached.include?(k.client_class_config.xtype) ? r : r + k.client_class_config.code_with_dependencies end code.blank? ? nil : Netzke::Core::DynamicAssets.minify_js(code) end
[ "def js_components\n @js_components ||= eagerly_loaded_components.inject({}) do |out, name|\n instance = component_instance(name.to_sym)\n out.merge(name => instance.js_config)\n end\n end", "def js_components\n @js_components ||= eagerly_loaded_components.inject({}) do |out, (name, config)|\n instance = component_instance(name.to_sym)\n out.merge(name => instance.js_config)\n end\n end", "def js_class(cached = [])\n # Defining the scope if it isn't known yet\n res = js_full_scope == \"Netzke.classes\" ? \"\" : %Q{\n if (!#{js_full_scope}) {\n Ext.ns(\"#{js_full_scope}\");\n }\n }\n\n if js_inheritance?\n # Using javascript inheritance\n res << <<-END_OF_JAVASCRIPT\n // Costructor\n #{js_full_class_name} = function(config){\n #{js_full_class_name}.superclass.constructor.call(this, config);\n };\n END_OF_JAVASCRIPT\n \n # Do we specify our own extend properties (overrriding js_extend_properties)? If so, include them, if not - don't re-include those from the parent!\n res << (singleton_methods(false).include?(\"js_extend_properties\") ? %Q{\n Ext.extend(#{js_full_class_name}, #{superclass.js_full_class_name}, #{js_extend_properties.to_nifty_json});\n } : %Q{\n Ext.extend(#{js_full_class_name}, #{superclass.js_full_class_name});\n })\n \n res << <<-END_OF_JAVASCRIPT\n Ext.reg(\"#{js_xtype}\", #{js_full_class_name});\n END_OF_JAVASCRIPT\n \n else\n # Menus\n js_add_menus = \"this.addMenus(#{js_menus.to_nifty_json});\" unless js_menus.empty?\n \n res << <<-END_OF_JAVASCRIPT\n // Constructor\n #{js_full_class_name} = function(config){\n // Do all the initializations that every Netzke widget should do: create methods for API-points,\n // process actions, tools, toolbars\n this.commonBeforeConstructor(config);\n // Call the constructor of the inherited class\n #{js_full_class_name}.superclass.constructor.call(this, config);\n // What every widget should do after calling the constructor of the inherited class, like\n // setting extra events\n this.commonAfterConstructor(config);\n };\n Ext.extend(#{js_full_class_name}, #{js_base_class}, Ext.applyIf(#{js_extend_properties.to_nifty_json}, Ext.widgetMixIn));\n Ext.reg(\"#{js_xtype}\", #{js_full_class_name});\n END_OF_JAVASCRIPT\n end\n \n res\n end", "def code\n @code ||= <<~JS\n #{set_up_js_variables}\n #{set_up_components}\n #{set_up_elements}\n #{render_to_string}\n return result;\n JS\n end", "def js_class_declaration_new_component\n mixins = js_mixins.empty? ? \"\" : %(#{js_mixins.join(\", \\n\")}, )\n %(#{js_full_class_name} = function(config){\n Netzke.aliasMethodChain(this, \"initComponent\", \"netzke\");\n #{js_full_class_name}.superclass.constructor.call(this, config);\n };\n\n Ext.extend(#{js_full_class_name}, #{js_base_class}, Netzke.chainApply(Netzke.componentMixin, #{mixins}\n #{js_extend_properties.to_nifty_json}));)\n end", "def js_scope\n js_class_name_to_scope(short_component_class_name)\n end", "def js_class_declaration_new_component\n mixins = js_mixins.empty? ? \"\" : %(#{js_mixins.join(\", \\n\")}, )\n %(#{js_full_class_name} = Ext.extend(#{js_base_class}, Netzke.chainApply(Netzke.componentMixin(#{js_base_class}), #{mixins}\n#{js_extend_properties.to_nifty_json}));)\n end", "def build_missing_beefjs_components(beefjs_components)\n print(\"beefnew\")\n end", "def js_configure(c)\n # Merge in component config options, besides those that are only meant for the server side\n # c.merge!(config.reject{ |k,v| self.class.server_side_config_options.include?(k.to_sym) })\n c.merge!(normalized_config)\n\n # Unique id of the component\n c.id = js_id\n\n # Configuration for all of our non-lazy-loaded children specified here. We can refer to them in +items+ so they get instantiated by Ext.\n c.netzke_components = js_components unless js_components.empty?\n\n # Endpoints (besides the default \"deliver_component\" - JavaScript side already knows about it)\n endpoints = self.class.endpoints.keys - [:deliver_component]\n\n # pass them as strings, not as symbols\n c.endpoints = endpoints.map(&:to_s) unless endpoints.empty?\n\n # Inform the JavaScript side if persistent_config is enabled\n # res[:persistent_config] = persistence_enabled?\n\n # Include our xtype\n c.xtype = self.class.js_config.xtype\n\n # Include our alias: Ext.createByAlias may be used to instantiate the component.\n c.alias = self.class.js_config.class_alias\n\n # So we can use getComponent(<component_name>) to retrieve a child component\n c.item_id ||= name\n\n c.i18n = js_translate_properties if js_translate_properties.present?\n\n c.netzke_plugins = plugins.map{ |p| p.to_s.camelcase(:lower) } if plugins.present?\n\n # we need to pass them as strigs, not as symbols\n c.tools = c.tools.map(&:to_s) if c.tools.present?\n\n c.flash = session[:flash] if session[:flash].present?\n end", "def initial_dynamic_javascript\n res = []\n # res << %(Ext.Ajax.extraParams = {authenticity_token: '#{form_authenticity_token}'}; // Rails' forgery protection)\n res << %{Ext.ns('Netzke');}\n res << %{Ext.ns('Netzke.core');}\n res << %{Netzke.RelativeUrlRoot = '#{ActionController::Base.config.relative_url_root}';}\n res << %{Netzke.RelativeExtUrl = '#{ActionController::Base.config.relative_url_root}/extjs';}\n\n res << %{Netzke.core.directMaxRetries = '#{Netzke::Core.js_direct_max_retries}';}\n\n res.join(\"\\n\")\n end", "def components_js\n Dir[src_path.join('components', '**', '*.js').to_s]\n end", "def netzke_js(_params = {})\n res = []\n res << content_for(:netzke_js_classes)\n\n res << 'Ext.onReady(function(){'\n res << content_for(:netzke_on_ready)\n res << '});'\n\n javascript_tag(res.join(\"\\n\"))\n end", "def builder_map_javascript_library\n container = CoffeeScript.compile(Rails.root.join('app/assets/javascripts/builder/container.js.coffee').read, :bare=>true)\n container = \"var queryStructure = queryStructure || {}; \\n\" + container\n reducer = CoffeeScript.compile(Rails.root.join('app/assets/javascripts/builder/reducer.js.coffee').read, :bare=>true)\n rules = CoffeeScript.compile(Rails.root.join('app/assets/javascripts/builder/rules.js.coffee').read, :bare=>true)\n return container + reducer + rules\n end", "def frontend_scripts\n\n @full_frontend_scripts ||= get_full_frontend_scripts\n\n end", "def MetaClass\n `#{self}.#{RubyJS.attr :class} = #{RubyJS.runtime :MetaClass}`\n `#{self}.#{RubyJS.attr :superclass} = #{nil}`\n `#{self}.#{RubyJS.attr :classname} = \"Class\"`\n `#{self}.#{RubyJS.attr :object_constructor} = #{RubyJS.runtime :MetaClass}`\n self\n end", "def javascript\n names.data[:JavaScript] ||= ref!(Prawn::Core::NameTree::Node.new(self, NAME_TREE_CHILDREN_LIMIT))\n end", "def javascript\n if defined? Prawn::NameTree\n names.data[:JavaScript] ||= ref!(Prawn::NameTree::Node.new(self, NAME_TREE_CHILDREN_LIMIT))\n elsif defined? Prawn::Core\n names.data[:JavaScript] ||= ref!(Prawn::Core::NameTree::Node.new(self, NAME_TREE_CHILDREN_LIMIT))\n elsif defined? PDF::Core::NameTree\n names.data[:JavaScript] ||= ref!(PDF::Core::NameTree::Node.new(self, NAME_TREE_CHILDREN_LIMIT))\n else\n raise \"Can't find Prawn's NameTree!\"\n end\n end", "def initial_dynamic_javascript\n res = []\n res << %(Ext.Ajax.extraParams = {authenticity_token: '#{form_authenticity_token}'}; // Rails' forgery protection)\n res << %{Ext.ns('Netzke');}\n res << %{Netzke.RelativeUrlRoot = '#{ActionController::Base.config.relative_url_root}';}\n res << %{Netzke.RelativeExtUrl = '#{ActionController::Base.config.relative_url_root}/extjs';}\n res.join(\"\\n\")\n end", "def include_js\n []\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
with the same values except the vowels removed remove_vowels(%w(abcdefghijklmnopqrstuvwxyz)) == %w(bcdfghjklmnpqrstvwxyz) remove_vowels(%w(green YELLOW black white)) == %w(grn YLLW blck wht) remove_vowels(%w(ABC AEIOU XYZ)) == ['BC', '', 'XYZ'] create method remove_vowels that takes an array called strings iterate with map, and delete any occurence of "aeiouAEIOU"
def remove_vowels(strings) strings.map { |string| string.delete "aeiouAEIOU" } end
[ "def remove_vowels(arr)\n arr.map { |string| string.gsub(/[aeiou]/i, '') }\nend", "def remove_vowels(ary)\n ary.map {|word| word.gsub(/[aeiouAEIOU]/, '')}\nend", "def remove_vowels(array)\n array.map { |string| string.gsub(/[aeiou]/i, '') }\nend", "def remove_vowels(words)\n words.map do |word|\n word.chars.select { |letter| !'aeiou'.include?(letter.downcase) }.join\n end\nend", "def remove_vowels(string_arr)\n string_arr.each do |word|\n word.gsub!(/[aeiou]/i,'')\n end\nend", "def remove_vowels(arr)\n arr.each { |string| string.gsub!(/[aeiou]/i, \"\") }\nend", "def remove_vowels(array)\r\n array.map {|word|word.delete(\"AEIOUaeiou\")}\r\nend", "def remove_vowels(array)\n array.map do |string|\n string.chars.select {|i| !'aeiou'.include?(i.downcase) }.join\n end\nend", "def remove_vowels(array)\n array.map do |word|\n word.chars.reject { |letter| %w[a e i o u].include?(letter.downcase) }.join\n end\nend", "def remove_vowels(strings)\n strings.each_with_object([]) do |string, arr|\n arr.push(string.gsub(/[aeiou]/i, ''))\n end\nend", "def remove_vowels(vowel_array)\n vowel_array.map {|string| consonant_array << string.delete('aeiouAEIOU')}\nend", "def remove_vowels(arr)\n final_arr = []\n arr.each do |str|\n final_arr << str.gsub(/[aeiou]/i, '')\n end\n final_arr\nend", "def remove_vowels(string_arr)\n output = []\n output = string_arr.each do |string|\n string.chars.each do |letter|\n if letter.match(/[AEIOUaeiou]/)\n string.delete!(letter)\n end \n end \n end \n output\nend", "def remove_vowels(string)\n array_string = string.split('')\n array_string.each do |char|\n char.gsub!(/[aeiou]/i, \"\")\n end\n\n array_string.join\nend", "def remove_vowels(str_arr)\n result = []\n str_arr.each do |string|\n result << string.chars.reject{|letter| letter =~ /[aeiou]/i }.join\n end\n result\nend", "def remove_vowels(array)\n new_array = []\n array.each do |word|\n vowels = %w(a e i o u)\n new_word = []\n word.each_char do |char|\n if vowels.include?(char.downcase) == false\n new_word << char\n end\n end\n new_array << new_word.join('')\n end\n new_array\nend", "def strip_vowels(s)\n s.delete \"aeiouAEIOU\"\nend", "def convert_vowels_and_no_repeats\n removed = []\n self.chars.to_a.reduce(nil) do |prev,cur|\n cur = 'a' if vowels.include?(cur) \n removed << cur unless prev.eql?(cur)\n cur \n end\n removed.join\n end", "def vowel_remover string\n# Using the .delete method, remove all the vowels from the string by passing all lowercase and uppercase vowels to the .delete method.\n# print the result\n p string.delete \"aeiouAEIOU\"\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Ask the influencer to link his twitter account
def link_twitter end
[ "def twitter\n end", "def twitter\n process_login\n end", "def twitter_link(player)\n if player.twitter_screen_name\n # clean up any bad characters in a player's twitter name\n twitter_user = player.twitter_screen_name.sub(/^.*[@\\/]/, '')\n\n link_to(\"@\" + twitter_user, \"http://twitter.com/#{twitter_user}\")\n end\n end", "def twitter_url; \"https://twitter.com/#{twitter}\" end", "def twitter_url\n twitter_user.blank? ? nil : \"#{TWITTER_URL}#{twitter_user}\"\n end", "def twitter\n process_omniauth_callback('twitter')\n end", "def twitter_link\n @twitter_link ||= APPLICATION_CONFIG['twitter_link']\n end", "def twitter_url\n Settings.twitter_url\n end", "def twitter_handle\n if twitter = self.identity(:twitter)\n twitter.handle\n end\n end", "def tweet(following)\n end", "def set_Twitter(value)\n set_input(\"Twitter\", value)\n end", "def post_to_twitter\n tweet = event_post_to_twitter(current_user.events.find(params[:id]))\n if tweet\n tweet_url = \"https://twitter.com/#{current_user.twitter_username}/status/#{tweet.id}\"\n redirect_to request.referer,\n :flash => { :success => \"Your event has been twitted,\n <br><i class='fa fa-twitter'></i> \n <a href='#{tweet_url}' rel='nofollow' target='_blank'>#{tweet_url}</a>\" }\n else\n redirect_to request.referer, :flash => { :error => \"Ooops. something wrong\" }\n end\n end", "def connect_twitter\r\n redirect_to \"/auth/twitter?path=#{params['path']}\"\r\n end", "def tw_profile_url\n \"http://twitter.com/intent/user?user_id=#{tw_user_id}\"\n end", "def twitter_link\n @twitter_link ||= ENV['APPLICATION_CONFIG_twitter_link']\n end", "def twitter\n get_authorization(:twitter)\n end", "def twitter_url_for(username)\n \"http://twitter.com/#{username}\"\n end", "def display_twitter_auth_url\n @oauth ||= Twitter::OAuth.new(TWITTER[:consumer_key], TWITTER[:consumer_secret])\n puts \"Log in as #{twitter_handle.blank? ? 'the character' : twitter_handle} and then paste this into your browser\"\n puts @oauth.request_token.authorize_url\n nil\n end", "def follow_intent_link(options = {}, &block)\n user_id_to_follow = options[:user_id] || Flakey.configuration.twitter_user_id\n screen_name_to_follow = options[:screen_name] || \n Flakey.configuration.twitter_handle\n label = options.has_key?(:label) ? options.delete(:label) : \"Follow Me\"\n\n intent_url = 'https://twitter.com/intent/user?'\n\n if user_id_to_follow\n intent_url += \"user_id=#{user_id_to_follow}\"\n end\n\n intent_url += '&' if user_id_to_follow && screen_name_to_follow\n\n unless screen_name_to_follow == ''\n intent_url += \"screen_name=#{screen_name_to_follow}\"\n end\n\n if block_given?\n link_to(intent_url, options.except(:user_id, :screen_name), &block)\n else\n link_to label, intent_url, options.except(:user_id, :screen_name)\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Omniauth setup phase hook, that is used to dynamically set up a omniauth strategy for provider on customer basis
def auth_setup service = Person::OmniauthService::SetupPhase.new(community: @current_community, params: params, request: request) service.run render :plain => "Setup complete.", :status => 404 #This notifies the ominauth to continue end
[ "def omniauth(provider, *args); end", "def facebook_setup\n request.env[\"omniauth.strategy\"].options[:client_id] = @current_community.facebook_connect_id || APP_CONFIG.fb_connect_id\n request.env[\"omniauth.strategy\"].options[:client_secret] = @current_community.facebook_connect_secret || APP_CONFIG.fb_connect_secret\n request.env[\"omniauth.strategy\"].options[:iframe] = true\n request.env[\"omniauth.strategy\"].options[:scope] = \"public_profile,email\"\n request.env[\"omniauth.strategy\"].options[:info_fields] = \"name,email,last_name,first_name\"\n\n render :text => \"Setup complete.\", :status => 404 #This notifies the ominauth to continue\n end", "def facebook_setup\n request.env[\"omniauth.strategy\"].options[:client_id] = @current_community.facebook_connect_id || APP_CONFIG.fb_connect_id\n request.env[\"omniauth.strategy\"].options[:client_secret] = @current_community.facebook_connect_secret || APP_CONFIG.fb_connect_secret\n request.env[\"omniauth.strategy\"].options[:iframe] = true\n request.env[\"omniauth.strategy\"].options[:scope] = \"public_profile,email\"\n request.env[\"omniauth.strategy\"].options[:info_fields] = \"name,email,last_name,first_name\"\n\n render :plain => \"Setup complete.\", :status => 404 #This notifies the ominauth to continue\n end", "def callback_phase #(*args)\n # This technique copied from OmniAuth::Strategy,\n # (this is how they do it for other omniauth objects).\n env['omniauth.authorize_params'] = session.delete('omniauth.authorize_params')\n super\n end", "def apply_omniauth(omniauth)\n case omniauth['provider']\n when 'facebook'\n self.apply_facebook(omniauth)\n end\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'], :token =>(omniauth['credentials']['token'] rescue nil))\n end", "def apply_omniauth(omniauth)\n # self.email = omniauth['info']['email'] if email.blank? # Twitter does not return an email\n authentications.build(provider: omniauth[\"provider\"], uid: omniauth[\"uid\"])\n end", "def social_setup(provider)\n omniauth = request.env[\"omniauth.auth\"]\n facebook_display = session['omniauth.facebook.display']\n\n if request.env[\"omniauth.error\"].present?\n flash[:error] = I18n.t(\"devise.omniauth_callbacks.failure\", :kind => provider, :reason => I18n.t(:reason_user_was_not_valid))\n if facebook_display == 'popup'\n return render :close_window, :layout => nil\n else\n return redirect_back_or_default(root_url)\n end\n end\n\n existing_auth = UserAuthentication.where(:provider => omniauth['provider'], :uid => omniauth['uid'].to_s).first\n \n email = omniauth[\"extra\"][\"user_hash\"][\"email\"]\n email_user = Spree::User.find_by_email(email)\n \n # If the person had created a soletron account and now has a Facebook auth linked to an anonymous account\n # => then destroy the link to the anonymous account\n # The other checks in the code, will display the proper errors, since existing_auth is set to nil\n if existing_auth and existing_auth.user.anonymous? and email_user\n existing_auth.destroy\n existing_auth = nil\n end\n \n ##\n # This statement slightly modified for Soletron\n ##\n #signing back in from a social source\n user = if existing_auth\n existing_auth.user\n elsif current_user# adding a social source - changed to elsif from else\n current_user\n else\n # New for Soletron. Create a new user, not an anonymous one\n \n # If the email provided by the provider already has a Soletron account, then it will ask the person to\n # login with that account and link to the provider\n #\n # This also handles the case above where the existing_auth is attached to an anonymous user, but\n # the database has a user already attached to the email address.\n if email_user\n flash[:error] = \"A Soletron account has already been created for the email supplied by your #{omniauth['provider'].capitalize} account. For your security, please login with your Soletron account, then link your account to #{omniauth['provider'].capitalize}\"\n if facebook_display == 'popup'\n return render :close_window, :layout => nil\n else\n return render :template => \"user_sessions/new\"\n end\n end\n \n random_password = Digest::SHA512.hexdigest \"#{email}-#{rand()}\"\n user = Spree::User.new(:email => email, :password => random_password, :password_confirmation => random_password, :name => omniauth[\"extra\"][\"user_hash\"][\"first_name\"], :birthday => (DateTime.now - 21.year), :confirmed_at => DateTime.now)\n user.generate_username\n #at_sym = email.index(\"@\")\n #if at_sym.nil?\n # username = email\n #else\n # username = email[0,at_sym]\n #end\n #random_username = \"#{username}#{rand(1000)}\"\n #user = Spree::User.create(:email => email, :password => random_password, :password_confirmation => random_password, :name => omniauth[\"extra\"][\"user_hash\"][\"first_name\"], :birthday => (DateTime.now - 21.year), :username => random_username, :confirmed_at => DateTime.now)\n if !user.save! # BUGBUG (aslepak) - need error handling in case .create fails (likely reason - we randomly generated a non-unique username), the two lines below don't seem to be working...\n puts \"user failed because #{user.errors}\"\n flash[:error] = \"Failed to create a Facebook user - please try again. #{user.errors}\"\n redirect_back_or_default(account_url)\n end\n user\n end\n \n ## Commented out for Soletron, because the else above handles it\n #user ||= Spree::User.anonymous!\n\n user.associate_auth(omniauth) unless existing_auth\n \n # add Facebook access token\n if omniauth['provider'] == 'facebook'\n puts \"updating facebook auth to token #{omniauth[\"credentials\"][\"token\"]}\"\n user.facebook_auth.update_attributes(:access_token => omniauth[\"credentials\"][\"token\"])\n end\n\n if current_order\n current_order.associate_user!(user)\n session[:guest_token] = nil\n end\n \n #puts \"referer #{request.referer}\"\n \n if user.anonymous? # This should not happen anymore, but leaving it\n random_password = Digest::SHA512.hexdigest \"#{email}-#{rand()}\"\n user.update_attributes(:email => email, :password => random_password, :password_confirmation => random_password, :name => omniauth[\"extra\"][\"user_hash\"][\"first_name\"], :birthday => (DateTime.now - 21.year))\n \n #session[:user_access_token] = user.token #set user access token so we can edit this user again later\n \n #flash.now[:notice] = t(\"one_more_step\", :kind => omniauth['provider'].capitalize)\n #render(:template => \"user_registrations/social_edit\", :locals => {:user => user, :omniauth => omniauth})\n elsif current_user\n # turned end if of flash[:error] into a statement\n if existing_auth && (existing_auth.user != current_user)\n flash[:error] = t(\"attach_error\", :kind => omniauth['provider'].capitalize)# if existing_auth && (existing_auth.user != current_user)\n #elsif omniauth['provider'] == 'facebook'\n # pull_facebook_data(user)\n # check_permissions(user)\n # check_data(user)\n end\n \n #if facebook_display == 'popup'\n # render :close_window, :layout => nil\n #else\n # redirect_back_or_default(account_url)\n #end\n else\n #if omniauth['provider'] == 'facebook'\n # pull_facebook_data(user)\n # check_permissions(user)\n # check_data(user)\n #end\n sign_in(user, :event => :authentication)\n \n #if facebook_display == 'popup'\n # render :close_window, :layout => nil\n #else\n # redirect_back_or_default(account_url)\n #end\n end\n \n if omniauth['provider'] == 'facebook' and flash[:error].nil? and flash[:alert].nil?\n pull_facebook_data(user)\n check_permissions(user)\n check_data(user)\n end\n \n if facebook_display == 'popup'\n close_window_redirect(true) # redirect_to '/close_window', :layout => nil\n elsif session[\"user_return_to\"] != login_path\n redirect_back_or_default(account_url)\n else\n redirect_to(account_url)\n end\n end", "def callback_phase\n raise OmniAuth::NoSessionError.new(\"Session Expired\") if session['oauth'].nil?\n\n request_token = FellowshipOneRequestToken.new(consumer, session['oauth'][name.to_s].delete('request_token'), session['oauth'][name.to_s].delete('request_secret'))\n\n opts = {}\n if session['oauth'][name.to_s]['callback_confirmed']\n opts[:oauth_verifier] = request['oauth_verifier']\n else\n opts[:oauth_callback] = callback_url\n end\n\n @access_token = request_token.get_access_token(opts)\n # IMPORTANT: DO NOT REMOVE THIS! WE DO NOT WANT TO CALL\n # OmniAuth::Strategies::OAuth::callback_phase here! So, we must copy\n # OmniAuth::Strategy::callback_phase here\n\n # super\n self.env['omniauth.auth'] = auth_hash\n call_app!\n rescue ::Timeout::Error => e\n fail!(:timeout, e)\n rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e\n fail!(:service_unavailable, e)\n rescue ::OAuth::Unauthorized => e\n fail!(:invalid_credentials, e)\n rescue ::NoMethodError, ::MultiJson::DecodeError => e\n fail!(:invalid_response, e)\n rescue ::OmniAuth::NoSessionError => e\n fail!(:session_expired, e)\n end", "def multi_factor_auth_phone_setup(success:,\n errors:,\n otp_delivery_preference:,\n area_code:,\n carrier:,\n country_code:,\n phone_type:,\n types:,\n **extra)\n track_event(\n 'Multi-Factor Authentication: phone setup',\n success: success,\n errors: errors,\n otp_delivery_preference: otp_delivery_preference,\n area_code: area_code,\n carrier: carrier,\n country_code: country_code,\n phone_type: phone_type,\n types: types,\n **extra,\n )\n end", "def setup_oai_provider\n \t@@provider_set ||= false\n \treturn if @@provider_set\n OaiProvider.class_eval do\n repository_name APP_CONFIG['oai_settings']['repository_name']\n repository_url APP_CONFIG['oai_settings']['repository_url']\n record_prefix APP_CONFIG['oai_settings']['record_prefix']\n admin_email APP_CONFIG['oai_settings']['admin_email']\n source_model OAI::Provider::ActiveRecordWrapper.new(Publication.oai_selection, {limit: APP_CONFIG['oai_settings']['max_no_of_records']})\n end\n OAI::Provider::Base.register_format(OAI::Provider::Metadata::OAI_MODS.instance)\n @@provider_set = true\n end", "def configure_backend!(config, backend, id = nil, secret = nil)\n return unless Rails.env.test? || APP_CONFIG.enabled?(\"oauth.#{backend}\")\n\n options = send(\"#{backend}_fetch_options\")\n\n if id\n config.omniauth backend, id, secret, options\n else\n config.omniauth backend, options\n end\nend", "def orcid_preprocessor\n @auth_hash = request.env['omniauth.auth']\n @params = request.env['omniauth.params']\n if @params['origin'] == 'feedback'\n session[:origin] = @params['origin']\n session[:contact_method] = @params['m']\n session[:link_location] = @params['l']\n elsif @params['origin'] == 'metadata'\n metadata_callback\n elsif @params['invitation'] && @params['identifier_id']\n orcid_invitation\n end\n setup_orcid\n end", "def create_omniauth\n org_uid = params[:state]\n organization = Maestrano::Connector::Rails::Organization.find_by_uid_and_tenant(org_uid, current_user.tenant)\n\n if organization && is_admin?(current_user, organization)\n organization.from_omniauth(env[\"omniauth.auth\"])\n\n # Fetch SalesForce user details\n user_details = Maestrano::Connector::Rails::External.fetch_user(organization)\n current_user.update_attribute(:locale, user_details['locale'])\n current_user.update_attribute(:timezone, user_details['timezone'])\n\n # Fetch SalesForce company name\n company = Maestrano::Connector::Rails::External.fetch_company(organization)\n organization.update_attribute(:oauth_name, company['Name'])\n organization.update_attribute(:oauth_uid, company['Id'])\n end\n\n redirect_to root_url\n end", "def lti_setup\n lti_configuration = LtiConfiguration.find_by(consumer_key: request.params[\"oauth_consumer_key\"])\n raise LtiLaunchError.new(nil), \"Configured consumer key is invalid.\" unless lti_configuration\n\n strategy = request.env[\"omniauth.strategy\"]\n raise LtiLaunchError.new(nil), \"Incoming request is not a LTI launch\" unless strategy\n\n strategy.options.consumer_key = lti_configuration.consumer_key\n strategy.options.shared_secret = lti_configuration.shared_secret\n head :ok\n end", "def add_provider_auth(auth_info)\n pa = self.provider_authorizations.build\n pa.assign_auth_info(auth_info)\n pa.auth_info = auth_info\n pa.save\n pa\n end", "def create_authentication(omniauth)\n authentications.create! do |a|\n a.provider = omniauth.provider\n a.uid = omniauth.uid\n end\n end", "def register_middleware(omniauth)\n raise NotImplementedError\n end", "def omniauth_with(&blk)\n @omniauth_cb = blk if blk\n @omniauth_cb\n end", "def mock_omniauth(provider, test_mode=true)\n\n # call method with mock values and attributes for given provider\n params_provider = send(\"params_#{provider}\")\n\n # deactivate test_mode\n OmniAuth.config.test_mode = test_mode ? true : false\n\n #deliver omniauth mock credentials\n OmniAuth.config.add_mock(provider.to_sym, params_provider)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Callback from Omniauth failures
def failure origin_locale = get_origin_locale(request, available_locales()) I18n.locale = origin_locale if origin_locale error_message = params[:error_reason] || "login error" kind = request.env["omniauth.error.strategy"].name.to_s || "Facebook" flash[:error] = t("devise.omniauth_callbacks.failure",:kind => kind.humanize, :reason => error_message.humanize) redirect_to search_path end
[ "def failure\n I18n.locale = URLUtils.extract_locale_from_url(request.env['omniauth.origin']) if request.env['omniauth.origin']\n error_message = params[:error_reason] || \"login error\"\n kind = env[\"omniauth.error.strategy\"].name.to_s || \"Facebook\"\n flash[:error] = t(\"devise.omniauth_callbacks.failure\",:kind => kind.humanize, :reason => error_message.humanize)\n redirect_to root\n end", "def omniauth_failure\n # Error and error_description come from Auth0. Ex: unauthorized and password_expired.\n error_type = (params[\"error\"] || \"\").to_sym\n error_code = (params[\"error_description\"] || \"\").to_sym\n unless params[\"error\"] && params[\"error_description\"]\n LogUtil.log_error(\n \"omniauth_failure called with missing error or error_description.\",\n error_type: error_type,\n error_description: error_code\n )\n end\n\n if error_type.present? && error_type == AUTH0_LOGIN_REQUIRED.to_sym\n # Silent login is expired, we need to logout current user\n logout\n elsif error_type.present? && error_type == AUTH0_UNAUTHORIZED.to_sym\n # Display 'unauthorized' errors but go to `failure` endpoint for all others.\n @message = if ERROR_EXPLANATIONS.key?(error_code)\n ERROR_EXPLANATIONS[error_code]\n else\n ERROR_EXPLANATIONS[:default]\n end\n render :omniauth_failure\n else\n failure\n end\n end", "def oauth_failure\n env = request.env\n # logger.debug2 \"env.keys = #{env.keys.sort.join(', ')}\"\n # logger.debug2 \"env = #{env} (#{env.class})\"\n error = env['omniauth.error']\n type = env['omniauth.error.type']\n strategy = env['omniauth.error.strategy']\n logger.debug2 \"error = #{error} (#{error.class})\"\n logger.debug2 \"error.methods = #{error.methods.sort.join(', ')}\"\n logger.debug2 \"error.message = #{error.message} (#{error.message.class})\"\n\n # check cancelled facebook login\n # Parameters: {\"error_reason\"=>\"user_denied\",\n # \"error\"=>\"access_denied\",\n # \"error_description\"=>\"The user denied your request.\", \"state\"=>\"480ee4d402ad5b940d6b48\n # error.message = OmniAuth::Strategies::OAuth2::CallbackError (String)\n # request_uri = http://localhost/auth/facebook/callback?error_reason=user_denied&error=access_denied&error_description=The+user+denied+your+request.&state=480ee4d402ad5b940d6b48805c6ec91ac70f840d400ac998\n # type = invalid_credentials (Symbol)\n # error.class = OmniAuth::Strategies::OAuth2::CallbackError\n # error.message = OmniAuth::Strategies::OAuth2::CallbackError\n request_uri = env['REQUEST_URI']\n uri_prefix = \"#{SITE_URL}auth/facebook/callback?error\"\n if request_uri.first(uri_prefix.length) == uri_prefix and\n type == :invalid_credentials and\n error.class == OmniAuth::Strategies::OAuth2::CallbackError and\n params[:error] == 'access_denied'\n logger.debug2 \"facebook login was cancelled\"\n save_flash_key \".login_cancelled\", :provider => 'facebook', :appname => APP_NAME\n redirect_to :controller => :auth\n return\n end\n\n # todo: check cancelled google+ login\n # no cancel button in google+ - use have to use back button\n\n # check for cancelled linkedin login\n # that is first logon with scope r_basicprofile r_network\n # and additional authorisation with scope r_basicprofile r_network rw_nus.)\n type = env['omniauth.error.type']\n if request_uri == \"#{SITE_URL}auth/linkedin/callback\" and\n type == :invalid_credentials and\n error.class == OAuth::Problem and\n error.message == 'parameter_absent'\n client = get_linkedin_api_client()\n if client\n logger.debug2 \"request for linked rw_nus priv. was cancelled\"\n save_flash_key \".linkedin_rw_nus_cancelled\", :appname => APP_NAME\n redirect_to :controller => :gifts\n else\n logger.debug2 \"linkedin login was cancelled\"\n save_flash_key \".login_cancelled\", :provider => 'linkedin', :appname => APP_NAME\n redirect_to :controller => :auth\n end\n return\n end\n\n # todo: check cancelled twitter login\n # twitter login fejlede! invalid_credentials: 401 Unauthorized\n logger.debug2 \"request_uri = #{request_uri}\"\n logger.debug2 \"type = #{type} (#{type.class})\"\n logger.debug2 \"error.class = #{error.class}\"\n logger.debug2 \"error.message = #{error.message}\"\n # request_uri = http://localhost/auth/twitter/callback?denied=2ddtp3zYx5CdldwXCOshMuFVC3QEiAMyAJpKUbO4Fc\n # type = invalid_credentials (Symbol)\n # error.class = OAuth::Unauthorized\n # error.message = 401 Unauthorized\n # Parameters: {\"denied\"=>\"2ddtp3zYx5CdldwXCOshMuFVC3QEiAMyAJpKUbO4Fc\"}\n uri_prefix = \"#{SITE_URL}auth/twitter/callback?denied=\"\n if request_uri.first(uri_prefix.length) == uri_prefix and\n type == :invalid_credentials and\n error.class == OAuth::Unauthorized and\n error.message == '401 Unauthorized'\n logger.debug2 \"twitter login was cancelled\"\n save_flash_key \".login_cancelled\", :provider => 'twitter', :appname => APP_NAME\n redirect_to :controller => :auth\n return\n end\n\n # logger.debug2 \"type = #{type}\"\n # logger.debug2 \"strategy = #{strategy}\"\n # logger.debug2 \"strategy.methods = #{strategy.methods.sort.join(', ')}\"\n # logger.debug2 \"strategy.name = #{strategy.name}\"\n #error = :\n # {\n # \"errorCode\": 0,\n # \"message\": \"Unable to verify access token\",\n # \"requestId\": \"K7SXSRYQUA\",\n # \"status\": 401,\n # \"timestamp\": 1384762283211\n #}\n #type = invalid_credentials\n #strategy = #<OmniAuth::Strategies::LinkedIn:0xb6480cb8>\n #strategy.name = linkedin\n message = $1 if error.message =~ /\"message\": \"(.*?)\"/\n message = error.message unless message\n message = message.to_s.first(40)\n # flash[:notice] = \"Authentication failure! #{type}: #{message}\"\n save_flash_key '.authentication_failure', :provider => provider_downcase(strategy.name), :type => type, :message => message\n redirect_to '/auth'\n end", "def specific_oauth_error(resp, error_code, context); end", "def invalid_oauth_response; end", "def default_oauth_fail\n auth = request.env['omniauth.auth']\n session.delete(\"devise.#{auth.provider.to_s}_data\")\n flash[:alert] = @user.errors.to_a[0] if @user.errors\n redirect_to auth.fail_redirect\n end", "def on_auth_failed(msg)\n emit('auth', false, msg)\n end", "def no_user_with_facebook_uid_or_email_attempt\n warden.custom_failure!\n render :status => 401,\n :json => { :errors => \"User with specified facebook uid or email is not found\", code: 16 },\n :success => false\n end", "def callback_failure\n flash[:error] = I18n.t(:connection_failure)\n\t redirect_to root_url\n\tend", "def failure\n redirect_to members_social_sign_up_path\n end", "def failure\n network = session.delete(:signup_flow_network)\n if params[:message] == 'invalid_credentials'\n scope = session.delete(:signup_flow_scope)\n lambda = network ? Network.klass(network).auth_failure_lambda(scope: scope) : nil\n if lambda && current_user\n lambda.call(current_user)\n set_flash_message(:notice, Network.klass(network).auth_failure_message(scope: scope))\n else\n # When we try to connect the user and fail because the connection was cancelled (ie. we're denied permission\n # by user), we show the signup modal on load with the alert inside the modal rather than float at top of page.\n session[:hide_global_flash] = session[:show_signup_alert] = true\n session[:force_auth] = :immediate\n set_flash_message(:alert, :cancelled)\n end\n else\n msg = \"Network connection failure for user #{current_user ? current_user.person_id : 'unregistered user'}: #{params[:message]}\"\n logger.error(msg)\n if e = request.env['omniauth.error']\n log_stack_trace(e)\n end\n set_flash_message(:alert, :error_communicating)\n end\n respond_to do |format|\n format.html { redirect_to session.delete(:signup_flow_destination) || request.env['omniauth.origin'] || root_path }\n format.json { render_jsend(error: :external_service_failed) }\n end\n end", "def omniauth(provider, *args); end", "def auth_fail\n fail(Kankri::AuthenticationFailure)\n end", "def google_oauth_success\n \n end", "def failure\n msg_returned = request.params['message']\n login_failed msg_returned.nil? ? 'Auth0 login failed.' : msg_returned\n end", "def auth_fail(*args, &blk)\n block_given? ? @auth_fail_cbs << blk : @auth_fails.push(args)\n while (fail_data = @auth_fails.shift)\n @auth_fail_cbs.each { |cb| cb.call(*fail_data) }\n end\n end", "def handle_errored_login(code)\n Log.error(\"error code #{code}.\")\n end", "def handle_failed_login\n Log.error(\"failure.\")\n end", "def failed_handler\n config(:failed, :failed_auth_handler)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
same as onstatechange_register, but autounregisters if the block returns true
def onstatechange_register_once handle = onstatechange_register { |st| onstatechange_unregister(handle) if yield(st) } end
[ "def on_actuator_state(&block)\n\t\t\t@on_actuator_state = block\n\t\tend", "def register_state_handler(state, &block)\n register(state_key(state), &block)\n end", "def register_state_handler(state, &block)\n register(\"state_#{state}\", &block)\n end", "def on_led_change( &block )\n @led_handler = block\n end", "def on_confchg(&block)\n\t\t@confchg_callback = block\n\tend", "def register_automatically(user, &block)\n # Automatic activation\n user.activate\n user.last_login_on = Time.now\n if user.save\n self.logged_user = user\n flash[:notice] = l(:notice_account_activated)\n redirect_to my_account_path\n else\n yield if block_given?\n end\n end", "def on_satellites_change(&block)\n\t\t\t@on_satellites_change = block\n\t\tend", "def register_automatically(user, &block)\n # Automatic activation\n user.activate\n user.last_login_on = Time.now\n if user.save\n self.logged_user = user\n send_notice l(:notice_account_activated)\n #redirect_to :controller => 'my', :action => 'account'\n #redirect_to editorial_url\n redirect_back_or_default(editorial_url)\n else\n yield if block_given?\n end\n end", "def on_activation(&block)\n @activation_callback = block\n self\n end", "def onStateChange(&callbackBlock)\r\n @stateCallback = callbackBlock\r\n end", "def once_state_changed(options = {}, &block)\n raise ArgumentError, 'Block required' unless block_given?\n\n once_block = lambda do |*args|\n off(*self.class::STATE.map, &once_block)\n yield(*args)\n end\n\n safe_unsafe_method options[:unsafe], :once, *self.class::STATE.map, &once_block\n end", "def on_idle(&block)\n backend.idle_proc = block\n end", "def when_ready(&block)\n handle :ready, &block\n end", "def on_status(&block)\n @on_status = block\n end", "def on_check_completed(&block)\n @check_completed_handler = block\n end", "def on_status_withheld(&block)\n on('status_withheld', &block)\n end", "def on_activate(&b)\n @on_activate_cb = b\n end", "def on_quorumchg(&block)\n\t\t@quorumchg_callback = block\n\tend", "def while_activated(name)\n if activated?(name)\n yield if block_given?\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return true if the argument is under the cursor
def at_cursor?(obj) same_pos?(obj, cursor) end
[ "def move_up?\n @cursor > 0\n end", "def needs_cursor?\n\t\t@show_cursor\n\tend", "def cursor_left?\r\n @item_window.index % 2 == 0\r\n end", "def cursor_movable?\n active\n end", "def cursor_movable?\n return false\n end", "def same_cursor_position?\n window.cursor[1] == @history.start_pos && \n window.cursor[0] == @history.line_number\n end", "def thresh_select?\n\t\t@sub_cursor != SUB_NONE\n\tend", "def check_cursor!\n @current_cursor or raise NoCursor.new(\"You have not defined anything to work with!\")\n end", "def cursor_movable?\n active && open? && !@cursor_fix && !@cursor_all\n end", "def start?\n @cursor == 0\n end", "def cursor_can_move_left?\n return (@cursor_position > 0)\n end", "def cursor_visible?(name)\n buffer(name).cursor_visible?\n end", "def cursor_visible?\n if front?\n front.cursor_visible?\n\n elsif previous?\n previous.cursor_visible?\n\n else\n interface.cursor_visible?\n\n end\n end", "def center_select?\n\t\t@sub_cursor == SUB_NONE\n\tend", "def cursor_visible?\n AMS::Cursor.is_visible?\n end", "def only_cursor_moved flag=true\n @cursor_movement = flag\nend", "def alive?\n @cursor_id != CLOSED_CURSOR\n end", "def cursor_can_move_right?\n return (@cursor_position < @text.scan(/./m).size)\n end", "def refresh_view?\n cursor.visible? && cursor.ox >= width || cursor.oy >= height\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns true if both arguments are at the same x/y/z
def same_pos?(pos1, pos2) pos1 = pos1.pos if pos1.respond_to?(:pos) pos2 = pos2.pos if pos2.respond_to?(:pos) pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z end
[ "def Point3dEqual(arg0, arg1)\n ret = _invoke(1610743875, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def == point\t\n\t\t@x == point.x && @y == point.y\t\n\tend", "def Range3dEqual(arg0, arg1)\n ret = _invoke(1610744093, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def in? instance, x1,y1,x2,y2,z\n return false if @z!=z\n csize = instance.option_manager['chunk size'].to_i\n if @x+csize>=x1 and\n @x<=x2 and\n @y+csize>=y1 and\n @y<=y2\n return true\n else\n return false\n end\n end", "def Vector3dEqual(arg0, arg1)\n ret = _invoke(1610744204, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def equivalent_with_at_least_two(x, y, z, t)\n rule1 = f_and(\n f_or(f_not(x), y, z),\n f_or(f_not(x), y, t),\n f_or(f_not(x), z, t)\n )\n\n rule2 = f_and(\n f_or(x, f_not(y), f_not(z)),\n f_or(x, f_not(y), f_not(t)),\n f_or(x, f_not(z), f_not(t))\n )\n\n f_and(rule1, rule2)\n end", "def same_as_player?(obj)\n obj.x == @player.x && obj.y == @player.y\n end", "def all_same?(first_operand, arglist)\n if arglist.empty?\n boolean(true)\n else\n first_value = first_operand.value\n all_equal = arglist.all? { |elem| first_value == elem.value }\n boolean(all_equal)\n end\n end", "def ==(point2)\n end", "def inp(x, *a)\n a.each {|v| return true if x === v}\n return false\nend", "def same?(point, delta = POINT_DELTA)\n if ((@x + delta > point.x && @x - delta < point.x &&\n @y + delta > point.y && @y - delta < point.y))\n return true\n end\n return false\n end", "def same_parameters?(o)\n @bf.m == o.bf.m && @bf.k == o.bf.k &&\n @bf.s == o.bf.s && @bf.b == o.bf.b\n end", "def is_isosceles?(a,b,c)\n if (a==b and b!=c) || (a!=b and a==c) || (a!=b and b==c)\n return true\n else\n return false\n end\nend", "def ==(other_point)\r\n if other_point.class != self.class\r\n false\r\n else\r\n @x == other_point.x and @y == other_point.y and @z == other_point.z and @m == other_point.m\r\n end\r\n end", "def isSame(tab)\n for x in 0..3\n for y in 0..3\n return(false) if (self.val(x,y) != tab.val(x,y)) ;\n end\n end\n return true ;\n end", "def ==(other)\n return false unless other.is_a? CommandArgs\n @args == other.args && @kwargs == other.kwargs\n end", "def ==(other)\n if other.instance_of?(Point)\n self.x == other.x && self.y == other.y\n else\n false\n end\n end", "def coincidental?\n point_a.coincident?(point_b) ||\n point_b.coincident?(point_c) ||\n point_a.coincident?(point_c)\n end", "def arguments_equal?(a, b)\n # Return true if both don't have args.\n # Return false if only one doesn't have args\n return true unless a.respond_to?(:arguments) && b.respond_to?(:arguments)\n return false unless a.respond_to?(:arguments) || b.respond_to?(:arguments)\n\n a.arguments.map { |arg| {name: arg.name, value: arg.value}.to_s }.sort ==\n b.arguments.map { |arg| {name: arg.name, value: arg.value}.to_s }.sort\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
try to match a userspecified name to one from the raws uses caseswitching and substring matching eg match_rawname('coal', ['COAL_BITUMINOUS', 'BAUXITE']) => 'COAL_BITUMINOUS'
def match_rawname(name, rawlist) rawlist.each { |r| return r if name == r } rawlist.each { |r| return r if name.downcase == r.downcase } may = rawlist.find_all { |r| r.downcase.index(name.downcase) } may.first if may.length == 1 end
[ "def is_proper(name)\n return name == (name[0].upcase + name[1..-1].downcase)\nend", "def get_perhiperal_default_name(raw_name)\n if bettermatch = /(?<better>[A-Z0-9]{3,})/.match(raw_name)\n return bettermatch[:better]\n end\n\n return raw_name\nend", "def proper_name(name)\n return name if name =~ /[[:upper:]]/\n\n name.gsub(/\\b[[:alpha:]]+/) { |w| w =~ PARTICLE_REGEX ? w : w.capitalize }\n end", "def compare_to_name(name_1, name_2)\n name_1.downcase == name_2.downcase ? true : false\nend", "def origName(name)\n\t\treturn @origName[name.downcase]\n\tend", "def case_insensitive_match; end", "def are_you_playing_banjo(name)\n if /\\Ar/.match(name.downcase)\n return \"#{name} plays banjo\"\n else\n return \"#{name} does not play banjo\"\n end\nend", "def fix_case_up(name)\n return name[0, 1].upcase + name[1..-1]\n end", "def name_matches?(guess)\n case guess\n when nil\n false\n else\n full_name.downcase == guess.downcase\n end\n end", "def match_to_preflabel(name)\n name = name.downcase\n case name\n when /reconstruction/\n standard_name = 'University of York. Post-war Reconstruction and'\\\n ' Development Unit'\n when /applied human rights/\n standard_name = 'University of York. Centre for Applied Human Rights'\n when /health economics/\n standard_name = 'University of York. Centre for Health Economics'\n when /health sciences/\n standard_name = 'University of York. Department of Health Sciences'\n when /lifelong learning/\n standard_name = 'University of York. Centre for Lifelong Learning'\n when /medieval studies/\n standard_name = 'University of York. Centre for Medieval Studies'\n when /renaissance/\n standard_name = 'University of York. Centre for Renaissance and Early'\\\n ' Modern Studies'\n when /reviews/\n standard_name = 'University of York. Centre for Reviews and'\\\n ' Disseminations'\n when /women/\n standard_name = \"University of York. Centre for Women's Studies\"\n when /school of social and political science/\n standard_name = 'University of York. School of Social and Political'\\\n ' Science'\n when /social policy/\n standard_name = 'University of York. Department of Social Policy and'\\\n ' Social Work'\n when /school of politics economics and philosophy/\n standard_name = 'University of York. School of Politics Economics and'\\\n ' Philosophy'\n when /politics/\n standard_name = 'University of York. Department of Politics'\n when /economics and related/\n standard_name = 'University of York. Department of Economics and Related'\\\n ' Studies'\n when /economics and philosophy/\n standard_name = 'University of York. School of Politics Economics and'\\\n ' Philosophy'\n when /history of art/\n standard_name = 'University of York. Department of History of Art'\n when /history/\n standard_name = 'University of York. Department of History'\n when /electronic/\n standard_name = 'University of York. Department of Electronic Engineering'\n when /theatre/\n standard_name = 'University of York. Department of Theatre, Film and'\\\n ' Television'\n when /physics/\n standard_name = 'University of York. Department of Physics'\n when /computer/\n standard_name = 'University of York. Department of Computer Science'\n when /psychology/\n standard_name = 'University of York. Department of Psychology'\n when /law/\n standard_name = 'University of York. York Law School'\n when /mathematics/\n standard_name = 'University of York. Department of Mathematics'\n when /advanced architectural/\n standard_name = 'University of York. Institute of Advanced Architectural'\\\n ' Studies'\n when /conservation/\n standard_name = 'University of York. Centre for Conservation Studies'\n when /eighteenth century/\n standard_name = 'University of York. Centre for Eighteenth Century\n Studies'\n when /chemistry/\n standard_name = 'University of York. Department of Chemistry'\n when /sociology/\n standard_name = 'University of York. Department of Sociology'\n when /education/\n standard_name = 'University of York. Department of Education'\n when /music/\n standard_name = 'University of York. Department of Music'\n when /archaeology/\n standard_name = 'University of York. Department of Archaeology'\n when /biology/\n standard_name = 'University of York. Department of Biology'\n when /biochemistry/ # confirmed with metadata team - recheck?\n standard_name = 'University of York. Department of Biology'\n when /english and related/ # confirmed directly with English department\n standard_name = 'University of York. Department of English and Related'\\\n ' Literature'\n when /philosophy/\n standard_name = 'University of York. Department of Philosophy'\n when /management studies/\n standard_name = 'University of York. Department of Management Studies'\n when /management school/\n # older versionof department name which should be retained if match found\n standard_name = 'University of York. The York Management School'\n when /language and linguistic science/\n standard_name = 'University of York. Department of Language and'\\\n ' Linguistic Science'\n when /language and lingusitic science/ # deal with common typo\n standard_name = 'University of York. Department of Language and'\\\n ' Linguistic Science'\n when /for all/ # this is 'languages for all' but in some records 'language'\n standard_name = 'University of York. Department of Language and'\\\n ' Linguistic Science. Languages for All'\n when /hull/\n standard_name = 'Hull York Medical School'\n when /international pathway/\n standard_name = 'University of York. International Pathway College'\n when /school of criminology/\n standard_name = 'University of York. School of Criminology'\n when /natural sciences/\n standard_name = 'University of York. School of Natural Sciences'\n when /environment and geography/ # order important, more precise must be first\n standard_name = 'University of York. Department of Environment and Geography'\n when /environment/\n standard_name = 'University of York. Environment Department'\n else\n standard_name = 'COULD NOT MATCH ' + name\n end\n standard_name\n end", "def names_match s1, s2\n t1 = ''\n t2 = ''\n s1.each_char do |c|\n t1 << c if c.match /(\\d|[a-zA-Z])/\n end\n s2.each_char do |c|\n t2 << c if c.match /(\\d|[a-zA-Z])/\n end\n t1.upcase == t2.upcase\nend", "def name_check?(input)\n (/#{input}/.match(@name.downcase) || /#{input}/.match(@last_name.downcase)) ? true : false\n end", "def create_match(nominee)\n names = []\n pname = nominee[:name]\n names << pname\n names << pname.sub(%r{ [A-Z]\\. }, ' ') # drop initial\n personname = ASF::Person.find(nominee[:id]).public_name\n names << personname if personname\n list = names.uniq.map{|name| Regexp.escape(name)}.join('|')\n # N.B. \\b does not match if it follows ')', so won't match John (Fred)\n # TODO: Work-round is to also look for EOS, but this needs to be improved\n %r{\\b(#{list})(\\b|$)}i\nend", "def is_valid_name(str)\n str_arr = str.split\n check = []\n str_arr.each do |ele|\n formatted = ele[0].upcase + ele[1..-1].downcase\n check << formatted\n end\n if check.length < 2 || check.join(\" \") != str\n return false\n else\n return true\n end\nend", "def fake_agent_name(name)\n word = name.downcase\n fake_name = next_consonant(next_vowel(swap_name(word)))\n fake_name.split.map(&:capitalize).join(' ')\nend", "def initial(name)\n return nil if name.nil?\n name[0].downcase\n end", "def valid_name (name)\r\n /^\\w+$/.match (name)\r\n end", "def snake_case(name); end", "def identifyProperName\n words = @phrase.split(' ')\n\n #this maybe should change to not check semanticClass\n #depends on how the NER system is going to be accurate or not\n #...we'll see\n unless @semanticClass != \"PERSON\"\n\ttempStatus = true \n else\n\ttempStatus = false\n end\n\n capRegex = /^[A-Z]/\n \n words.each do |word|\n\tif(capRegex.match(word) != nil)\n\t tempStatus = true\n\telse\n\t @properName = false\n\tend\t \n end\n\n @properName = tempStatus unless @properName == false\n \n tempStatus\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if the version is in the range of this VersionRange object. Uses OSGi versioning rules to determine if the version is in range.
def in_range(version) return in_range(version.min) && (version.max_infinite ? true : in_range(version.max)) if version.is_a?(VersionRange) result = min_inclusive ? min <= version : min < version if (!max_infinite) result &= max_inclusive ? max >= version : max > version end result end
[ "def version_in_range?(range)\n minimum_platform_version = Versionomy.parse(range.first)\n maximum_platform_version = Versionomy.parse(range.last)\n @version >= minimum_platform_version && @version <= maximum_platform_version\n end", "def version_in_range?(range)\n if range.is_a? String\n range = range.split('..')\n end\n minimum_platform_version = Gem::Version.new(range.first)\n maximum_platform_version = Gem::Version.new(range.last)\n @version >= minimum_platform_version && @version <= maximum_platform_version\n end", "def match?(version)\n return false if version < lower_bound\n return include_lower_bound? if version == lower_bound\n return true if upper_bound.nil?\n return false if version > upper_bound\n return include_upper_bound? if version == upper_bound\n true\n end", "def versions_intersect?(other)\n range = ::SemanticPuppet::VersionRange.parse(@version || '')\n other_range = ::SemanticPuppet::VersionRange.parse(other.version || '')\n\n range.intersection(other_range) != ::SemanticPuppet::VersionRange::EMPTY_RANGE\n end", "def exact_version?\n self.begin == self.end\n end", "def includes_verse?(verse)\n return false unless verse.is_a?(Verse)\n\n start_verse <= verse && verse <= end_verse\n end", "def in_range?\n return self.range.include?([@x, @y])\n end", "def in?(range)\n @key <= range.end and @key >= range.start\n end", "def valid_ruby_range?\n !(empty? || exclude_begin? || (STARTLESS_RANGE_NOT_SUPPORTED && !self.begin) || (ENDLESS_RANGE_NOT_SUPPORTED && !self.end))\n end", "def covers?(*args)\n other = coerce_range(*args)\n\n if other.instant?\n self.begin <= other.begin and other.end < self.end\n else\n self.begin <= other.begin and other.end <= self.end\n end\n end", "def within?(other_slice)\n if ! other_slice.class == Slice\n raise RuntimeError, \"The Slice#overlaps? method takes a Slice object as its arguments.\"\n end\n if self.seq_region.coord_system != other_slice.seq_region.coord_system\n raise RuntimeError, \"The argument slice of Slice#overlaps? has to be in the same coordinate system, but were \" + self.seq_region.coord_system.name + \" and \" + other_slice.seq_region.coord_system.name\n end\n\n self_range = self.start .. self.stop\n other_range = other_slice.start .. other_slice.stop\n\n if other_range.include?(self.start) and other_range.include?(self.stop)\n return true\n else\n return false\n end\n end", "def within?(other_slice)\r\n if ! other_slice.class == Slice\r\n raise RuntimeError, \"The Slice#overlaps? method takes a Slice object as its arguments.\"\r\n end\r\n if self.seq_region.coord_system != other_slice.seq_region.coord_system\r\n raise RuntimeError, \"The argument slice of Slice#overlaps? has to be in the same coordinate system, but were \" + self.seq_region.coord_system.name + \" and \" + other_slice.seq_region.coord_system.name\r\n end\r\n\r\n self_range = self.start .. self.stop\r\n other_range = other_slice.start .. other_slice.stop\r\n\r\n if other_range.include?(self.start) and other_range.include?(self.stop)\r\n return true\r\n else\r\n return false\r\n end\r\n end", "def subset?(range)\n range = range.to_range if range.respond_to?(:to_range)\n return false if self.begin < range.begin || self.end > range.end\n return false if self.end == range.end && !self.exclude_end? && range.exclude_end?\n true\n end", "def range?\n return @def.range?\n end", "def in_range?(val, range)\n return true unless range\n\n if range.is_a?(Hash)\n result = true\n result &= ( val < range[:before] ) if range[:before]\n result &= ( val > range[:after] ) if range[:after]\n result &= ( val <= range[:max] ) if range[:max]\n result &= ( val >= range[:min] ) if range[:min]\n result &= ( val < range[:less_than] ) if range[:less_than]\n result &= ( val <= range[:less_than_or_equal_to] ) if range[:less_than_or_equal_to]\n result &= ( val > range[:greater_than] ) if range[:greater_than]\n result &= ( val >= range[:greater_than_or_equal_to] ) if range[:greater_than_or_equal_to]\n result\n else\n range = [range] unless range.respond_to?(:include?)\n range.include?(val)\n end\n end", "def superset?(range)\n range = range.to_range if range.respond_to?(:to_range)\n return false if self.begin > range.begin || self.end < range.end\n return false if self.end == range.end && self.exclude_end? && !range.exclude_end?\n true\n end", "def version_between? low_version, high_version, current_version = nil\n current_version ||= rails_version\n return false unless current_version\n\n version = current_version.split(\".\").map!(&:to_i)\n low_version = low_version.split(\".\").map!(&:to_i)\n high_version = high_version.split(\".\").map!(&:to_i)\n\n version.each_with_index do |v, i|\n if v < low_version.fetch(i, 0)\n return false\n elsif v > low_version.fetch(i, 0)\n break\n end\n end\n\n version.each_with_index do |v, i|\n if v > high_version.fetch(i, 0)\n return false\n elsif v < high_version.fetch(i, 0)\n break\n end\n end\n\n true\n end", "def range_includes_item?(range, item)\n range.begin <= item && item <= range.end\n end", "def include_range? other_range\n case other_range\n when Range\n if other_range.first >= self.first && other_range.last <= self.last\n return true\n else\n return false\n end\n else\n raise \"unsupported type\"\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }