Class: ActiveSalesforce::EntityDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/entity_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, name, asf_class, columns, relationships, custom, key_prefix) ⇒ EntityDefinition

Returns a new instance of EntityDefinition.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/active_record/connection_adapters/entity_definition.rb', line 25

def initialize(connection, name, asf_class, columns, relationships, custom, key_prefix)
  @connection = connection
  @name = name
  @asf_class = asf_class
  @columns = columns
  @relationships = relationships
  @custom = custom
  @key_prefix = key_prefix
  
  @column_name_to_column = {}          
  @columns.each { |column| @column_name_to_column[column.name] = column }
  
  @api_name_to_column = {}
  @columns.each { |column| @api_name_to_column[column.api_name] = column }
end

Instance Attribute Details

#api_name_to_columnObject (readonly)

Returns the value of attribute api_name_to_column.



23
24
25
# File 'lib/active_record/connection_adapters/entity_definition.rb', line 23

def api_name_to_column
  @api_name_to_column
end

#asf_classObject (readonly)

Returns the value of attribute asf_class.



23
24
25
# File 'lib/active_record/connection_adapters/entity_definition.rb', line 23

def asf_class
  @asf_class
end

#column_name_to_columnObject (readonly)

Returns the value of attribute column_name_to_column.



23
24
25
# File 'lib/active_record/connection_adapters/entity_definition.rb', line 23

def column_name_to_column
  @column_name_to_column
end

#columnsObject (readonly)

Returns the value of attribute columns.



23
24
25
# File 'lib/active_record/connection_adapters/entity_definition.rb', line 23

def columns
  @columns
end

#key_prefixObject (readonly)

Returns the value of attribute key_prefix.



23
24
25
# File 'lib/active_record/connection_adapters/entity_definition.rb', line 23

def key_prefix
  @key_prefix
end

#nameObject (readonly)

Returns the value of attribute name.



23
24
25
# File 'lib/active_record/connection_adapters/entity_definition.rb', line 23

def name
  @name
end

#relationshipsObject (readonly)

Returns the value of attribute relationships.



23
24
25
# File 'lib/active_record/connection_adapters/entity_definition.rb', line 23

def relationships
  @relationships
end

Instance Method Details

#api_nameObject



45
46
47
# File 'lib/active_record/connection_adapters/entity_definition.rb', line 45

def api_name
  @custom ? name + "__c" : name
end

#custom?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/active_record/connection_adapters/entity_definition.rb', line 41

def custom?
  @custom
end

#layoutsObject



49
50
51
52
53
54
55
# File 'lib/active_record/connection_adapters/entity_definition.rb', line 49

def layouts
  return @layouts if @layouts
  
  # Lazy load Layout information
  response = @connection.binding.describeLayout(:sObjectType => api_name)
  @layouts = @connection.get_result(response, :describeLayout)
end