class Crm::Core::BasicResource

BasicResource is the base class of all JustRelate WebCRM SDK resources. @api public

Public Class Methods

base_type() click to toggle source
# File lib/crm/core/basic_resource.rb, line 7
def self.base_type
  name.split(/::/).last
end
path() click to toggle source
# File lib/crm/core/basic_resource.rb, line 15
def self.path
  resource_name.pluralize
end
resource_name() click to toggle source
# File lib/crm/core/basic_resource.rb, line 11
def self.resource_name
  base_type.underscore
end

Public Instance Methods

==(other)
Alias for: eql?
eql?(other) click to toggle source
# File lib/crm/core/basic_resource.rb, line 55
def eql?(other)
  other.equal?(self) || other.instance_of?(self.class) && other.id == id
end
Also aliased as: ==
id() click to toggle source

Returns the ID of this item. @return [String] @api public

# File lib/crm/core/basic_resource.rb, line 22
def id
  self['id']
end
path() click to toggle source
# File lib/crm/core/basic_resource.rb, line 26
def path
  [self.class.path, id].compact.join('/')
end
reload() click to toggle source

Reloads the attributes of this item from the remote web service. @example

contact.locality
# => 'Bergen'

# Assume this contact has been modified concurrently.

contact.reload
# => Crm::Contact

contact.locality
# => 'Oslo'

@return [self] the reloaded item. @api public

# File lib/crm/core/basic_resource.rb, line 51
def reload
  load_attributes(RestApi.instance.get(path))
end
type() click to toggle source

Returns the type object of this item. @return [Crm::Type] @api public

# File lib/crm/core/basic_resource.rb, line 33
def type
  ::Crm::Type.find(type_id)
end

Private Instance Methods

if_match_header() click to toggle source
# File lib/crm/core/basic_resource.rb, line 64
def if_match_header
  {'If-Match' => self['version']}
end