idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
9,500 | def feature ( name = nil ) if ! name self . class . features . keys else if self . class . features . key? ( name ) self . class . features [ name ] else fail "Feature #{name} does not exist!" end end end | Returns an array of the names of all associated features |
9,501 | def imperative_move game . available_moves . each do | move | new_game = game . pristine_mark move return move if new_game . over? && new_game . winner == player_number end if moves_by_rating . all? { | move , rating , game | rating == - 1 } Game . winning_states do | position1 , position2 , position3 | a , b , c = boa... | allows us to override ratings in cases where they make the robot look stupid |
9,502 | def start_span ( operation_name , child_of : nil , references : nil , start_time : nil , tags : nil , ignore_active_scope : false ) if child_of . nil? && references . nil? && ! ignore_active_scope child_of = active_span end Span . new ( tracer : self , operation_name : operation_name , child_of : child_of , references ... | Starts a new span . |
9,503 | def extract ( format , carrier ) case format when OpenTracing :: FORMAT_TEXT_MAP extract_from_text_map ( carrier ) when OpenTracing :: FORMAT_BINARY warn 'Binary join format not yet implemented' nil when OpenTracing :: FORMAT_RACK extract_from_rack ( carrier ) else warn 'Unknown join format' nil end end | Extract a SpanContext from a carrier |
9,504 | def set_baggage ( baggage = { } ) @context = SpanContext . new ( id : context . id , trace_id : context . trace_id , baggage : baggage ) end | Set all baggage at once . This will reset the baggage to the given param . |
9,505 | def to_h { runtime_guid : tracer . guid , span_guid : context . id , trace_guid : context . trace_id , span_name : operation_name , attributes : tags . map { | key , value | { Key : key . to_s , Value : value } } , oldest_micros : start_micros , youngest_micros : end_micros , error_flag : false , dropped_logs : dropped... | Hash representation of a span |
9,506 | def activate ( span : , finish_on_close : true ) return active if active && active . span == span LightStep :: Scope . new ( manager : self , span : span , finish_on_close : finish_on_close ) . tap do | scope | add_scope ( scope ) end end | Make a span instance active . |
9,507 | def configure_connection ( opts = { } ) opts [ 'client_id' ] ||= Lentil :: Engine :: APP_CONFIG [ "instagram_client_id" ] opts [ 'client_secret' ] ||= Lentil :: Engine :: APP_CONFIG [ "instagram_client_secret" ] opts [ 'access_token' ] ||= Lentil :: Engine :: APP_CONFIG [ "instagram_access_token" ] || nil Instagram . c... | Configure the Instagram class in preparation requests . |
9,508 | def configure_comment_connection ( access_token = nil ) access_token ||= Lentil :: Engine :: APP_CONFIG [ "instagram_access_token" ] || nil raise "instagram_access_token must be defined as a parameter or in the application config" unless access_token configure_connection ( { 'access_token' => access_token } ) end | Configure the Instagram class in preparation for leaving comments |
9,509 | def fetch_recent_images_by_tag ( tag = nil ) configure_connection tag ||= Lentil :: Engine :: APP_CONFIG [ "default_image_search_tag" ] Instagram . tag_recent_media ( tag , :count => 10 ) end | Queries the Instagram API for recent images with a given tag . |
9,510 | def extract_image_data ( instagram_metadata ) { url : instagram_metadata . link , external_id : instagram_metadata . id , large_url : instagram_metadata . images . standard_resolution . url , name : instagram_metadata . caption && instagram_metadata . caption . text , tags : instagram_metadata . tags , user : instagram... | Produce processed image metadata from Instagram metadata . This metadata is accepted by the save_image method . |
9,511 | def save_image ( image_data ) instagram_service = Lentil :: Service . where ( :name => "Instagram" ) . first user_record = instagram_service . users . where ( :user_name => image_data [ :user ] [ :username ] ) . first_or_create! ( { :full_name => image_data [ :user ] [ :full_name ] , :bio => image_data [ :user ] [ :bio... | Takes return from Instagram API gem and adds image users and tags to the database . |
9,512 | def save_instagram_load ( instagram_load , raise_dupes = false ) images = instagram_load if ! images . kind_of? ( Array ) images = [ images ] end images . collect { | image | begin save_image ( extract_image_data ( image ) ) rescue DuplicateImageError => e raise e if raise_dupes next rescue => e Rails . logger . error ... | Takes return from Instagram API gem and adds all new images users and tags to the database . |
9,513 | def harvest_image_data ( image ) response = Typhoeus . get ( image . large_url ( false ) , followlocation : true ) if response . success? raise "Invalid content type: " + response . headers [ 'Content-Type' ] unless ( response . headers [ 'Content-Type' ] == 'image/jpeg' ) elsif response . timed_out? raise "Request tim... | Retrieve the binary image data for a given Image object |
9,514 | def harvest_video_data ( image ) response = Typhoeus . get ( image . video_url , followlocation : true ) if response . success? raise "Invalid content type: " + response . headers [ 'Content-Type' ] unless ( response . headers [ 'Content-Type' ] == 'video/mp4' ) elsif response . timed_out? raise "Request timed out" els... | Retrieve the binary video data for a given Image object |
9,515 | def leave_image_comment ( image , comment ) configure_comment_connection Instagram . client . create_media_comment ( image . external_identifier , comment ) end | Leave a comment containing the donor agreement on an Instagram image |
9,516 | def calculate_popularity ( image ) if ( image . staff_like === false ) staff_like_points = 0 else staff_like_points = 10 end if image . like_votes_count > 0 like_vote_points = Math :: log ( image . like_votes_count , 1.5 ) . round else like_vote_points = 0 end if image . win_pct and image . wins_count + image . losses_... | Takes image object and returns a popularity score |
9,517 | def update_image_popularity_score ( image_to_update = :all ) def get_score_write_to_db ( image ) popularity_score = calculate_popularity ( image ) image . update_attribute ( :popular_score , popularity_score ) end if image_to_update == :all images = Lentil :: Image . find ( image_to_update ) images . each do | image | ... | Takes an image id and updates its popularity score |
9,518 | def build super do | builder | @zip_codes . each_with_index do | zip , i | builder . tag! ( 'ZipCode' , :ID => i ) do builder . tag! ( 'Zip5' , zip ) end end end end | Given a list of zip codes looks up what city and state they are associated with . |
9,519 | def def_set ( * method_names ) method_names . each do | method_name | define_singleton_method method_name do | arg = Undefined , & block | if arg . equal? ( Undefined ) unless block raise ArgumentError , "setting #{method_name}: no value and no block given" end self . config = config . with ( method_name => block ) els... | Create a DSL method to set a certain config property . The generated method will take either a plain value or a block which will be captured and stored instead . |
9,520 | def def_forward ( mappings , * names ) if mappings . instance_of? Hash mappings . each do | method_name , target | define_singleton_method method_name do | * args , & block | self . config = config . public_send ( target , * args , & block ) end end else def_forward ( [ mappings , * names ] . map { | name | { name => n... | Forward a method to the config object . This assumes the method will return an updated config instance . |
9,521 | def def_add ( name , options ) old_verbose , $VERBOSE = $VERBOSE , false define_singleton_method name do | * args , & block | defaults = options . fetch ( :defaults , { } ) klass = options . fetch ( :create ) if args . last . instance_of? ( Hash ) args [ - 1 ] = defaults . merge ( args [ - 1 ] ) else args << defaults e... | Generate a DSL method that creates a certain type of domain object and adds it to a list on the config . |
9,522 | def derive_mapper_from_collection ( collection ) if m = collection . first name = "#{m.class.name.split('::').last}CollectionMapper" begin return @options [ :namespace ] . const_get ( name ) rescue NameError end end begin return @options [ :namespace ] . const_get ( :CollectionMapper ) rescue NameError end CollectionMa... | Derives a mapper from the given collection . |
9,523 | def derive_mapper_from_item ( item ) klass = item . class namespaces = klass . name . split ( "::" ) [ 0 ... - 1 ] begin return build_mapper_class ( namespaces , klass ) rescue NameError klass = next_class_for_lookup ( item , namespaces , klass ) retry if klass end raise_mapper_not_found ( item ) end | Derives a mapper from the given item . This item should not be a collection . |
9,524 | def root if parent_ids . present? base_class . find ( parent_ids . first ) else self . root? ? self : self . parent . root end end | Returns this document s root node . Returns self if the current document is a root node |
9,525 | def nullify_children children . each do | c | c . parent = c . parent_id = nil c . save end end | Nullifies all children s parent_id |
9,526 | def rearrange if self . parent_id self . parent_ids = parent . parent_ids + [ self . parent_id ] else self . parent_ids = [ ] end self . depth = parent_ids . size rearrange_children! if self . parent_ids_changed? end | Updates the parent_ids and marks the children for rearrangement when the parent_ids changed |
9,527 | def needs_update? return true unless File . exist? ( @context . xcconfig_path ) xcconfig_hash = Xcodeproj :: Config . new ( File . new ( @context . xcconfig_path ) ) . to_hash needs_update = xcconfig_hash [ MANGLED_SPECS_CHECKSUM_XCCONFIG_KEY ] != @context . specs_checksum Pod :: UI . message '- Mangling config already... | Does the mangling xcconfig need to be updated? |
9,528 | def update_pod_xcconfigs_for_mangling! Pod :: UI . message '- Updating Pod xcconfig files' do @context . pod_xcconfig_paths . each do | pod_xcconfig_path | Pod :: UI . message "- Updating '#{File.basename(pod_xcconfig_path)}'" update_pod_xcconfig_for_mangling! ( pod_xcconfig_path ) end end end | Update all pod xcconfigs to use the mangling defines |
9,529 | def update_pod_xcconfig_for_mangling! ( pod_xcconfig_path ) mangle_xcconfig_include = "#include \"#{@context.xcconfig_path}\"\n" gcc_preprocessor_defs = File . readlines ( pod_xcconfig_path ) . select { | line | line =~ / / } . first gcc_preprocessor_defs . strip! xcconfig_contents = File . read ( pod_xcconfig_path ) n... | Update a mangling config to use the mangling defines |
9,530 | def configure_project if ( xcconfig = self . pods_xcconfig_hash ) && ldflags = xcconfig [ 'OTHER_LDFLAGS' ] @config . resources_dirs << resources_dir . to_s frameworks = installed_frameworks [ :pre_built ] if frameworks @config . embedded_frameworks += frameworks @config . embedded_frameworks . uniq! end if @use_framew... | Adds the Pods project to the RubyMotion config as a vendored project and |
9,531 | def install! ( update ) FileUtils . rm_rf ( resources_dir ) pods_installer . update = update pods_installer . installation_options . integrate_targets = false pods_installer . install! install_resources copy_cocoapods_env_and_prefix_headers end | Performs a CocoaPods Installation . |
9,532 | def resources resources = [ ] script = Pathname . new ( @config . project_dir ) + SUPPORT_FILES + "Pods-#{TARGET_NAME}-resources.sh" return resources unless File . exist? ( script ) File . open ( script ) { | f | f . each_line do | line | if matched = line . match ( / \s / ) path = ( matched [ 1 ] . strip ) [ 1 .. - 2 ... | Do not copy . framework bundles these should be handled through RM s embedded_frameworks config attribute . |
9,533 | def acts_as_struct ( * members ) include Comparable extend InheritedAttributes class_inheritable_array :current_members unless respond_to? ( :current_members ) self . current_members ||= [ ] self . current_members . concat members all_members = self . current_members attr_accessor * members define_method :initialize do... | Mixes in struct behavior to the current class . |
9,534 | def cycles g = self . clone self . inject ( [ ] ) do | acc , v | acc = acc . concat ( g . cycles_with_vertex ( v ) ) g . remove_vertex ( v ) ; acc end end | Returns an array of all minimum cycles in a graph |
9,535 | def parse ( body = self . body ) return PARSING_CACHE [ body ] if PARSING_CACHE [ body ] pairs = Analysis . analyze_inputs ( [ [ file , body ] ] ) PARSING_CACHE [ body ] = pairs [ 0 ] [ 1 ] end | Parses the given text . |
9,536 | def find_sexps ( type , tree = self . parse ( self . body ) ) result = tree [ 0 ] == type ? [ tree ] : [ ] tree . each do | node | result . concat find_sexps ( type , node ) if node . is_a? ( Array ) end result end | Finds all sexps of the given type in the given Sexp tree . |
9,537 | def strongly_connected_components raise NotDirectedError , "strong_components only works for directed graphs." unless directed? vis = TarjanSccVisitor . new ( self ) depth_first_search ( vis ) { | v | } vis end | class TarjanSccVisitor This is Tarjan s algorithm for strongly connected components from his paper Depth first search and linear graph algorithms . It calculates the components in a single application of DFS . We implement the algorithm with the help of the DFSVisitor TarjanSccVisitor . |
9,538 | def each_edge ( & block ) if directed? each_vertex { | u | each_adjacent ( u ) { | v | yield u , v } } else each_edge_aux ( & block ) end end | The each_edge iterator should provide efficient access to all edges of the graph . Its defines the EdgeListGraph concept . |
9,539 | def handle_global_options ( settings ) if settings [ :" " ] @using << Laser . LineLengthWarning ( settings [ :" " ] ) end if ( only_name = settings [ :only ] ) @fix = @using = Warning . concrete_warnings . select do | w | classname = w . name && w . name . split ( '::' ) . last ( classname && only_name . index ( classn... | Processes the global options which includes picking which warnings to run against the source code . The settings provided determine what modifies the runner s settings . |
9,540 | def get_settings warning_opts = get_warning_options Trollop :: options do banner 'LASER: Lexically- and Semantically-Enriched Ruby' opt :fix , 'Should errors be fixed in-line?' , short : '-f' opt :display , 'Should errors be displayed?' , short : '-b' , default : true opt :' ' , 'Should fixed errors be reported anyway?... | Parses the command - line options using Trollop |
9,541 | def get_warning_options all_options = Warning . all_warnings . inject ( { } ) do | result , warning | options = warning . options options = [ options ] if options . any? && ! options [ 0 ] . is_a? ( Array ) options . each do | option | result [ option . first ] = option end result end all_options . values end | Gets all the options from the warning plugins and collects them with overriding rules . The later the declaration is run the higher the priority the option has . |
9,542 | def print_modules Analysis :: LaserModule . all_modules . map do | mod | result = [ ] result << if Analysis :: LaserClass === mod && mod . superclass then "#{mod.path} < #{mod.superclass.path}" else mod . name end result end . sort . flatten . each { | name | puts name } end | Prints the known modules after analysis . |
9,543 | def convert_warning_list ( list ) list . map do | list | case list when :all then Warning . all_warnings when :whitespace [ ExtraBlankLinesWarning , ExtraWhitespaceWarning , OperatorSpacing , MisalignedUnindentationWarning ] else list end end . flatten end | Converts a list of warnings and symbol shortcuts for warnings to just a list of warnings . |
9,544 | def collect_warnings ( files , scanner ) full_list = files . map do | file | data = file == '(stdin)' ? STDIN . read : File . read ( file ) if scanner . settings [ :fix ] scanner . settings [ :output_file ] = scanner . settings [ :stdin ] ? STDOUT : File . open ( file , 'w' ) end results = scanner . scan ( data , file ... | Collects warnings from all the provided files by running them through the scanner . |
9,545 | def display_warnings ( warnings , settings ) num_fixable = warnings . select { | warn | warn . fixable? } . size num_total = warnings . size results = "#{num_total} warnings found. #{num_fixable} are fixable." puts results puts '=' * results . size warnings . each do | warning | puts "#{warning.file}:#{warning.line_num... | Displays warnings using user - provided settings . |
9,546 | def attach_distance_map ( map = Hash . new ( 0 ) ) @dist_map = map class << self def handle_tree_edge ( u , v ) super @dist_map [ v ] = @dist_map [ u ] + 1 end def distance_to_root ( v ) @dist_map [ v ] end end end | Attach a map to the visitor which records the distance of a visited vertex to the start vertex . |
9,547 | def bfs_search_tree_from ( v ) require 'laser/third_party/rgl/adjacency' bfs = bfs_iterator ( v ) tree = DirectedAdjacencyGraph . new bfs . set_tree_edge_event_handler { | from , to | tree . add_edge ( from , to ) } bfs . set_to_end tree end | Returns a DirectedAdjacencyGraph which represents a BFS search tree starting at _v_ . This method uses the tree_edge_event of BFSIterator to record all tree edges of the search tree in the result . |
9,548 | def depth_first_search ( vis = DFSVisitor . new ( self ) , & b ) each_vertex do | u | unless vis . finished_vertex? ( u ) vis . handle_start_vertex ( u ) depth_first_visit ( u , vis , & b ) end end end | Do a recursive DFS search on the whole graph . If a block is passed it is called on each _finish_vertex_ event . See strongly_connected_components for an example usage . |
9,549 | def depth_first_visit ( u , vis = DFSVisitor . new ( self ) , & b ) vis . color_map [ u ] = :GRAY vis . handle_examine_vertex ( u ) each_adjacent ( u ) { | v | vis . handle_examine_edge ( u , v ) if vis . follow_edge? ( u , v ) vis . handle_tree_edge ( u , v ) vis . color_map [ v ] = :GRAY depth_first_visit ( v , vis ,... | Start a depth first search at vertex _u_ . The block _b_ is called on each finish_vertex event . |
9,550 | def scan ( text , filename = '(none)' ) warnings = scan_for_file_warnings ( text , filename ) text = filter_fixable ( warnings ) . inject ( text ) do | text , warning | warning . fix ( text ) end with_fixing_piped_to_output do text . split ( / \n / ) . each_with_index do | line , number | warnings . concat process_line... | Scans the text for warnings . |
9,551 | def process_line ( line , line_number , filename ) warnings = all_warnings_for_line ( line , line_number , filename ) fix_input ( warnings , line , line_number , filename ) if @settings [ :fix ] warnings end | Finds all matching warnings and if the user wishes fix a subset of them . |
9,552 | def fix_input ( warnings , line , line_number , filename ) fixable_warnings = filter_fixable warnings if fixable_warnings . size == 1 self . settings [ :output_lines ] << fixable_warnings . first . fix rescue line elsif fixable_warnings . size > 1 new_text = fixable_warnings . first . fix rescue line process_line ( new... | Tries to fix the given line with a set of matching warnings for that line . May recurse if there are multiple warnings on the same line . |
9,553 | def all_warnings_for_line ( line , line_number , filename ) new_warnings = check_for_indent_warnings! ( line , filename ) new_warnings . concat scan_for_line_warnings ( line , filename ) new_warnings . each { | warning | warning . line_number = line_number } end | Returns all warnings that match the line |
9,554 | def check_for_indent_warnings! ( line , filename ) return [ ] if line == "" indent_size = get_indent_size line if indent_size > current_indent self . indent_stack . push indent_size elsif indent_size < current_indent previous = self . indent_stack . pop if indent_size != current_indent && using . include? ( MisalignedU... | Checks for new warnings based on indentation . |
9,555 | def scan_for_line_warnings ( line , filename ) warnings = scan_for_warnings ( using & LineWarning . all_warnings , line , filename ) filtered_warnings_from_line ( line , warnings ) end | Goes through all line warning subclasses and checks if we got some new warnings for a given line |
9,556 | def lex ( body = self . body , token_class = Token ) return [ ] if body =~ / / Ripper . lex ( body ) . map { | token | token_class . new ( token ) } end | Lexes the given text . |
9,557 | def find_token ( * args ) body , list = _extract_token_search_args ( args ) lexed = lex ( body ) lexed . find . with_index do | tok , idx | is_token = list . include? ( tok . type ) is_not_symbol = idx == 0 || lexed [ idx - 1 ] . type != :on_symbeg is_token && is_not_symbol end end | Finds the first instance of a set of tokens in the body . If no text is given to scan then the full content is scanned . |
9,558 | def split_on_keyword ( * args ) body , keywords = _extract_token_search_args ( args ) token = find_keyword ( body , * keywords ) return _split_body_with_raw_token ( body , token ) end | Splits the body into two halfs based on the first appearance of a keyword . |
9,559 | def split_on_token ( * args ) body , tokens = _extract_token_search_args ( args ) token = find_token ( body , * tokens ) return _split_body_with_raw_token ( body , token ) end | Splits the body into two halfs based on the first appearance of a token . |
9,560 | def to_adjacency result = ( directed? ? DirectedAdjacencyGraph : AdjacencyGraph ) . new each_vertex { | v | result . add_vertex ( v ) } each_edge { | u , v | result . add_edge ( u , v ) } result end | Convert a general graph to an AdjacencyGraph . If the graph is directed returns a DirectedAdjacencyGraph ; otherwise returns an AdjacencyGraph . |
9,561 | def initialize_copy ( orig ) @vertex_dict = orig . instance_eval { @vertex_dict } . dup @vertex_dict . keys . each do | v | @vertex_dict [ v ] = @vertex_dict [ v ] . dup end @predecessor_dict = orig . instance_eval { @predecessor_dict } . dup @predecessor_dict . keys . each do | v | @predecessor_dict [ v ] = @predecess... | Returns a new empty DirectedAdjacencyGraph which has as its edgelist class the given class . The default edgelist class is Set to ensure set semantics for edges and vertices . |
9,562 | def edgelist_class = ( klass ) @vertex_dict . keys . each do | v | @vertex_dict [ v ] = klass . new @vertex_dict [ v ] . to_a end @predecessor_dict . keys . each do | v | @predecessor_dict [ v ] = klass . new @predecessor_dict [ v ] . to_a end end | Converts the adjacency list of each vertex to be of type _klass_ . The class is expected to have a new contructor which accepts an enumerable as parameter . |
9,563 | def opposite_method ( new_name , old_name ) define_method new_name do | * args , & blk | ! send ( old_name , * args , & blk ) end end | Creates a new method that returns the boolean negation of the specified method . |
9,564 | def attr_accessor_with_default ( name , val ) ivar_sym = "@#{name}" define_method name do unless instance_variable_defined? ( ivar_sym ) instance_variable_set ( ivar_sym , val ) end instance_variable_get ivar_sym end attr_writer name end | Creates an attr_accessor that defaults to a certain value . |
9,565 | def cattr_get_and_setter ( * attrs ) attrs . each do | attr | cattr_accessor attr singleton_class . instance_eval do alias_method "#{attr}_old_get" . to_sym , attr define_method attr do | * args , & blk | if args . size > 0 send ( "#{attr}=" , * args ) elsif blk != nil send ( "#{attr}=" , blk ) else send ( "#{attr}_old... | Creates a DSL - friendly set - and - getter method . The method when called with no arguments acts as a getter . When called with arguments it acts as a setter . Uses class instance variables - this is not for generating instance methods . |
9,566 | def dominance_frontier ( start_node = self . enter , dom_tree ) vertices . inject ( Hash . new { | h , k | h [ k ] = Set . new } ) do | result , b | preds = b . real_predecessors if preds . size >= 2 preds . each do | p | b_dominator = dom_tree [ b ] . successors . first break unless b_dominator runner = dom_tree [ p ]... | Returns the dominance frontier of the graph . |
9,567 | def dominator_set_intersect ( b1 , b2 , doms ) finger1 , finger2 = b1 , b2 while finger1 . post_order_number != finger2 . post_order_number finger1 = doms [ finger1 ] while finger1 . post_order_number < finger2 . post_order_number finger2 = doms [ finger2 ] while finger2 . post_order_number < finger1 . post_order_numbe... | performs a set intersection of the dominator tree . |
9,568 | def batch_connect_config ( template = nil ) if template @batch_connect_config . fetch ( template . to_sym , { } ) . to_h . symbolize_keys . merge ( template : template . to_sym ) else @batch_connect_config end end | The batch connect template configuration used for this cluster |
9,569 | def batch_connect_template ( context = { } ) context = context . to_h . symbolize_keys BatchConnect :: Factory . build batch_connect_config ( context [ :template ] || :basic ) . merge ( context ) end | Build a batch connect template from the respective configuration |
9,570 | def custom_allow? ( feature ) allow? && ! custom_config ( feature ) . empty? && build_acls ( custom_config ( feature ) . fetch ( :acls , [ ] ) . map ( & :to_h ) ) . all? ( & :allow? ) end | Whether the custom feature is allowed based on the ACLs |
9,571 | def to_h { id : id , metadata : metadata_config , login : login_config , job : job_config , custom : custom_config , acls : acls_config , batch_connect : batch_connect_config } end | Convert object to hash |
9,572 | def run_bulk ( t , first , last , incr = 1 ) retry_until { DRMAA . run_bulk_jobs ( t . ptr , first , last , incr ) } end | submits bulk job described by JobTemplate t and returns an array of job id strings |
9,573 | def wait_each ( timeout = - 1 ) if ! block_given? ary = Array . new end while true begin info = DRMAA . wait ( ANY_JOB , timeout ) rescue DRMAAInvalidJobError break end if block_given? yield info else ary << info end end if ! block_given? return ary end end | run block with JobInfo to finish for each waited session job or return JobInfo array if no block was passed |
9,574 | def predicate_visitor join_dependency = ActiveRecord :: Associations :: ClassMethods :: JoinDependency . new ( @klass , association_joins , custom_joins ) MetaWhere :: Visitors :: Predicate . new ( join_dependency ) end | Very occasionally we need to get a visitor for another relation so it makes sense to factor these out into a public method despite only being two lines long . |
9,575 | def schedule_blast_from_template ( template , list , schedule_time , options = { } ) post = options ? options : { } post [ :copy_template ] = template post [ :list ] = list post [ :schedule_time ] = schedule_time api_post ( :blast , post ) end | Schedule a mass mail blast from template |
9,576 | def schedule_blast_from_blast ( blast_id , schedule_time , options = { } ) post = options ? options : { } post [ :copy_blast ] = blast_id post [ :schedule_time ] = schedule_time api_post ( :blast , post ) end | Schedule a mass mail blast from previous blast |
9,577 | def update_blast ( blast_id , name = nil , list = nil , schedule_time = nil , from_name = nil , from_email = nil , subject = nil , content_html = nil , content_text = nil , options = { } ) data = options ? options : { } data [ :blast_id ] = blast_id if name != nil data [ :name ] = name end if list != nil data [ :list ]... | params blast_id Fixnum | String name String list String schedule_time String from_name String from_email String subject String content_html String content_text String options hash |
9,578 | def stats_list ( list = nil , date = nil ) data = { } if list != nil data [ :list ] = list end if date != nil data [ :date ] = date end data [ :stat ] = 'list' api_get ( :stats , data ) end | params list String date String |
9,579 | def stats_blast ( blast_id = nil , start_date = nil , end_date = nil , options = { } ) data = options if blast_id != nil data [ :blast_id ] = blast_id end if start_date != nil data [ :start_date ] = start_date end if end_date != nil data [ :end_date ] = end_date end data [ :stat ] = 'blast' api_get ( :stats , data ) en... | params blast_id String start_date String end_date String options Hash |
9,580 | def stats_send ( template = nil , start_date = nil , end_date = nil , options = { } ) data = options if template != nil data [ :template ] = template end if start_date != nil data [ :start_date ] = start_date end if end_date != nil data [ :end_date ] = end_date end data [ :stat ] = 'send' api_get ( :stats , data ) end | params template String start_date String end_date String options Hash |
9,581 | def save_alert ( email , type , template , _when = nil , options = { } ) data = options data [ :email ] = email data [ :type ] = type data [ :template ] = template if ( type == 'weekly' || type == 'daily' ) data [ :when ] = _when end api_post ( :alert , data ) end | params email String type String template String _when String options hash |
9,582 | def process_job ( job , options = { } , report_email = nil , postback_url = nil , binary_key = nil ) data = options data [ 'job' ] = job if ! report_email . nil? data [ 'report_email' ] = report_email end if ! postback_url . nil? data [ 'postback_url' ] = postback_url end api_post ( :job , data , binary_key ) end | params job String options hash report_email String postback_url String binary_key String |
9,583 | def process_import_job ( list , emails , report_email = nil , postback_url = nil , options = { } ) data = options data [ 'list' ] = list data [ 'emails' ] = Array ( emails ) . join ( ',' ) process_job ( :import , data , report_email , postback_url ) end | params emails String | Array implementation for import_job |
9,584 | def process_import_job_from_file ( list , file_path , report_email = nil , postback_url = nil , options = { } ) data = options data [ 'list' ] = list data [ 'file' ] = file_path process_job ( :import , data , report_email , postback_url , 'file' ) end | implementation for import job using file upload |
9,585 | def process_update_job_from_file ( file_path , report_email = nil , postback_url = nil , options = { } ) data = options data [ 'file' ] = file_path process_job ( :update , data , report_email , postback_url , 'file' ) end | implementation for update job using file upload |
9,586 | def process_purchase_import_job_from_file ( file_path , report_email = nil , postback_url = nil , options = { } ) data = options data [ 'file' ] = file_path process_job ( :purchase_import , data , report_email , postback_url , 'file' ) end | implementation for purchase import job using file upload |
9,587 | def process_snapshot_job ( query = { } , report_email = nil , postback_url = nil , options = { } ) data = options data [ 'query' ] = query process_job ( :snapshot , data , report_email , postback_url ) end | implementation for snapshot job |
9,588 | def process_export_list_job ( list , report_email = nil , postback_url = nil , options = { } ) data = options data [ 'list' ] = list process_job ( :export_list_data , data , report_email , postback_url ) end | implementation for export list job |
9,589 | def get_user_by_key ( id , key , fields = { } ) data = { 'id' => id , 'key' => key , 'fields' => fields } api_get ( :user , data ) end | Get user by specified key |
9,590 | def get_trigger_by_template ( template , trigger_id = nil ) data = { } data [ 'template' ] = template if trigger_id != nil then data [ 'trigger_id' ] = trigger_id end api_get ( :trigger , data ) end | params template String trigger_id String Get an existing trigger |
9,591 | def post_template_trigger ( template , time , time_unit , event , zephyr ) data = { } data [ 'template' ] = template data [ 'time' ] = time data [ 'time_unit' ] = time_unit data [ 'event' ] = event data [ 'zephyr' ] = zephyr api_post ( :trigger , data ) end | params template String time String time_unit String event String zephyr String Create or update a trigger |
9,592 | def post_event_trigger ( event , time , time_unit , zephyr ) data = { } data [ 'time' ] = time data [ 'time_unit' ] = time_unit data [ 'event' ] = event data [ 'zephyr' ] = zephyr api_post ( :trigger , data ) end | params template String time String time_unit String zephyr String Create or update a trigger |
9,593 | def set_up_post_request ( uri , data , headers , binary_key = nil ) if ! binary_key . nil? binary_data = data [ binary_key ] if binary_data . is_a? ( StringIO ) data [ binary_key ] = UploadIO . new ( binary_data , "text/plain" , "local.path" ) else data [ binary_key ] = UploadIO . new ( File . open ( binary_data ) , "t... | set up our post request |
9,594 | def create ( task ) validate_type! ( task ) attributes = sanitize ( task ) _ , _ , root = @client . post ( "/tasks" , attributes ) Task . new ( root [ :data ] ) end | Create a task |
9,595 | def update ( task ) validate_type! ( task ) params = extract_params! ( task , :id ) id = params [ :id ] attributes = sanitize ( task ) _ , _ , root = @client . put ( "/tasks/#{id}" , attributes ) Task . new ( root [ :data ] ) end | Update a task |
9,596 | def create ( contact ) validate_type! ( contact ) attributes = sanitize ( contact ) _ , _ , root = @client . post ( "/contacts" , attributes ) Contact . new ( root [ :data ] ) end | Create a contact |
9,597 | def update ( contact ) validate_type! ( contact ) params = extract_params! ( contact , :id ) id = params [ :id ] attributes = sanitize ( contact ) _ , _ , root = @client . put ( "/contacts/#{id}" , attributes ) Contact . new ( root [ :data ] ) end | Update a contact |
9,598 | def create ( call ) validate_type! ( call ) attributes = sanitize ( call ) _ , _ , root = @client . post ( "/calls" , attributes ) Call . new ( root [ :data ] ) end | Create a call |
9,599 | def update ( call ) validate_type! ( call ) params = extract_params! ( call , :id ) id = params [ :id ] attributes = sanitize ( call ) _ , _ , root = @client . put ( "/calls/#{id}" , attributes ) Call . new ( root [ :data ] ) end | Update a call |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.