sugarcrm 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,7 +12,7 @@ RubyGem for interacting with SugarCRM via REST.
12
12
 
13
13
  A less clunky way to interact with SugarCRM via REST.
14
14
 
15
- Instead of SugarCRM.connection.get_entry("Users", "1"), you can use SugarCRM::User.find(1). There is also support for collections à la SugarCRM::User.find(1).email_addresses, or SugarCRM::Contact.first.meetings << new_meeting. ActiveRecord style finders are in place, with limited support for conditions and joins.
15
+ Instead of SugarCRM.connection.get_entry("Users", "1") you could use SugarCRM::User.find(1). There is support for collections à la SugarCRM::User.find(1).email_addresses, or SugarCRM::Contact.first.meetings << new_meeting. ActiveRecord style finders are in place, with limited support for conditions and joins.
16
16
 
17
17
  == FEATURES/PROBLEMS:
18
18
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.0
1
+ 0.9.1
@@ -44,15 +44,10 @@ module SugarCRM; module AssociationMethods
44
44
  query_association :#{k}
45
45
  end
46
46
  ?
47
- #seed_association_cache(k.to_syn)
48
47
  end
49
48
  self.class.association_methods_generated = true
50
49
  end
51
50
 
52
- # def seed_association_cache(association)
53
- # @association_cache[association] = AssociationCollection.new(self,association)
54
- # end
55
-
56
51
  # Returns the records from the associated module or returns the cached copy if we've already
57
52
  # loaded it. Force a reload of the records with reload=true
58
53
  #
@@ -76,17 +71,4 @@ module SugarCRM; module AssociationMethods
76
71
  collection
77
72
  end
78
73
 
79
- # Loads related records for the given association
80
- # def load_associations_for(association)
81
- # SugarCRM.connection.get_relationships(self.class._module.name, self.id, association.to_s)
82
- # end
83
-
84
- # pushes an element to the association collection
85
- def append_to_association(association, record)
86
- collection = query_association(association)
87
- collection << record
88
- collection
89
- end
90
-
91
-
92
74
  end; end
@@ -2,7 +2,6 @@ module SugarCRM; module AttributeMethods
2
2
 
3
3
  module ClassMethods
4
4
  # Returns a hash of the module fields from the module
5
- # merges matching keys if another attributes hash is provided
6
5
  def attributes_from_module_fields
7
6
  fields = {}.with_indifferent_access
8
7
  self._module.fields.keys.sort.each do |k|
@@ -12,10 +11,6 @@ module SugarCRM; module AttributeMethods
12
11
  end
13
12
  end
14
13
 
15
- # TODO: Object.id is not being updated properly. Figure out why...
16
- alias :pk :id
17
- alias :primary_key :id
18
-
19
14
  # Determines if attributes or associations have been changed
20
15
  def changed?
21
16
  return true if attributes_changed?
@@ -43,7 +38,7 @@ module SugarCRM; module AttributeMethods
43
38
  # with attributes from the module.fields array. Skips any
44
39
  # fields that aren't in the module.fields array
45
40
  #
46
- # BUG: SugarCRM likes to return fields you don't ask for, and
41
+ # BUG: SugarCRM likes to return fields you don't ask for and
47
42
  # aren't fields on a module (i.e. modified_user_name). This
48
43
  # royally screws up our typecasting code, so we handle it here.
49
44
  def merge_attributes(attrs={})
@@ -21,9 +21,9 @@ module SugarCRM; module AttributeSerializers
21
21
  end
22
22
 
23
23
  # Converts the modified_attributes hash into format recognizable by Sugar
24
- # { :last_name => {:old => "Smit", :new => "Smith"}}
24
+ # {:last_name => {:old => "Smit", :new => "Smith"}}
25
25
  # becomes
26
- # { :last_name => {:name => "last_name", :value => "Smith"}}
26
+ # {:last_name => {:name => "last_name", :value => "Smith"}}
27
27
  def serialize_modified_attributes
28
28
  attr_hash = {}
29
29
  @modified_attributes.each_pair do |name,hash|
@@ -33,7 +33,7 @@ module SugarCRM; module AttributeSerializers
33
33
  attr_hash
34
34
  end
35
35
 
36
- # Un-typecasts the attribute - false becomes 0
36
+ # Un-typecasts the attribute - false becomes "0", 5234 becomes "5234", etc.
37
37
  def serialize_attribute(name,value)
38
38
  attr_value = value
39
39
  attr_type = attr_type_for(name)
@@ -4,13 +4,11 @@ module SugarCRM; module AttributeTypeCast
4
4
 
5
5
  # Returns the attribute type for a given attribute
6
6
  def attr_type_for(attribute)
