Class: ActiveRecord::ConnectionAdapters::SalesforceRelationship
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::SalesforceRelationship
- Includes:
- StringHelper
- Defined in:
- lib/relationship_definition.rb
Instance Attribute Summary collapse
-
#api_name ⇒ Object
readonly
Returns the value of attribute api_name.
-
#custom ⇒ Object
readonly
Returns the value of attribute custom.
-
#foreign_key ⇒ Object
readonly
Returns the value of attribute foreign_key.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#one_to_many ⇒ Object
readonly
Returns the value of attribute one_to_many.
-
#reference_to ⇒ Object
readonly
Returns the value of attribute reference_to.
Instance Method Summary collapse
-
#initialize(source, column = nil) ⇒ SalesforceRelationship
constructor
A new instance of SalesforceRelationship.
Methods included from StringHelper
Constructor Details
#initialize(source, column = nil) ⇒ SalesforceRelationship
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/relationship_definition.rb', line 35 def initialize(source, column = nil) if source[:childSObject] relationship = source if relationship[:relationshipName] @api_name = relationship[:relationshipName] @one_to_many = true @label = @api_name @name = column_nameize(@api_name) @custom = false else @api_name = relationship[:field] @one_to_many = relationship[:cascadeDelete] == "true" @label = relationship[:childSObject].pluralize @custom = relationship[:childSObject].match(/__c$/) name = relationship[:childSObject] name = name.chop.chop.chop if custom @name = column_nameize(name.pluralize) @name = @name + "__c" if custom end @reference_to = relationship[:childSObject] @foreign_key = column_nameize(relationship[:field]) @foreign_key = @foreign_key.chop.chop << "id__c" if @foreign_key.match(/__c$/) else field = source @api_name = field[:name] @custom = field[:custom] == "true" @api_name = @api_name.chop.chop unless @custom @label = field[:label] @reference_to = field[:referenceTo] @one_to_many = false @foreign_key = column.name @name = column_nameize(@api_name) end end |
Instance Attribute Details
#api_name ⇒ Object (readonly)
Returns the value of attribute api_name.
33 34 35 |
# File 'lib/relationship_definition.rb', line 33 def api_name @api_name end |
#custom ⇒ Object (readonly)
Returns the value of attribute custom.
33 34 35 |
# File 'lib/relationship_definition.rb', line 33 def custom @custom end |
#foreign_key ⇒ Object (readonly)
Returns the value of attribute foreign_key.
33 34 35 |
# File 'lib/relationship_definition.rb', line 33 def foreign_key @foreign_key end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
33 34 35 |
# File 'lib/relationship_definition.rb', line 33 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
33 34 35 |
# File 'lib/relationship_definition.rb', line 33 def name @name end |
#one_to_many ⇒ Object (readonly)
Returns the value of attribute one_to_many.
33 34 35 |
# File 'lib/relationship_definition.rb', line 33 def one_to_many @one_to_many end |
#reference_to ⇒ Object (readonly)
Returns the value of attribute reference_to.
33 34 35 |
# File 'lib/relationship_definition.rb', line 33 def reference_to @reference_to end |