module Mycrm::Model::InstanceMethods
provides methods for the instance
Public Class Methods
new(attributes = nil)
click to toggle source
Calls superclass method
# File lib/mycrm/model.rb, line 21 def initialize(attributes = nil) partitions = (attributes || []).partition{ |field, _| attribute_set[field].nil? } super(partitions.last.to_h) partitions.first.each { |field, value| send("#{field}=", value) rescue nil } end
Public Instance Methods
create!()
click to toggle source
# File lib/mycrm/model.rb, line 27 def create! mass_assign(self.class.execute(:post, nil, to_json)) end
delete!()
click to toggle source
# File lib/mycrm/model.rb, line 35 def delete! self.class.execute(:delete, id, nil) end
mass_assign(json)
click to toggle source
# File lib/mycrm/model.rb, line 47 def mass_assign(json) attribute_set.set(self, json) end
swoop(_, v)
click to toggle source
# File lib/mycrm/model.rb, line 43 def swoop(_, v) (v.is_a?(Hash) ? v.delete_if(&method(:swoop)) : v.to_s).empty? end
to_json()
click to toggle source
# File lib/mycrm/model.rb, line 39 def to_json VirtusConvert.new(self).to_hash.delete_if(&method(:swoop)) end
update!()
click to toggle source
# File lib/mycrm/model.rb, line 31 def update! mass_assign(self.class.execute(:put, id, to_json)) end