Sha256: 7bc884dd8e511cf85e5f5148365a57dda3fdabd047132948ea1e0986f6bb8267

Contents?: true

Size: 1.73 KB

Versions: 21

Compression:

Stored size: 1.73 KB

Contents

=begin
  ActiveSalesforce
  Copyright 2006 Doug Chasman
 
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
 
     http://www.apache.org/licenses/LICENSE-2.0
 
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
=end

require 'rubygems'
require_gem 'rails', ">= 1.0.0"

require 'pp'


module ActiveSalesforce  
  class EntityDefinition
    attr_reader :name, :asf_class, :columns, :column_name_to_column, :api_name_to_column, :relationships, :key_prefix
    
    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
    
    def custom?
      @custom
    end
    
    def api_name
      @custom ? name + "__c" : name
    end
    
    def layouts
      return @layouts if @layouts
      
      # Lazy load Layout information
      response = @connection.binding.describeLayout(:sObjectType => api_name)
      @layouts = @connection.get_result(response, :describeLayout)
    end
    
  end
  
end    

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
activesalesforce-0.4.5 lib/entity_definition.rb
activesalesforce-0.4.6 lib/entity_definition.rb
activesalesforce-0.4.7 lib/entity_definition.rb
activesalesforce-0.4.8 lib/entity_definition.rb
activesalesforce-0.4.9 lib/entity_definition.rb
activesalesforce-0.5.0 lib/entity_definition.rb
activesalesforce-0.5.1 lib/entity_definition.rb
activesalesforce-0.5.2 lib/entity_definition.rb
activesalesforce-0.5.3 lib/entity_definition.rb
activesalesforce-0.5.4 lib/entity_definition.rb
activesalesforce-0.5.5 lib/entity_definition.rb
activesalesforce-0.5.6 lib/entity_definition.rb
activesalesforce-0.5.7 lib/entity_definition.rb
activesalesforce-0.5.8 lib/entity_definition.rb
activesalesforce-0.5.9 lib/entity_definition.rb
activesalesforce-0.6.0 lib/entity_definition.rb
activesalesforce-0.6.1 lib/entity_definition.rb
activesalesforce-0.6.2 lib/entity_definition.rb
activesalesforce-0.6.3 lib/entity_definition.rb
activesalesforce-1.0.0 lib/entity_definition.rb