module CrudMethods::ClassMethods
Public Instance Methods
all()
click to toggle source
# File lib/crud_methods.rb, line 14 def all #TODO Refactor into low level API max_records = 200 result = [] begin batch = RubyZoho.configuration.api.some(self.module_name, result.count + 1, max_records) result.concat(batch) unless batch.nil? end until batch.nil? || (batch.length < max_records) result.collect { |r| new(r) } end
delete(id)
click to toggle source
# File lib/crud_methods.rb, line 28 def delete(id) RubyZoho.configuration.api.delete_record(self.module_name, id) end
find(id)
click to toggle source
# File lib/crud_methods.rb, line 24 def find(id) self.find_by_id(id) end
first()
click to toggle source
# File lib/crud_methods.rb, line 9 def first r = RubyZoho.configuration.api.first(self.module_name) new(r[0]) end
update(object_attribute_hash)
click to toggle source
# File lib/crud_methods.rb, line 32 def update(object_attribute_hash) raise(RuntimeError, 'No ID found', object_attribute_hash.to_s) if object_attribute_hash[:id].nil? id = object_attribute_hash[:id] object_attribute_hash.delete(:id) r = RubyZoho.configuration.api.update_record(self.module_name, id, object_attribute_hash) new(object_attribute_hash.merge!(r)) end