7
- # sometimes the module fields aren't loaded. Why?
8
7
  fields = self.class._module.fields
9
8
  field = fields[attribute]
10
9
  raise UninitializedModule, "SugarCRM::Module #{self.class._module.name} was not initialized properly (fields.length == 0)" if fields.length == 0
11
10
  raise InvalidAttribute, "#{self.class}_module.fields does not contain an entry for #{attribute} (of type: #{attribute.class})\nValid fields: #{self.class._module.fields.keys.sort.join(", ")}" if field.nil?
12
11
  raise InvalidAttributeType, "#{self.class}._module.fields[#{attribute}] does not have a key for \'type\'" if field["type"].nil?
13
- #return :string unless field.is_a? Hash
14
12
  field["type"].to_sym
15
13
  end
16
14
 
@@ -32,7 +32,7 @@ module SugarCRM; class Base
32
32
  @debug = options[:debug]
33
33
  @@connection = SugarCRM::Connection.new(url, user, pass, options)
34
34
  end
35
-
35
+
36
36
  def find(*args)
37
37
  options = args.extract_options!
38
38
  validate_find_options(options)
@@ -199,23 +199,6 @@ module SugarCRM; class Base
199
199
  if match.finder?
200
200
  finder = match.finder
201
201
  bang = match.bang?
202
- # def self.find_by_login_and_activated(*args)
203
- # options = args.extract_options!
204
- # attributes = construct_attributes_from_arguments(
205
- # [:login,:activated],
206
- # args
207
- # )
208
- # finder_options = { :conditions => attributes }
209
- # validate_find_options(options)
210
- #
211
- # if options[:conditions]
212
- # with_scope(:find => finder_options) do
213
- # find(:first, options)
214
- # end
215
- # else
216
- # find(:first, options.merge(finder_options))
217
- # end
218
- # end
219
202
  self.class_eval <<-EOS, __FILE__, __LINE__ + 1
220
203
  def self.#{method_id}(*args)
221
204
  options = args.extract_options!
@@ -239,31 +222,6 @@ module SugarCRM; class Base
239
222
  send(method_id, *arguments)
240
223
  elsif match.instantiator?
241
224
  instantiator = match.instantiator
242
- # def self.find_or_create_by_user_id(*args)
243
- # guard_protected_attributes = false
244
- #
245
- # if args[0].is_a?(Hash)
246
- # guard_protected_attributes = true
247
- # attributes = args[0].with_indifferent_access
248
- # find_attributes = attributes.slice(*[:user_id])
249
- # else
250
- # find_attributes = attributes = construct_attributes_from_arguments([:user_id], args)
251
- # end
252
- #
253
- # options = { :conditions => find_attributes }
254
- # set_readonly_option!(options)
255
- #
256
- # record = find(:first, options)
257
- #
258
- # if record.nil?
259
- # record = self.new { |r| r.send(:attributes=, attributes, guard_protected_attributes) }
260
- # yield(record) if block_given?
261
- # record.save
262
- # record
263
- # else
264
- # record
265
- # end
266
- # end
267
225
  self.class_eval <<-EOS, __FILE__, __LINE__ + 1
268
226
  def self.#{method_id}(*args)
269
227
  attributes = [:#{attribute_names.join(',:')}]
@@ -322,10 +280,6 @@ module SugarCRM; class Base
322
280
  end
323
281
 
324
282
  # Creates an instance of a Module Class, i.e. Account, User, Contact, etc.
325
- # This call depends upon SugarCRM.modules having actual data in it. If you
326
- # are using Base.establish_connection, you should be fine. But if you are
327
- # using the Connection class by itself, you may need to prime the pump with
328
- # a call to Module.register_all
329
283
  def initialize(attributes={})
330
284
  @modified_attributes = {}
331
285
  merge_attributes(attributes.with_indifferent_access)
@@ -362,8 +316,8 @@ module SugarCRM; class Base
362
316
  true
363
317
  end
364
318
 
365
- # Saves the current object, checks that required fields are present.
366
- # raises an exception if a save fails
319
+ # Saves the current object, and any modified associations.
320
+ # Raises an exceptions if save fails for any reason.
367
321
  def save!
368
322
  save_modified_attributes
369
323
  save_modified_associations
@@ -400,8 +354,6 @@ module SugarCRM; class Base
400
354
  id.hash
401
355
  end
402
356
 
403
-
404
- # Wrapper around class attribute
405
357
  def attribute_methods_generated?
406
358
  self.class.attribute_methods_generated
407
359
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sugarcrm
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 57
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 0
10
- version: 0.9.0
9
+ - 1
10
+ version: 0.9.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Carl Hicks
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-29 00:00:00 -08:00
18
+ date: 2011-01-04 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency