module Crm::Helpers::Persistence
Public Class Methods
included(base)
click to toggle source
# File lib/crm/helpers/persistence.rb, line 6 def self.included(base) base.extend ClassMethods end
Public Instance Methods
destroy()
click to toggle source
# File lib/crm/helpers/persistence.rb, line 50 def destroy crm_object.destroy self end
persist()
click to toggle source
# File lib/crm/helpers/persistence.rb, line 55 def persist return false if invalid? @crm_object = if crm_object.nil? self.class.crm_class.create(crm_attributes) else crm_object.update(crm_attributes) end assign_crm_attributes(crm_object.attributes) true end
save()
click to toggle source
# File lib/crm/helpers/persistence.rb, line 28 def save update end
save!()
click to toggle source
# File lib/crm/helpers/persistence.rb, line 32 def save! update! end
update(attributes = {})
click to toggle source
# File lib/crm/helpers/persistence.rb, line 36 def update(attributes = {}) assign_crm_attributes(attributes) return false if invalid? persist end
update!(attributes = {})
click to toggle source
# File lib/crm/helpers/persistence.rb, line 43 def update!(attributes = {}) assign_crm_attributes(attributes) raise Crm::Errors::InvalidValues.new('', errors) if invalid? persist end
Protected Instance Methods
crm_object()
click to toggle source
# File lib/crm/helpers/persistence.rb, line 69 def crm_object return @crm_object if defined?(@crm_object) return nil if id.blank? @crm_object = self.class.crm_class.find(id) end