Method: QuickBase::Client#method_missing

Defined in:
lib/QuickBaseClient.rb

#method_missing(missing_method_name, *missing_method_args) ⇒ Object

Enables alternative syntax for processing data using id values or xml element names. E.g:

qbc.bcdcajmrh.qid_1.printChildElements(qbc.records)

  • prints the records returned by query 1 from table bcdcajmrh

puts qbc.bcdcajmrf.xml_desc

  • get the description from the bcdcajmrf application

puts qbc.dbid_8emtadvk.rid_24105.fid_6

  • print field 6 from record 24105 in table 8emtadvk



665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
# File 'lib/QuickBaseClient.rb', line 665

def method_missing(missing_method_name, *missing_method_args)
  method_s = missing_method_name.to_s
  if method_s.match(/dbid_.+/) 
    if QuickBase::Misc.isDbidString?(method_s.sub("dbid_",""))
       getSchema(method_s.sub("dbid_","")) 
    end
  elsif @dbid and method_s.match(/rid_[0-9]+/) 
    _setActiveRecord(method_s.sub("rid_",""))
    @fieldValue = @field_data_list
  elsif @dbid and method_s.match(/qid_[0-9]+/) 
    doQuery(@dbid,nil,method_s.sub("qid_",""))
  elsif @dbid and method_s.match(/fid_[0-9]+/) 
     if @field_data_list
       @fieldValue = getFieldDataValue(method_s.sub("fid_","")) 
    else
       lookupField(method_s.sub("fid_",""))
    end  
  elsif @dbid and method_s.match(/pageid_[0-9]+/) 
    _getDBPage(method_s.sub("pageid_",""))
  elsif @dbid and method_s.match(/userid_.+/)
    _getUserRole(method_s.sub("userid_",""))       
  elsif @dbid and @rid and @fid and method_s.match(/vid_[0-9]+/) 
     downLoadFile( @dbid, @rid, @fid, method_s.sub("vid_","") )
  elsif @dbid and method_s.match(/import_[0-9]+/)
    _runImport(method_s.sub("import_",""))
  elsif @qdbapi and method_s.match(/xml_.+/)
    if missing_method_args and missing_method_args.length > 0
       @fieldValue = @qdbapi.send(method_s.sub("xml_",""),missing_method_args)
    else
       @fieldValue = @qdbapi.send(method_s.sub("xml_",""))
    end
  elsif QuickBase::Misc.isDbidString?(method_s)
    getSchema(method_s) 
  else  
    raise "'#{method_s}' is not a valid method in the QuickBase::Client class."
  end
  return @fieldValue if @fieldValue.is_a?(REXML::Element) # chain XML lookups
  return @fieldValue if @fieldValue.is_a?(String) # assume we just want a field value 
  self # otherwise, allows chaining of all above
end