idx
int64
0
24.9k
question
stringlengths
68
4.14k
target
stringlengths
9
749
10,300
def method_missing ( method , * args , & block ) if method . to_s . end_with? ( '_path' , '_url' ) if main_app . respond_to? ( method ) main_app . send ( method , * args ) else super end else super end end
Override method_missing to check for main app routes before throwing exception
10,301
def perform ( signup ) return unless NewsletterSignup . api_available? gibbon = Gibbon :: Request . new ( api_key : Settings . newsletter_api_key ) request_body = { email_address : signup . email , status : 'subscribed' } gibbon . lists ( newsletter_list_id ( signup ) ) . members . create ( body : request_body ) signup...
Attempts to signup an email to newsletter
10,302
def forward_enquiry ( enquiry ) @enquiry = enquiry sender = email_sender ( enquiry . name , enquiry . email ) mail subject : forwarding_subject ( enquiry ) , from : sender , to : incoming_email_address , reply_to : sender end
Send supplied enquiry to contact email
10,303
def auto_reply ( enquiry ) @enquiry = enquiry sender = email_sender ( Integral :: Settings . website_title , outgoing_email_address ) mail subject : auto_reply_subject ( enquiry ) , to : enquiry . email , from : sender , reply_to : sender end
Send an auto reply to the visitor of the supplied enquiry
10,304
def create @comment = @commentable . comments . new comment_params if @comment . valid? @comment . save return render layout : false , partial : comment_partial ( :comment ) , locals : { tree : @comment } end render json : { errors : @comment . errors } end
BASE METHODS Public methods
10,305
def recalculate_my_comments_counter! dcount = my_draft_comments . count pcount = my_published_comments . count update_attributes! ( { my_draft_comments_count : dcount , my_published_comments_count : pcount , my_comments_count : dcount + pcount } ) end
I think we shouldn t to have my_deleted_comments cache counter
10,306
def field_added ( name , type , args , options ) if ( default = options [ :ruby_default ] ) attr_default name , default elsif ( default = options [ :default ] ) && default . is_a? ( Proc ) ActiveSupport :: Deprecation . warn ( ':default => Proc has been deprecated. Use :ruby_default.' , caller ) attr_default name , def...
Hobo Fields field declaration
10,307
def get_io ( io , offset = 0 ) io = :: File . open ( io , "rb" ) unless io . is_a? ( IO ) || io . is_a? ( StringIO ) io . seek ( offset , :: IO :: SEEK_SET ) io end
The problem in RubyZip 1 . 1 . 0 is that we only call seek when io is a File . We need to move the cursor to the right position when io is a StringIO as well .
10,308
def find_all ( account_id , options = { } ) response = JSON . parse ( @client . get ( 'direct_debit_authorities' , { account_id : account_id } . merge ( options ) ) . body ) direct_debit_authorities = response . key? ( 'direct_debit_authorities' ) ? response [ 'direct_debit_authorities' ] : [ ] direct_debit_authorities...
List existing direct debit authorities for a given bank account
10,309
def validate ( routing_number ) response = @client . get ( 'tools/routing_number' , { routing_number : routing_number } , true ) ( response . status == 200 ) ? JSON . parse ( response . body ) [ 'routing_number' ] : { } end
Validate a US bank routing number before creating an account . This can be used to provide on - demand verification and further information of the bank information a User is providing .
10,310
def find_all ( options = { } ) response = JSON . parse ( @client . get ( 'companies' , options ) . body ) users = response . key? ( 'companies' ) ? response [ 'companies' ] : [ ] users . map { | attributes | Promisepay :: Company . new ( @client , attributes ) } end
List all companies for a marketplace
10,311
def update ( attributes ) response = JSON . parse ( @client . patch ( "companies/#{attributes[:id]}" , attributes ) . body ) Promisepay :: Company . new ( @client , response [ 'companies' ] ) end
Update a company for a user
10,312
def method_missing ( name , * args , & block ) if self . class . resources . keys . include? ( name ) resources [ name ] ||= self . class . resources [ name ] . new ( self ) resources [ name ] else super end end
Catch calls for resources
10,313
def buyer response = JSON . parse ( @client . get ( "items/#{send(:id)}/buyers" ) . body ) Promisepay :: User . new ( @client , response [ 'users' ] ) end
Show the buyer detail for a single item for a marketplace .
10,314
def fees ( options = { } ) response = JSON . parse ( @client . get ( "items/#{send(:id)}/fees" , options ) . body ) fees = response . key? ( 'fees' ) ? response [ 'fees' ] : [ ] fees . map { | attributes | Promisepay :: Fee . new ( @client , attributes ) } end
Get fees associated to the item .
10,315
def transactions ( options = { } ) response = JSON . parse ( @client . get ( "items/#{send(:id)}/transactions" , options ) . body ) transactions = response . key? ( 'transactions' ) ? response [ 'transactions' ] : [ ] transactions . map { | attributes | Promisepay :: Transaction . new ( @client , attributes ) } end
Get historical transactions for the item .
10,316
def batch_transactions ( options = { } ) response = JSON . parse ( @client . get ( "items/#{send(:id)}/batch_transactions" , options ) . body ) batch_transactions = response . key? ( 'batch_transactions' ) ? response [ 'batch_transactions' ] : [ ] batch_transactions . map { | attributes | Promisepay :: BatchTransaction...
Get historical batch_transactions for the item .
10,317
def make_payment ( options = { } ) response = JSON . parse ( @client . patch ( "items/#{send(:id)}/make_payment" , options ) . body ) @attributes = response [ 'items' ] true end
Make a payment for an Item .
10,318
def request_payment ( options = { } ) response = JSON . parse ( @client . patch ( "items/#{send(:id)}/request_payment" , options ) . body ) @attributes = response [ 'items' ] true end
Request payment for an Item .
10,319
def release_payment ( options = { } ) response = JSON . parse ( @client . patch ( "items/#{send(:id)}/release_payment" , options ) . body ) @attributes = response [ 'items' ] true end
Release funds held in escrow from an Item with an Escrow or Escrow Partial Release payment type .
10,320
def request_release ( options = { } ) response = JSON . parse ( @client . patch ( "items/#{send(:id)}/request_release" , options ) . body ) @attributes = response [ 'items' ] true end
Request release of funds held in escrow from an Item with an Escrow or Escrow Partial Release payment type .
10,321
def acknowledge_wire ( options = { } ) response = JSON . parse ( @client . patch ( "items/#{send(:id)}/acknowledge_wire" , options ) . body ) @attributes = response [ 'items' ] true end
Acknowledge that funds are being wired for payment .
10,322
def revert_wire ( options = { } ) response = JSON . parse ( @client . patch ( "items/#{send(:id)}/revert_wire" , options ) . body ) @attributes = response [ 'items' ] true end
Revert an acknowledge wire Item Action .
10,323
def request_refund ( options = { } ) response = JSON . parse ( @client . patch ( "items/#{send(:id)}/request_refund" , options ) . body ) @attributes = response [ 'items' ] true end
Request a refund for an Item .
10,324
def raise_dispute ( options = { } ) response = JSON . parse ( @client . patch ( "items/#{send(:id)}/raise_dispute" , options ) . body ) @attributes = response [ 'items' ] true end
Raise a dispute for the Item .
10,325
def find_all ( options = { } ) response = JSON . parse ( @client . get ( 'items' , options ) . body ) items = response . key? ( 'items' ) ? response [ 'items' ] : [ ] items . map { | attributes | Promisepay :: Item . new ( @client , attributes ) } end
List all items for a marketplace
10,326
def find ( id , type = :full ) case type when :full response = JSON . parse ( @client . get ( "items/#{id}" ) . body ) Promisepay :: Item . new ( @client , response [ 'items' ] ) when :status response = JSON . parse ( @client . get ( "items/#{id}/status" ) . body ) Promisepay :: Item . new ( @client , response [ 'items...
Get a single item for a marketplace
10,327
def bank_account response = JSON . parse ( @client . get ( "users/#{send(:id)}/bank_accounts" ) . body ) Promisepay :: BankAccount . new ( @client , response [ 'bank_accounts' ] ) rescue Promisepay :: UnprocessableEntity nil end
Gets Bank account for a user on a marketplace .
10,328
def card_account response = JSON . parse ( @client . get ( "users/#{send(:id)}/card_accounts" ) . body ) Promisepay :: CardAccount . new ( @client , response [ 'card_accounts' ] ) rescue Promisepay :: UnprocessableEntity nil end
Gets Card account for a user on a marketplace .
10,329
def paypal_account response = JSON . parse ( @client . get ( "users/#{send(:id)}/paypal_accounts" ) . body ) Promisepay :: PaypalAccount . new ( @client , response [ 'paypal_accounts' ] ) rescue Promisepay :: UnprocessableEntity nil end
Gets PayPal account for a user on a marketplace .
10,330
def disbursement_account ( account_id ) options = { account_id : account_id } JSON . parse ( @client . post ( "users/#{send(:id)}/disbursement_account" , options ) . body ) true end
Set the disbursement account for a user .
10,331
def company response = JSON . parse ( @client . get ( "users/#{send(:id)}/companies" ) . body ) Promisepay :: Company . new ( @client , response [ 'companies' ] ) rescue Promisepay :: NotFound nil end
Gets company for a user on a marketplace .
10,332
def find ( id ) response = JSON . parse ( @client . get ( "fees/#{id}" ) . body ) Promisepay :: Fee . new ( @client , response [ 'fees' ] ) end
Get a single fee for a marketplace
10,333
def create ( attributes ) response = JSON . parse ( @client . post ( 'fees' , attributes ) . body ) Promisepay :: Fee . new ( @client , response [ 'fees' ] ) end
Create a fee for a marketplace
10,334
def withdraw ( options = { } ) response = JSON . parse ( @client . post ( "wallet_accounts/#{send(:id)}/withdraw" , options ) . body ) response . key? ( 'disbursements' ) ? response [ 'disbursements' ] : { } end
Withdraw funds from a Wallet Account to a specified disbursement account .
10,335
def deposit ( options = { } ) response = JSON . parse ( @client . post ( "wallet_accounts/#{send(:id)}/deposit" , options ) . body ) response . key? ( 'disbursements' ) ? response [ 'disbursements' ] : { } end
Deposit funds to a Wallet Account from a specified payment account .
10,336
def user response = JSON . parse ( @client . get ( "wallet_accounts/#{send(:id)}/users" ) . body ) response . key? ( 'users' ) ? Promisepay :: User . new ( @client , response [ 'users' ] ) : nil end
Show the User the Wallet Account is associated with
10,337
def fee response = JSON . parse ( @client . get ( "transactions/#{send(:id)}/fees" ) . body ) response . key? ( 'fees' ) ? Promisepay :: Fee . new ( @client , response [ 'fees' ] ) : nil end
Gets a transactions fee details if applicable .
10,338
def create ( type = :session , attributes ) case type when :session if attributes && attributes [ :fee_ids ] && attributes [ :fee_ids ] . is_a? ( Array ) attributes [ :fee_ids ] = attributes [ :fee_ids ] . join ( ',' ) end response = @client . get ( 'request_session_token' , attributes ) JSON . parse ( response . body ...
Create a new token for an item
10,339
def find_all ( options = { } ) response = JSON . parse ( @client . get ( 'charges' , options ) . body ) charges = response . key? ( 'charges' ) ? response [ 'charges' ] : [ ] charges . map { | attributes | Promisepay :: Charge . new ( @client , attributes ) } end
List all charges
10,340
def create_async_doc ( doc , opts = { } ) data , _status_code , _headers = create_async_doc_with_http_info ( doc , opts ) return data end
Creates a document asynchronously . You must use a callback url or the the returned status id and the status api to find out when it completes . Then use the download api to get the document .
10,341
def create_doc ( doc , opts = { } ) data , _status_code , _headers = create_doc_with_http_info ( doc , opts ) return data end
Creates a document synchronously .
10,342
def get_async_doc ( id , opts = { } ) data , _status_code , _headers = get_async_doc_with_http_info ( id , opts ) return data end
Downloads a document .
10,343
def get_async_doc_status ( id , opts = { } ) data , _status_code , _headers = get_async_doc_status_with_http_info ( id , opts ) return data end
Check on the status of an asynchronously created document .
10,344
def likes verbs_of_interest = %w[ like unlike ] query = Activity . joins ( :verb ) . with_actor_id ( id : guid ) . with_target_id ( id : nil ) . merge ( Verb . with_display_name ( name : verbs_of_interest ) ) @likes ||= query . group ( :activity_object_id ) . having ( "COUNT(1) % 2 == 1" ) end
A list of activities the user likes
10,345
def likes? ( object ) verbs_of_interest = %w[ like unlike ] query = Activity . joins ( :verb ) . with_activity_object_id ( id : object . id ) . with_actor_id ( id : guid ) . merge ( Verb . with_display_name ( name : verbs_of_interest ) ) query . count . odd? end
Checks if the person likes the object or not
10,346
def add_audience_to_activity ( activity : ) object_ids_array . each do | audience_id | privacy = audience_privacy ( audience_id : audience_id ) audience = activity . audiences . build ( privacy : privacy ) audience . activity_object_id = audience_id if privacy == limited_privacy end end
Add an audience to the activity
10,347
def call audiences = [ merge_icon ( list : privacy_hash ( privacy_symbol : :public ) , icon : "fa-globe" ) ] audiences << merge_icon ( list : privacy_hash ( privacy_symbol : :circles ) , icon : "fa-google-circles" ) audiences . concat ( merge_icon ( list : person_list , icon : "fa-user" ) ) audiences . concat ( merge_i...
Instance Methods Invoke the AudienceList instance . This is the primary public API method . Create the audience list
10,348
def person_list return Person . none if @query . blank? result = select_display_name_alias_and_guids ( query : Person ) result . display_name_like ( query : "%#{@query}%" ) end
Build the list of people based on the query
10,349
def liked_by query = Activity . joins ( :verb ) . with_activity_object_id ( id : id ) likers = query . merge ( Verb . with_display_name ( name : "like" ) ) unlikers = query . merge ( Verb . with_display_name ( name : "unlike" ) ) people = likers . map ( & :actor ) unlikers . each do | activity | people . delete_at peop...
Instance Methods A list of people that like this activity object
10,350
def time_ago ( options : { } ) data = { behavior : "tooltip-on-hover" , time_ago : "moment.js" } options . reverse_merge! ( title : created_updated_tooltip_text , data : data ) time_tag ( options : options ) end
Builds an HTML time tag
10,351
def call create_circle ( display_name : "Friends" , content : friends_content ) create_circle ( display_name : "Family" , content : family_content ) create_circle ( display_name : "Acquaintances" , content : acquaintances_content ) create_circle ( display_name : "Following" , content : following_content ) end
Instance Methods Invoke the AddDefaultCircles instance . This is the primary public API method . Add the default circles
10,352
def call list = [ ] @activity . audiences . each do | audience | if audience . public? message = I18n . t ( "tooltip.public" , scope : "socializer.activities.audiences.index" ) return [ message ] end list . concat ( audience_list ( audience : audience ) ) end list . unshift ( @activity . activitable_actor . activitable...
Instance Methods Invoke the ActivityAudienceList instance . This is the primary public API method .
10,353
def limited_audience_list ( activitable : ) return [ activitable . display_name ] unless activitable . is_a? ( Circle ) activitable . contacts . pluck ( :display_name ) end
In the case of LIMITED audience then go through all the audience circles and add contacts from those circles in the list of allowed audience .
10,354
def comments activitable_type = ActivityObject . with_activitable_type ( type : Comment . name ) @comments ||= children . joins ( :activitable_object ) . merge ( activitable_type ) end
Retrieves the comments for an activity
10,355
def link_to_like_or_unlike return unless helpers . current_user options = current_user_likes? ? like_options : unlike_options like_or_unlike_link ( options : options ) end
Builds the like or unlike link
10,356
def image_tag_avatar ( size : nil , css_class : nil , alt : "Avatar" , title : nil ) width , height = parse_size ( size : size ) if size helpers . tag . img ( src : avatar_url , class : css_class , alt : alt , title : title , width : width , height : height , data : { behavior : "tooltip-on-hover" } ) end
Creates an image tag for the persons avatar
10,357
def link_to_avatar helpers . link_to ( image_tag_avatar ( title : model . display_name ) , helpers . person_activities_path ( person_id : model . id ) ) end
Creates a link to the persons profile with their avatar as the content
10,358
def toolbar_stream_links list = combine_circles_and_memberships return if list . blank? html = [ toolbar_links ( list [ 0 .. 2 ] ) ] html << toolbar_dropdown ( list [ 3 .. ( list . size ) ] ) helpers . safe_join ( html ) end
Builds the links for the shared toolbar
10,359
def get_contact ( id , opts = { } ) data , _status_code , _headers = get_contact_with_http_info ( id , opts ) return data end
Returns a specific student contact
10,360
def get_contacts_for_student ( id , opts = { } ) data , _status_code , _headers = get_contacts_for_student_with_http_info ( id , opts ) return data end
Returns the contacts for a student
10,361
def get_course ( id , opts = { } ) data , _status_code , _headers = get_course_with_http_info ( id , opts ) return data end
Returns a specific course
10,362
def get_course_for_section ( id , opts = { } ) data , _status_code , _headers = get_course_for_section_with_http_info ( id , opts ) return data end
Returns the course for a section
10,363
def get_district ( id , opts = { } ) data , _status_code , _headers = get_district_with_http_info ( id , opts ) return data end
Returns a specific district
10,364
def get_district_admin ( id , opts = { } ) data , _status_code , _headers = get_district_admin_with_http_info ( id , opts ) return data end
Returns a specific district admin
10,365
def get_district_for_contact ( id , opts = { } ) data , _status_code , _headers = get_district_for_contact_with_http_info ( id , opts ) return data end
Returns the district for a student contact
10,366
def get_district_for_course ( id , opts = { } ) data , _status_code , _headers = get_district_for_course_with_http_info ( id , opts ) return data end
Returns the district for a course
10,367
def get_district_for_district_admin ( id , opts = { } ) data , _status_code , _headers = get_district_for_district_admin_with_http_info ( id , opts ) return data end
Returns the district for a district admin
10,368
def get_district_for_school ( id , opts = { } ) data , _status_code , _headers = get_district_for_school_with_http_info ( id , opts ) return data end
Returns the district for a school
10,369
def get_district_for_school_admin ( id , opts = { } ) data , _status_code , _headers = get_district_for_school_admin_with_http_info ( id , opts ) return data end
Returns the district for a school admin
10,370
def get_district_for_section ( id , opts = { } ) data , _status_code , _headers = get_district_for_section_with_http_info ( id , opts ) return data end
Returns the district for a section
10,371
def get_district_for_student ( id , opts = { } ) data , _status_code , _headers = get_district_for_student_with_http_info ( id , opts ) return data end
Returns the district for a student
10,372
def get_district_for_teacher ( id , opts = { } ) data , _status_code , _headers = get_district_for_teacher_with_http_info ( id , opts ) return data end
Returns the district for a teacher
10,373
def get_district_for_term ( id , opts = { } ) data , _status_code , _headers = get_district_for_term_with_http_info ( id , opts ) return data end
Returns the district for a term
10,374
def get_school ( id , opts = { } ) data , _status_code , _headers = get_school_with_http_info ( id , opts ) return data end
Returns a specific school
10,375
def get_school_admin ( id , opts = { } ) data , _status_code , _headers = get_school_admin_with_http_info ( id , opts ) return data end
Returns a specific school admin
10,376
def get_school_for_section ( id , opts = { } ) data , _status_code , _headers = get_school_for_section_with_http_info ( id , opts ) return data end
Returns the school for a section
10,377
def get_school_for_student ( id , opts = { } ) data , _status_code , _headers = get_school_for_student_with_http_info ( id , opts ) return data end
Returns the primary school for a student
10,378
def get_school_for_teacher ( id , opts = { } ) data , _status_code , _headers = get_school_for_teacher_with_http_info ( id , opts ) return data end
Retrieves school info for a teacher .
10,379
def get_schools_for_school_admin ( id , opts = { } ) data , _status_code , _headers = get_schools_for_school_admin_with_http_info ( id , opts ) return data end
Returns the schools for a school admin
10,380
def get_schools_for_student ( id , opts = { } ) data , _status_code , _headers = get_schools_for_student_with_http_info ( id , opts ) return data end
Returns the schools for a student
10,381
def get_schools_for_teacher ( id , opts = { } ) data , _status_code , _headers = get_schools_for_teacher_with_http_info ( id , opts ) return data end
Returns the schools for a teacher
10,382
def get_section ( id , opts = { } ) data , _status_code , _headers = get_section_with_http_info ( id , opts ) return data end
Returns a specific section
10,383
def get_sections_for_course ( id , opts = { } ) data , _status_code , _headers = get_sections_for_course_with_http_info ( id , opts ) return data end
Returns the sections for a Courses
10,384
def get_sections_for_school ( id , opts = { } ) data , _status_code , _headers = get_sections_for_school_with_http_info ( id , opts ) return data end
Returns the sections for a school
10,385
def get_sections_for_student ( id , opts = { } ) data , _status_code , _headers = get_sections_for_student_with_http_info ( id , opts ) return data end
Returns the sections for a student
10,386
def get_sections_for_teacher ( id , opts = { } ) data , _status_code , _headers = get_sections_for_teacher_with_http_info ( id , opts ) return data end
Returns the sections for a teacher
10,387
def get_sections_for_term ( id , opts = { } ) data , _status_code , _headers = get_sections_for_term_with_http_info ( id , opts ) return data end
Returns the sections for a term
10,388
def get_student ( id , opts = { } ) data , _status_code , _headers = get_student_with_http_info ( id , opts ) return data end
Returns a specific student
10,389
def get_students_for_contact ( id , opts = { } ) data , _status_code , _headers = get_students_for_contact_with_http_info ( id , opts ) return data end
Returns the students for a student contact
10,390
def get_students_for_school ( id , opts = { } ) data , _status_code , _headers = get_students_for_school_with_http_info ( id , opts ) return data end
Returns the students for a school
10,391
def get_students_for_section ( id , opts = { } ) data , _status_code , _headers = get_students_for_section_with_http_info ( id , opts ) return data end
Returns the students for a section
10,392
def get_students_for_teacher ( id , opts = { } ) data , _status_code , _headers = get_students_for_teacher_with_http_info ( id , opts ) return data end
Returns the students for a teacher
10,393
def get_teacher ( id , opts = { } ) data , _status_code , _headers = get_teacher_with_http_info ( id , opts ) return data end
Returns a specific teacher
10,394
def get_teacher_for_section ( id , opts = { } ) data , _status_code , _headers = get_teacher_for_section_with_http_info ( id , opts ) return data end
Returns the primary teacher for a section
10,395
def get_teachers_with_http_info ( opts = { } ) if @api_client . config . debugging @api_client . config . logger . debug "Calling API: DataApi.get_teachers ..." end local_var_path = "/teachers" query_params = { } query_params [ :' ' ] = opts [ :' ' ] if ! opts [ :' ' ] . nil? query_params [ :' ' ] = opts [ :' ' ] if ! ...
Returns a list of teachers
10,396
def get_teachers_for_school ( id , opts = { } ) data , _status_code , _headers = get_teachers_for_school_with_http_info ( id , opts ) return data end
Returns the teachers for a school
10,397
def get_teachers_for_section ( id , opts = { } ) data , _status_code , _headers = get_teachers_for_section_with_http_info ( id , opts ) return data end
Returns the teachers for a section
10,398
def get_teachers_for_student ( id , opts = { } ) data , _status_code , _headers = get_teachers_for_student_with_http_info ( id , opts ) return data end
Returns the teachers for a student
10,399
def get_term ( id , opts = { } ) data , _status_code , _headers = get_term_with_http_info ( id , opts ) return data end
Returns a specific term