module ZohoReports::ZohoReportify::ClassMethods

Public Class Methods

initialize_zoho_table() click to toggle source
# File lib/zoho_reports/zoho_reportify.rb, line 17
def self.initialize_zoho_table
  client = ZohoReports::Client.new

  # Pre-process attributes to be better with Zoho
  zoho_all = []
  all.each do |model|
    zoho_all << ZohoReports::Client.zoho_attributes(model.attributes)
  end

  client.import_data(
    self.table_name, 
    'UPDATEADD', 
    zoho_all.to_json, 
    'ZOHO_CREATE_TABLE' => 'true', 
  )

end

Public Instance Methods

zoho_reportify(options = {}) click to toggle source
# File lib/zoho_reports/zoho_reportify.rb, line 14
def zoho_reportify(options = {})
  after_save :save_zoho_record

  def self.initialize_zoho_table
    client = ZohoReports::Client.new

    # Pre-process attributes to be better with Zoho
    zoho_all = []
    all.each do |model|
      zoho_all << ZohoReports::Client.zoho_attributes(model.attributes)
    end

    client.import_data(
      self.table_name, 
      'UPDATEADD', 
      zoho_all.to_json, 
      'ZOHO_CREATE_TABLE' => 'true', 
    )

  end

  include ZohoReports::ZohoReportify::LocalInstanceMethods
end