module CrudMethods

Public Class Methods

included(base) click to toggle source
# File lib/crud_methods.rb, line 3
def self.included(base)
  base.extend(ClassMethods)
end

Public Instance Methods

attach_file(file_path, file_name) click to toggle source
# File lib/crud_methods.rb, line 50
def attach_file(file_path, file_name)
  RubyZoho.configuration.api.attach_file(self.class.module_name, self.send(primary_key), file_path, file_name)
end
create(object_attribute_hash) click to toggle source
# File lib/crud_methods.rb, line 54
def create(object_attribute_hash)
  initialize(object_attribute_hash)
  save
end
save() click to toggle source
# File lib/crud_methods.rb, line 59
def save
  h = {}
  @fields.each { |f| h.merge!({ f => eval("self.#{f.to_s}") }) }
  h.delete_if { |k, v| v.nil? }
  r = RubyZoho.configuration.api.add_record(self.class.module_name, h)
  up_date(r)
end
save_object(object) click to toggle source
# File lib/crud_methods.rb, line 67
def save_object(object)
  h = {}
  object.fields.each { |f| h.merge!({ f => object.send(f) }) }
  h.delete_if { |k, v| v.nil? }
  r = RubyZoho.configuration.api.add_record(object.module_name, h)
  up_date(r)
end
up_date(object_attribute_hash) click to toggle source
# File lib/crud_methods.rb, line 75
def up_date(object_attribute_hash)
  update_or_create_attrs(object_attribute_hash)
  self
end