activesalesforce 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/asf_adapter.rb +19 -5
- metadata +2 -2
data/lib/asf_adapter.rb
CHANGED
@@ -395,7 +395,15 @@ module ActiveRecord
|
|
395
395
|
|
396
396
|
def get_entity_def(entity_name)
|
397
397
|
cached_entity_def = @entity_def_map[entity_name]
|
398
|
-
|
398
|
+
|
399
|
+
if cached_entity_def
|
400
|
+
# Check for the loss of asf AR setup
|
401
|
+
entity_klass = entity_name.constantize
|
402
|
+
|
403
|
+
configure_active_record cached_entity_def unless entity_klass.respond_to?(:asf_augmented?)
|
404
|
+
|
405
|
+
return cached_entity_def
|
406
|
+
end
|
399
407
|
|
400
408
|
log("Retrieving metadata for '#{entity_name}'", "get_entity_def()") {
|
401
409
|
cached_columns = []
|
@@ -406,7 +414,7 @@ module ActiveRecord
|
|
406
414
|
custom = false
|
407
415
|
rescue SalesforceError => e
|
408
416
|
# Fallback and see if we can find a custom object with this name
|
409
|
-
@logger.
|
417
|
+
@logger.debug(" Unable to find medata for '#{entity_name}', falling back to custom object name #{entity_name + "__c"}")
|
410
418
|
|
411
419
|
metadata = get_result(@connection.describeSObject(:sObjectType => entity_name + "__c"), :describeSObject)
|
412
420
|
custom = true
|
@@ -445,6 +453,12 @@ module ActiveRecord
|
|
445
453
|
entity_name = entity_def.name
|
446
454
|
klass = entity_name.constantize
|
447
455
|
|
456
|
+
class << klass
|
457
|
+
def asf_augmented?
|
458
|
+
true
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
448
462
|
klass.set_inheritance_column nil
|
449
463
|
klass.lock_optimistically = false
|
450
464
|
klass.record_timestamps = false
|
@@ -461,7 +475,7 @@ module ActiveRecord
|
|
461
475
|
# DCHASMAN TODO Figure out how to handle polymorphic refs (e.g. Note.parent can refer to
|
462
476
|
# Account, Contact, Opportunity, Contract, Asset, Product2, <CustomObject1> ... <CustomObject(n)>
|
463
477
|
if reference_to.is_a? Array
|
464
|
-
@logger.
|
478
|
+
@logger.debug(" Skipping unsupported polymophic one-to-#{one_to_many ? 'many' : 'one' } relationship '#{referenceName}' from #{entity_name} to [#{relationship.reference_to.join(', ')}] using #{foreign_key}")
|
465
479
|
next
|
466
480
|
end
|
467
481
|
|
@@ -472,7 +486,7 @@ module ActiveRecord
|
|
472
486
|
referenced_klass = reference_to.constantize
|
473
487
|
rescue NameError => e
|
474
488
|
# Automatically create a least a stub for the referenced entity
|
475
|
-
@logger.
|
489
|
+
@logger.debug(" Creating ActiveRecord stub for the referenced entity '#{reference_to}'")
|
476
490
|
|
477
491
|
referenced_klass = klass.class_eval("::#{reference_to} = Class.new(ActiveRecord::Base)")
|
478
492
|
|
@@ -485,7 +499,7 @@ module ActiveRecord
|
|
485
499
|
klass.belongs_to referenceName.to_sym, :class_name => reference_to, :foreign_key => foreign_key, :dependent => false
|
486
500
|
end
|
487
501
|
|
488
|
-
@logger.
|
502
|
+
@logger.debug(" Created one-to-#{one_to_many ? 'many' : 'one' } relationship '#{referenceName}' from #{entity_name} to #{relationship.reference_to} using #{foreign_key}")
|
489
503
|
|
490
504
|
end
|
491
505
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: activesalesforce
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-02-
|
6
|
+
version: 0.3.0
|
7
|
+
date: 2006-02-22 00:00:00 -05:00
|
8
8
|
summary: ActiveSalesforce (ASF) is a Rails connection adapter that provides direct access to Salesforce.com hosted data and metadata via the ActiveRecord model layer. Objects, fields, and relationships are all auto surfaced as active record attributes and rels.
|
9
9
|
require_paths:
|
10
10
|
- lib
|