activesalesforce 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/asf_adapter.rb +15 -10
- data/lib/entity_definition.rb +3 -2
- metadata +2 -2
data/lib/asf_adapter.rb
CHANGED
@@ -105,7 +105,7 @@ module ActiveRecord
|
|
105
105
|
MAX_BOXCAR_SIZE = 200
|
106
106
|
|
107
107
|
attr_accessor :batch_size
|
108
|
-
attr_reader :entity_def_map, :keyprefix_to_entity_def_map, :config
|
108
|
+
attr_reader :entity_def_map, :keyprefix_to_entity_def_map, :config, :class_to_entity_map
|
109
109
|
|
110
110
|
def initialize(connection, logger, connection_options, config)
|
111
111
|
super(connection, logger)
|
@@ -121,8 +121,10 @@ module ActiveRecord
|
|
121
121
|
|
122
122
|
|
123
123
|
def set_class_for_entity(klass, entity_name)
|
124
|
-
@logger.debug("Setting @class_to_entity_map['#{entity_name.upcase}'] = #{klass}")
|
124
|
+
@logger.debug("Setting @class_to_entity_map['#{entity_name.upcase}'] = #{klass} for connection #{self}")
|
125
125
|
@class_to_entity_map[entity_name.upcase] = klass
|
126
|
+
|
127
|
+
pp @class_to_entity_map
|
126
128
|
end
|
127
129
|
|
128
130
|
|
@@ -541,13 +543,13 @@ module ActiveRecord
|
|
541
543
|
|
542
544
|
key_prefix = metadata[:keyPrefix]
|
543
545
|
|
544
|
-
entity_def = ActiveSalesforce::EntityDefinition.new(self, entity_name,
|
546
|
+
entity_def = ActiveSalesforce::EntityDefinition.new(self, entity_name, entity_klass,
|
545
547
|
cached_columns, cached_relationships, custom, key_prefix)
|
546
548
|
|
547
549
|
@entity_def_map[entity_name] = entity_def
|
548
550
|
@keyprefix_to_entity_def_map[key_prefix] = entity_def
|
549
551
|
|
550
|
-
configure_active_record
|
552
|
+
configure_active_record(entity_def)
|
551
553
|
|
552
554
|
entity_def
|
553
555
|
}
|
@@ -557,7 +559,7 @@ module ActiveRecord
|
|
557
559
|
def configure_active_record(entity_def)
|
558
560
|
entity_name = entity_def.name
|
559
561
|
klass = class_from_entity_name(entity_name)
|
560
|
-
|
562
|
+
|
561
563
|
class << klass
|
562
564
|
def asf_augmented?
|
563
565
|
true
|
@@ -567,7 +569,7 @@ module ActiveRecord
|
|
567
569
|
# Add support for SID-based authentication
|
568
570
|
ActiveSalesforce::SessionIDAuthenticationFilter.register(klass)
|
569
571
|
|
570
|
-
klass.set_inheritance_column nil
|
572
|
+
klass.set_inheritance_column nil unless entity_def.custom?
|
571
573
|
klass.set_primary_key "id"
|
572
574
|
klass.lock_optimistically = false
|
573
575
|
klass.record_timestamps = false
|
@@ -584,7 +586,7 @@ module ActiveRecord
|
|
584
586
|
# DCHASMAN TODO Figure out how to handle polymorphic refs (e.g. Note.parent can refer to
|
585
587
|
# Account, Contact, Opportunity, Contract, Asset, Product2, <CustomObject1> ... <CustomObject(n)>
|
586
588
|
if reference_to.is_a? Array
|
587
|
-
@logger.debug(" Skipping unsupported polymophic one-to-#{one_to_many ? 'many' : 'one' } relationship '#{referenceName}' from #{
|
589
|
+
@logger.debug(" Skipping unsupported polymophic one-to-#{one_to_many ? 'many' : 'one' } relationship '#{referenceName}' from #{klass} to [#{relationship.reference_to.join(', ')}] using #{foreign_key}")
|
588
590
|
next
|
589
591
|
end
|
590
592
|
|
@@ -599,16 +601,19 @@ module ActiveRecord
|
|
599
601
|
|
600
602
|
referenced_klass = klass.class_eval("::#{reference_to} = Class.new(ActiveRecord::Base)")
|
601
603
|
|
604
|
+
# Automatically inherit the connection from the referencee
|
605
|
+
referenced_klass.connection = klass.connection
|
606
|
+
|
602
607
|
# configure_active_record(get_entity_def(reference_to))
|
603
608
|
end
|
604
609
|
|
605
610
|
if one_to_many
|
606
|
-
klass.has_many referenceName.to_sym, :class_name =>
|
611
|
+
klass.has_many referenceName.to_sym, :class_name => referenced_klass.name, :foreign_key => foreign_key, :dependent => false
|
607
612
|
else
|
608
|
-
klass.belongs_to referenceName.to_sym, :class_name =>
|
613
|
+
klass.belongs_to referenceName.to_sym, :class_name => referenced_klass.name, :foreign_key => foreign_key, :dependent => false
|
609
614
|
end
|
610
615
|
|
611
|
-
|
616
|
+
@logger.debug(" Created one-to-#{one_to_many ? 'many' : 'one' } relationship '#{referenceName}' from #{klass} to #{referenced_klass} using #{foreign_key}")
|
612
617
|
|
613
618
|
end
|
614
619
|
end
|
data/lib/entity_definition.rb
CHANGED
@@ -23,11 +23,12 @@ require 'pp'
|
|
23
23
|
|
24
24
|
module ActiveSalesforce
|
25
25
|
class EntityDefinition
|
26
|
-
attr_reader :name, :columns, :column_name_to_column, :api_name_to_column, :relationships, :key_prefix
|
26
|
+
attr_reader :name, :asf_class, :columns, :column_name_to_column, :api_name_to_column, :relationships, :key_prefix
|
27
27
|
|
28
|
-
def initialize(connection, name, columns, relationships, custom, key_prefix)
|
28
|
+
def initialize(connection, name, asf_class, columns, relationships, custom, key_prefix)
|
29
29
|
@connection = connection
|
30
30
|
@name = name
|
31
|
+
@asf_class = asf_class
|
31
32
|
@columns = columns
|
32
33
|
@relationships = relationships
|
33
34
|
@custom = custom
|
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.4.
|
7
|
-
date: 2006-03-
|
6
|
+
version: 0.4.5
|
7
|
+
date: 2006-03-15 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
|