Class: CapsuleCRM::Base

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Dirty, HTTParty
Defined in:
lib/capsulecrm/base.rb

Direct Known Subclasses

Child, Opportunity, Party

Constant Summary collapse

@@last_response =
nil

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Base

nodoc



27
28
29
30
31
32
# File 'lib/capsulecrm/base.rb', line 27

def initialize(attributes={})
  attributes.each do |name, value|
    send("#{name}=", value)
  end
  changed_attributes.clear
end

Instance Attribute Details

#idObject

nodoc



16
17
18
# File 'lib/capsulecrm/base.rb', line 16

def id
  @id
end

#raw_dataObject

Returns the value of attribute raw_data.



17
18
19
# File 'lib/capsulecrm/base.rb', line 17

def raw_data
  @raw_data
end

Class Method Details

.find(what, options = {}) ⇒ Object

nodoc



65
66
67
68
# File 'lib/capsulecrm/base.rb', line 65

def self.find(what, options={})
  return find_all(options) if what == :all
  find_one(what)
end

.last_responseObject

for debugging



72
73
74
# File 'lib/capsulecrm/base.rb', line 72

def self.last_response
  @@last_response
end

Instance Method Details

#==(other) ⇒ Object

nodoc



36
37
38
39
# File 'lib/capsulecrm/base.rb', line 36

def ==(other)
  return false if other.nil?
  id == other.id
end

#errorsObject

nodoc



50
51
52
# File 'lib/capsulecrm/base.rb', line 50

def errors
  @errors ||= []
end

#new_record?Boolean

nodoc

Returns:

  • (Boolean)


56
57
58
# File 'lib/capsulecrm/base.rb', line 56

def new_record?
  id.nil?
end