Module: ZohoReports::ZohoReportify::ClassMethods

Defined in:
lib/zoho_reports/zoho_reportify.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.initialize_zoho_tableObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 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

Instance Method Details

#zoho_reportify(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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