idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
9,600 | def where ( deal_id , options = { } ) _ , _ , root = @client . get ( "/deals/#{deal_id}/associated_contacts" , options ) root [ :items ] . map { | item | AssociatedContact . new ( item [ :data ] ) } end | Retrieve deal s associated contacts |
9,601 | def create ( deal_id , associated_contact ) validate_type! ( associated_contact ) attributes = sanitize ( associated_contact ) _ , _ , root = @client . post ( "/deals/#{deal_id}/associated_contacts" , attributes ) AssociatedContact . new ( root [ :data ] ) end | Create an associated contact |
9,602 | def fetch ( & block ) return unless block_given? session = @client . sync . start ( @device_uuid ) return unless session && session . id loop do queued_data = @client . sync . fetch ( @device_uuid , session . id ) break unless queued_data next if queued_data . empty? ack_keys = [ ] queued_data . each do | sync_meta , r... | Intantiate a new BaseCRM Sync API V2 high - level wrapper |
9,603 | def start ( device_uuid ) validate_device! ( device_uuid ) status , _ , root = @client . post ( "/sync/start" , { } , build_headers ( device_uuid ) ) return nil if status == 204 build_session ( root ) end | Start synchronization flow |
9,604 | def fetch ( device_uuid , session_id , queue = 'main' ) validate_device! ( device_uuid ) raise ArgumentError , "session_id must not be nil nor empty" unless session_id && ! session_id . strip . empty? raise ArgumentError , "queue name must not be nil nor empty" unless queue && ! queue . strip . empty? status , _ , root... | Get data from queue |
9,605 | def ack ( device_uuid , ack_keys ) validate_device! ( device_uuid ) raise ArgumentError , "ack_keys must not be nil and an array" unless ack_keys && ack_keys . is_a? ( Array ) return true if ack_keys . empty? payload = { :ack_keys => ack_keys . map ( & :to_s ) } status , _ , _ = @client . post ( '/sync/ack' , payload ,... | Acknowledge received data |
9,606 | def create ( tag ) validate_type! ( tag ) attributes = sanitize ( tag ) _ , _ , root = @client . post ( "/tags" , attributes ) Tag . new ( root [ :data ] ) end | Create a tag |
9,607 | def update ( tag ) validate_type! ( tag ) params = extract_params! ( tag , :id ) id = params [ :id ] attributes = sanitize ( tag ) _ , _ , root = @client . put ( "/tags/#{id}" , attributes ) Tag . new ( root [ :data ] ) end | Update a tag |
9,608 | def create ( loss_reason ) validate_type! ( loss_reason ) attributes = sanitize ( loss_reason ) _ , _ , root = @client . post ( "/loss_reasons" , attributes ) LossReason . new ( root [ :data ] ) end | Create a loss reason |
9,609 | def update ( loss_reason ) validate_type! ( loss_reason ) params = extract_params! ( loss_reason , :id ) id = params [ :id ] attributes = sanitize ( loss_reason ) _ , _ , root = @client . put ( "/loss_reasons/#{id}" , attributes ) LossReason . new ( root [ :data ] ) end | Update a loss reason |
9,610 | def create ( note ) validate_type! ( note ) attributes = sanitize ( note ) _ , _ , root = @client . post ( "/notes" , attributes ) Note . new ( root [ :data ] ) end | Create a note |
9,611 | def update ( note ) validate_type! ( note ) params = extract_params! ( note , :id ) id = params [ :id ] attributes = sanitize ( note ) _ , _ , root = @client . put ( "/notes/#{id}" , attributes ) Note . new ( root [ :data ] ) end | Update a note |
9,612 | def create ( source ) validate_type! ( source ) attributes = sanitize ( source ) _ , _ , root = @client . post ( "/sources" , attributes ) Source . new ( root [ :data ] ) end | Create a source |
9,613 | def create ( order ) validate_type! ( order ) attributes = sanitize ( order ) _ , _ , root = @client . post ( "/orders" , attributes ) Order . new ( root [ :data ] ) end | Create an order |
9,614 | def update ( order ) validate_type! ( order ) params = extract_params! ( order , :id ) id = params [ :id ] attributes = sanitize ( order ) _ , _ , root = @client . put ( "/orders/#{id}" , attributes ) Order . new ( root [ :data ] ) end | Update an order |
9,615 | def create ( lead ) validate_type! ( lead ) attributes = sanitize ( lead ) _ , _ , root = @client . post ( "/leads" , attributes ) Lead . new ( root [ :data ] ) end | Create a lead |
9,616 | def update ( lead ) validate_type! ( lead ) params = extract_params! ( lead , :id ) id = params [ :id ] attributes = sanitize ( lead ) _ , _ , root = @client . put ( "/leads/#{id}" , attributes ) Lead . new ( root [ :data ] ) end | Update a lead |
9,617 | def create ( deal ) validate_type! ( deal ) attributes = sanitize ( deal ) _ , _ , root = @client . post ( "/deals" , attributes ) Deal . new ( root [ :data ] ) end | Create a deal |
9,618 | def update ( deal ) validate_type! ( deal ) params = extract_params! ( deal , :id ) id = params [ :id ] attributes = sanitize ( deal ) _ , _ , root = @client . put ( "/deals/#{id}" , attributes ) Deal . new ( root [ :data ] ) end | Update a deal |
9,619 | def where ( order_id , options = { } ) _ , _ , root = @client . get ( "/orders/#{order_id}/line_items" , options ) root [ :items ] . map { | item | LineItem . new ( item [ :data ] ) } end | Retrieve order s line items |
9,620 | def create ( order_id , line_item ) validate_type! ( line_item ) attributes = sanitize ( line_item ) _ , _ , root = @client . post ( "/orders/#{order_id}/line_items" , attributes ) LineItem . new ( root [ :data ] ) end | Create a line item |
9,621 | def find ( order_id , id ) _ , _ , root = @client . get ( "/orders/#{order_id}/line_items/#{id}" ) LineItem . new ( root [ :data ] ) end | Retrieve a single line item |
9,622 | def create ( product ) validate_type! ( product ) attributes = sanitize ( product ) _ , _ , root = @client . post ( "/products" , attributes ) Product . new ( root [ :data ] ) end | Create a product |
9,623 | def update ( product ) validate_type! ( product ) params = extract_params! ( product , :id ) id = params [ :id ] attributes = sanitize ( product ) _ , _ , root = @client . put ( "/products/#{id}" , attributes ) Product . new ( root [ :data ] ) end | Update a product |
9,624 | def where ( options = { } ) _ , _ , root = @client . get ( "/deal_unqualified_reasons" , options ) root [ :items ] . map { | item | DealUnqualifiedReason . new ( item [ :data ] ) } end | Retrieve all deal unqualified reasons |
9,625 | def create ( deal_unqualified_reason ) validate_type! ( deal_unqualified_reason ) attributes = sanitize ( deal_unqualified_reason ) _ , _ , root = @client . post ( "/deal_unqualified_reasons" , attributes ) DealUnqualifiedReason . new ( root [ :data ] ) end | Create a deal unqualified reason |
9,626 | def update ( deal_unqualified_reason ) validate_type! ( deal_unqualified_reason ) params = extract_params! ( deal_unqualified_reason , :id ) id = params [ :id ] attributes = sanitize ( deal_unqualified_reason ) _ , _ , root = @client . put ( "/deal_unqualified_reasons/#{id}" , attributes ) DealUnqualifiedReason . new (... | Update a deal unqualified reason |
9,627 | def + ( other ) other = other . to_days if other . respond_to? ( :to_days ) ISO8601 :: Date . new ( ( @date + other ) . iso8601 ) end | Forwards the date the given amount of days . |
9,628 | def atomize ( input ) week_date = parse_weekdate ( input ) return atomize_week_date ( input , week_date [ 2 ] , week_date [ 1 ] ) unless week_date . nil? _ , sign , year , separator , day = parse_ordinal ( input ) return atomize_ordinal ( year , day , separator , sign ) unless year . nil? _ , year , separator , month ,... | Splits the date component into valid atoms . |
9,629 | def months_to_seconds ( base ) month_base = base . nil? ? nil : base + years . to_seconds ( base ) months . to_seconds ( month_base ) end | Changes the base to compute the months for the right base year |
9,630 | def atomize ( input ) duration = parse ( input ) || raise ( ISO8601 :: Errors :: UnknownPattern , input ) valid_pattern? ( duration ) @sign = sign_to_i ( duration [ :sign ] ) components = parse_tokens ( duration ) components . delete ( :time ) valid_fractions? ( components . values ) components end | Splits a duration pattern into valid atoms . |
9,631 | def fetch_seconds ( other , base = nil ) case other when ISO8601 :: Duration other . to_seconds ( base ) when Numeric other . to_f else raise ( ISO8601 :: Errors :: TypeError , other ) end end | Fetch the number of seconds of another element . |
9,632 | def to_seconds ( base = nil ) valid_base? ( base ) return factor ( base ) * atom if base . nil? target = :: Time . new ( base . year + atom . to_i , base . month , base . day , base . hour , base . minute , base . second , base . zone ) target - base . to_time end | The amount of seconds |
9,633 | def include? ( other ) raise ( ISO8601 :: Errors :: TypeError , "The parameter must respond_to #to_time" ) unless other . respond_to? ( :to_time ) ( first . to_time <= other . to_time && last . to_time >= other . to_time ) end | Check if a given time is inside the current TimeInterval . |
9,634 | def subset? ( other ) raise ( ISO8601 :: Errors :: TypeError , "The parameter must be an instance of #{self.class}" ) unless other . is_a? ( self . class ) other . include? ( first ) && other . include? ( last ) end | Returns true if the interval is a subset of the given interval . |
9,635 | def intersection ( other ) raise ( ISO8601 :: Errors :: IntervalError , "The intervals are disjoint" ) if disjoint? ( other ) && other . disjoint? ( self ) return self if subset? ( other ) return other if other . subset? ( self ) a , b = sort_pair ( self , other ) self . class . from_datetimes ( b . first , a . last ) ... | Return the intersection between two intervals . |
9,636 | def parse_subpattern ( pattern ) return ISO8601 :: Duration . new ( pattern ) if pattern . start_with? ( 'P' ) ISO8601 :: DateTime . new ( pattern ) end | Parses a subpattern to a correct type . |
9,637 | def parse ( date_time ) raise ( ISO8601 :: Errors :: UnknownPattern , date_time ) if date_time . empty? date , time = date_time . split ( 'T' ) date_atoms = parse_date ( date ) time_atoms = Array ( time && parse_time ( time ) ) separators = [ date_atoms . pop , time_atoms . pop ] raise ( ISO8601 :: Errors :: UnknownPat... | Parses an ISO date time where the date and the time components are optional . |
9,638 | def parse_date ( input ) today = :: Date . today return [ today . year , today . month , today . day , :ignore ] if input . empty? date = ISO8601 :: Date . new ( input ) date . atoms << date . separator end | Validates the date has the right pattern . |
9,639 | def valid_representation? ( date , time ) year , month , day = date hour = time . first date . nil? || ! ( ! year . nil? && ( month . nil? || day . nil? ) && ! hour . nil? ) end | If time is provided date must use a complete representation |
9,640 | def repo_make ( name ) path = repo_path ( name ) path . mkpath Dir . chdir ( path ) do ` ` repo_make_readme_change ( name , 'Added' ) ` ` ` ` end path end | Makes a repo with the given name . |
9,641 | def local_branches @local_branches ||= begin branches = [ ] if not git . branches . local . empty? branches << git . branches . local . select { | b | b . current } [ 0 ] . name branches << git . branches . local . select { | b | not b . current } . map { | b | b . name } end branches . flatten end end | Returns the local git branches ; current branch is always first |
9,642 | def [] ( key ) bmp_def = _get_definition key bmp = @values [ bmp_def . bmp ] bmp ? bmp . value : nil end | Retrieve the decoded value of the contents of a bitmap described either by the bitmap number or name . |
9,643 | def to_s _mti_name = _get_mti_definition ( mti ) [ 1 ] str = "MTI:#{mti} (#{_mti_name})\n\n" _max = @values . values . max { | a , b | a . name . length <=> b . name . length } _max_name = _max . name . length @values . keys . sort . each { | bmp_num | _bmp = @values [ bmp_num ] str += ( "%03d %#{_max_name}s : %s\n" % ... | Returns a nicely formatted representation of this message . |
9,644 | def []= ( i , value ) if i > 128 raise ISO8583Exception . new ( "Bits > 128 are not permitted." ) elsif i < 2 raise ISO8583Exception . new ( "Bits < 2 are not permitted (continutation bit is set automatically)" ) end @bmp [ i - 1 ] = ( value == true ) end | Set the bit to the indicated value . Only true sets the bit any other value unsets it . |
9,645 | def to_bytes bitmap_hex = "" str = "" self . to_s . chars . reverse . each_with_index do | ch , i | str << ch next if i == 0 if ( i + 1 ) % 4 == 0 bitmap_hex << str . reverse . to_i ( 2 ) . to_s ( 16 ) str = "" end end unless str . empty? bitmap_hex << str . reverse . to_i ( 2 ) . to_s ( 16 ) end bitmap_hex . reverse .... | Generate the bytes representing this bitmap . |
9,646 | def try_user ( timeout = Device :: IO . timeout , options = nil , & block ) time = timeout != 0 ? Time . now + timeout / 1000 : Time . now processing = Hash . new ( keep : true ) interation = 0 files = options [ :bmps ] [ :attach_loop ] if options && options [ :bmps ] . is_a? ( Hash ) max = ( files . size - 1 ) if file... | must send nonblock proc |
9,647 | def menu ( title , selection , options = { } ) return nil if selection . empty? options [ :number ] = true if options [ :number ] . nil? options [ :timeout ] ||= Device :: IO . timeout key , selected = pagination ( title , options , selection ) do | collection , line_zero | collection . each_with_index do | value , i |... | Create a form menu . |
9,648 | def edit ( object , method_name ) method = LookupPath . new ( object ) . find ( method_name . to_s ) or raise NoMethodError , "no method `#{method_name}' in lookup path of #{object.class} instance" file , line = method . source_location if ! file raise NoSourceLocationError , "no source location for #{method.owner}##{m... | Run the editor command for the + method_name + of + object + . |
9,649 | def command_for ( file , line ) line = line . to_s words = Shellwords . shellwords ( command ) words . map! do | word | word . gsub! ( / / , file ) word . gsub! ( / / , line ) word . gsub! ( / / , '%' ) word end end | Return the editor command for the given file and line . |
9,650 | def edit ( name ) Editor . new ( Looksee . editor ) . edit ( lookup_path . object , name ) end | Open an editor at the named method s definition . |
9,651 | def has_one ( region_name , ** opts , & block ) within = opts [ :in ] || opts [ :within ] region_class = opts [ :class ] || opts [ :region_class ] define_region_accessor ( region_name , within : within , region_class : region_class , & block ) end | Defines region accessor . |
9,652 | def has_many ( region_name , ** opts , & block ) region_class = opts [ :class ] || opts [ :region_class ] collection_class = opts [ :through ] || opts [ :collection_class ] each = opts [ :each ] || raise ( ArgumentError , '"has_many" method requires "each" param' ) within = opts [ :in ] || opts [ :within ] define_regio... | Defines multiple regions accessor . |
9,653 | def authorize_from_refresh_token ( refresh_token ) @access_token = oauth_client . get_token ( { client_id : oauth_client . id , client_secret : oauth_client . secret , refresh_token : refresh_token , grant_type : 'refresh_token' } ) end | Authorize client by fetching a new access_token via refresh token |
9,654 | def as_hqmf_model json = { 'id' => hqmf_id , 'title' => title , 'description' => description , 'population_criteria' => population_criteria , 'data_criteria' => data_criteria , 'source_data_criteria' => source_data_criteria , 'measure_period' => measure_period , 'attributes' => measure_attributes , 'populations' => pop... | Returns the hqmf - parser s ruby implementation of an HQMF document . Rebuild from population_criteria data_criteria and measure_period JSON |
9,655 | def code_system_pairs codes . collect do | code | { code : code . code , system : code . codeSystem } end end | Returns all of the codes on this datatype in a way that is typical to the CQL execution engine . |
9,656 | def shift_dates ( seconds ) fields . keys . each do | field | if send ( field ) . is_a? DateTime send ( field + '=' , ( send ( field ) . to_time + seconds . seconds ) . to_datetime ) end if ( send ( field ) . is_a? Interval ) || ( send ( field ) . is_a? DataElement ) send ( field + '=' , send ( field ) . shift_dates ( ... | Shift all fields that deal with dates by the given value . Given value should be in seconds . Positive values shift forward negative values shift backwards . |
9,657 | def shift_dates ( seconds ) if ( @low . is_a? DateTime ) || ( @low . is_a? Time ) @low = ( @low . utc . to_time + seconds . seconds ) . to_datetime . new_offset ( 0 ) end if ( @high . is_a? DateTime ) || ( @high . is_a? Time ) @high = ( @high . utc . to_time + seconds . seconds ) . to_datetime . new_offset ( 0 ) @high ... | Shift dates by the given value . Given value should be in seconds . Positive values shift forward negative values shift backwards . |
9,658 | def shift_dates ( seconds ) self . birthDatetime = ( birthDatetime . utc . to_time + seconds . seconds ) . to_datetime dataElements . each { | element | element . shift_dates ( seconds ) } end | Shift all data element fields that deal with dates by the given value . Given value should be in seconds . Positive values shift forward negative values shift backwards . |
9,659 | def fields_for record_name , record_object = nil , fields_options = { } , & block super record_name , record_object , fields_options . merge ( builder : self . class ) , & block end | Ensure fields_for yields a GovukElementsFormBuilder . |
9,660 | def merge_attributes attributes , default : hash = attributes || { } hash . merge ( default ) { | _key , oldval , newval | Array ( newval ) + Array ( oldval ) } end | Given an attributes hash that could include any number of arbitrary keys this method ensure we merge one or more default attributes into the hash creating the keys if don t exist or merging the defaults if the keys already exists . It supports strings or arrays as values . |
9,661 | def update ( args = { } ) return @data if args . empty? org = args [ :organization ] || account . username box_name = args [ :name ] || @name data = @client . request ( 'put' , box_path ( org , box_name ) , box : args ) @data = data if ! args [ :organization ] && ! args [ :name ] data end | Update a box |
9,662 | def search ( query = nil , provider = nil , sort = nil , order = nil , limit = nil , page = nil ) params = { q : query , provider : provider , sort : sort , order : order , limit : limit , page : page } . delete_if { | _ , v | v . nil? } @client . request ( 'get' , '/search' , params ) end | Requests a search based on the given parameters |
9,663 | def filter ( & block ) @selectors = Hash . new @filtered_nodes = [ ] @document = read_document @metadata = PandocFilter :: Metadata . new @document . meta nodes_to_filter = Enumerator . new do | node_list | @document . each_depth_first do | node | node_list << node end end @current_node = @document nodes_to_filter . ea... | Create a filter using + block + . In the block you specify selectors and actions to be performed on selected nodes . In the example below the selector is Image which selects all image nodes . The action is to prepend the contents of the image s caption by the string Figure . . |
9,664 | def with ( selector ) @selectors [ selector ] = Selector . new selector unless @selectors . has_key? selector yield @current_node if @selectors [ selector ] . matches? @current_node , @filtered_nodes end | Specify what nodes to filter with a + selector + . If the + current_node + matches that selector it is passed to the block to this + with + method . |
9,665 | def matches? node , filtered_nodes node . type == @type and @classes . all? { | c | node . has_class? c } and @relations . all? { | r | r . matches? node , filtered_nodes } end | Create a new Selector based on the selector string |
9,666 | def [] ( k ) if RESERVED_FIELDS . include? k . to_sym super else r = attributes . find { | a | a . key . to_s == k . to_s } . value end end | Look up attributes |
9,667 | def once ( opts ) o = @state . merge opts o [ :time ] = Time . now . to_i o [ :tags ] = ( ( o [ :tags ] | [ "once" ] ) rescue [ "once" ] ) @client << o end | Issues an immediate update of the state with tag once set but does not update the local state . Useful for transient errors . Opts are merged with the state . |
9,668 | def set_slimmer_headers ( hash ) raise InvalidHeader if ( hash . keys - SLIMMER_HEADER_MAPPING . keys ) . any? SLIMMER_HEADER_MAPPING . each do | hash_key , header_suffix | value = hash [ hash_key ] headers [ "#{HEADER_PREFIX}-#{header_suffix}" ] = value . to_s if value end end | Set the slimmer headers to configure the page |
9,669 | def add ( file , line , expression = nil ) real_file = ( file != Pry . eval_path ) raise ArgumentError , 'Invalid file!' if real_file && ! File . exist? ( file ) validate_expression expression Pry . processor . debugging = true path = ( real_file ? File . expand_path ( file ) : file ) Debugger . add_breakpoint ( path ,... | Add a new breakpoint . |
9,670 | def change ( id , expression = nil ) validate_expression expression breakpoint = find_by_id ( id ) breakpoint . expr = expression breakpoint end | Change the conditional expression for a breakpoint . |
9,671 | def delete ( id ) unless Debugger . started? && Debugger . remove_breakpoint ( id ) raise ArgumentError , "No breakpoint ##{id}" end Pry . processor . debugging = false if to_a . empty? end | Delete an existing breakpoint with the given ID . |
9,672 | def clear Debugger . breakpoints . clear if Debugger . started? Pry . processor . debugging = false end | Delete all breakpoints . |
9,673 | def stop Debugger . stop if ! @always_enabled && Debugger . started? if PryDebugger . current_remote_server PryDebugger . current_remote_server . teardown end end | Cleanup when debugging is stopped and execution continues . |
9,674 | def task ( name , * args ) klass = Fudge :: Tasks . discover ( name ) task = klass . new ( * args ) current_scope . tasks << task with_scope ( task ) { yield if block_given? } end | Adds a task to the current scope |
9,675 | def method_missing ( meth , * args , & block ) task meth , * args , & block rescue Fudge :: Exceptions :: TaskNotFound super end | Delegate to the current object scope |
9,676 | def generate_command ( name , tty_options ) cmd = [ ] cmd << name cmd += tty_options cmd << "`#{find_filters.join(' | ')}`" cmd . join ( ' ' ) end | Generates a command line with command and any tty_option |
9,677 | def init generator = Fudge :: Generator . new ( Dir . pwd ) msg = generator . write_fudgefile shell . say msg end | Initalizes the blank Fudgefile |
9,678 | def build ( build_name = 'default' ) description = Fudge :: Parser . new . parse ( 'Fudgefile' ) Fudge :: Runner . new ( description ) . run_build ( build_name , options ) end | Runs the parsed builds |
9,679 | def build ( name , options = { } ) @builds [ name ] = build = Build . new ( options ) with_scope ( build ) { yield } end | Sets builds to an initial empty array Adds a build to the current description |
9,680 | def task_group ( name , * args , & block ) if block @task_groups [ name ] = block else find_task_group ( name ) . call ( * args ) end end | Adds a task group to the current description or includes a task group |
9,681 | def find_task_group ( name ) @task_groups [ name ] . tap do | block | raise Exceptions :: TaskGroupNotFound . new ( name ) unless block end end | Gets a task group of the given name |
9,682 | def run_build ( which_build = 'default' , options = { } ) formatter = options [ :formatter ] || Fudge :: Formatters :: Simple . new output_start ( which_build , formatter ) status = run ( which_build , options ) output_status ( status , formatter ) end | Run the specified build |
9,683 | def with_timer ( name ) start = Time . now yield duration = Time . now - start add_field ( name , duration * 1000 ) self end | times the execution of a block and adds a field containing the duration in milliseconds |
9,684 | def validate_required_all ( required_configs ) required_configs . each do | config | unless config_set? ( config ) message = "Configuration value `#{config}` is required." raise ConfigurationError , message end end end | Loops through the list of required configurations and raises an error if a it can t find all the configuration values set |
9,685 | def validate_required_any ( required_configs ) valid = required_configs . select { | config | config_set? ( config ) } return if valid . any? config_list = required_configs . map { | conf | '`' + conf + '`' } . join ( ', ' ) message = "At least one of the configuration values has to be set: #{config_list}." raise Confi... | Loops through the list of required configurations and raises an error if a it can t find at least one configuration value set |
9,686 | def validate_value ( config , allowed_values ) value = instance_variable_get ( "@#{config}" ) return unless invalid_value? ( value , allowed_values ) message = "Configuration value `#{value}` is not allowed for `#{config}`." raise ConfigurationError , message end | Raises an error if the setting receives an invalid value |
9,687 | def add ( event ) if @verbose metadata = "Honeycomb dataset '#{event.dataset}' | #{event.timestamp.iso8601}" metadata << " (sample rate: #{event.sample_rate})" if event . sample_rate != 1 @output . print ( "#{metadata} | " ) end @output . puts ( event . data . to_json ) end | Prints an event |
9,688 | def send_event ( event ) @lock . synchronize do transmission_client_params = { max_batch_size : @max_batch_size , send_frequency : @send_frequency , max_concurrent_batches : @max_concurrent_batches , pending_work_capacity : @pending_work_capacity , responses : @responses , block_on_send : @block_on_send , block_on_resp... | Enqueue an event to send . Sampling happens here and we will create new threads to handle work as long as we haven t gone over max_concurrent_batches and there are still events in the queue . |
9,689 | def body raise RequestError , 'The request requires a HTTP method.' unless @http_method raise RequestError , 'The payload needs to be a hash.' unless @payload . to_s . empty? || @payload . is_a? ( Hash ) res = Net :: HTTP . start ( uri . hostname , Yoti . configuration . api_port , use_ssl : https_uri? ) do | http | si... | Makes a HTTP request after signing the headers |
9,690 | def process_data ( hash ) Array ( hash ) . map do | hash | Resource . new ( client , hash , resource_relations , resources_key ) end end | Build a Response after a completed request . |
9,691 | def request ( method , path , data = nil , options = nil ) instrument ( "request.bookingsync_api" , method : method , path : path ) do response = call ( method , path , data , options ) response . respond_to? ( :resources ) ? response . resources : response end end | Make a HTTP request to a path and returns an Array of Resources |
9,692 | def paginate ( path , options = { } , & block ) instrument ( "paginate.bookingsync_api" , path : path ) do request_settings = { auto_paginate : options . delete ( :auto_paginate ) , request_method : options . delete ( :request_method ) || :get } if block_given? data = fetch_with_block ( path , options , request_setting... | Make a HTTP GET or POST request to a path with pagination support . |
9,693 | def call ( method , path , data = nil , options = nil ) instrument ( "call.bookingsync_api" , method : method , path : path ) do if [ :get , :head ] . include? ( method ) options = data data = { } end options ||= { } options [ :headers ] ||= { } options [ :headers ] [ "Authorization" ] = "Bearer #{token}" if options . ... | Make a HTTP request to given path and returns Response object . |
9,694 | def with_headers ( extra_headers = { } , & block ) original_headers = @conn . headers . dup @conn . headers . merge! ( extra_headers ) result = yield self @conn . headers = original_headers result end | Yields client with temporarily modified headers . |
9,695 | def handle_response ( faraday_response ) @last_response = response = Response . new ( self , faraday_response ) case response . status when 204 ; nil when 200 .. 299 ; response when 401 ; raise Unauthorized . new ( response ) when 403 ; raise Forbidden . new ( response ) when 404 ; raise NotFound . new ( response ) whe... | Process faraday response . |
9,696 | def call ( data = { } , options = { } ) m = options . delete ( :method ) client . call m || method , href_template , data , options end | Make an API request with the curent Relation . |
9,697 | def brainstem_present ( name , options = { } , & block ) Brainstem . presenter_collection ( options [ :namespace ] ) . presenting ( name , options . reverse_merge ( :params => params ) , & block ) end | Return a Ruby hash that contains models requested by the user s params and allowed by the + name + presenter s configuration . |
9,698 | def preload_method @preload_method ||= begin if Gem . loaded_specs [ 'activerecord' ] . version >= Gem :: Version . create ( '4.1' ) ActiveRecord :: Associations :: Preloader . new . method ( :preload ) else Proc . new do | models , association_names | ActiveRecord :: Associations :: Preloader . new ( models , associat... | Returns a proc that takes two arguments + models + and + association_names + which when called preloads those . |
9,699 | def apply_ordering_to_scope ( scope , user_params ) sort_name , direction = calculate_sort_name_and_direction ( user_params ) order = configuration [ :sort_orders ] . fetch ( sort_name , { } ) [ :value ] ordered_scope = case order when Proc fresh_helper_instance . instance_exec ( scope , direction , & order ) when nil ... | Given user params apply a validated sort order to the given scope . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.