Class: ActiveRecord::ConnectionAdapters::SalesforceColumn

Inherits:
Column
  • Object
show all
Includes:
StringHelper
Defined in:
lib/active_record/connection_adapters/column_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StringHelper

#column_nameize

Constructor Details

#initialize(field) ⇒ SalesforceColumn

Returns a new instance of SalesforceColumn.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/active_record/connection_adapters/column_definition.rb', line 35

def initialize(field)
  @api_name = field[:name]
  @custom = field[:custom] == "true"
  @name = column_nameize(@api_name)
  @type = get_type(field[:type])
  @limit = field[:length]
  @label = field[:label]
  @name_field = field[:nameField] == "true"
  
  @text = [:string, :text].include? @type
  @number = [:float, :integer].include? @type
  
  @createable = field[:createable] == "true"
  @updateable = field[:updateable] == "true"
  
  if field[:type] =~ /reference/i
    @reference_to = field[:referenceTo]
    @one_to_many = false
    @cascade_delete = false
    
    @name = @name.chop.chop << "id__c" if @custom
  end
end

Instance Attribute Details

#api_nameObject (readonly)

Returns the value of attribute api_name.



33
34
35
# File 'lib/active_record/connection_adapters/column_definition.rb', line 33

def api_name
  @api_name
end

#createableObject (readonly)

Returns the value of attribute createable.



33
34
35
# File 'lib/active_record/connection_adapters/column_definition.rb', line 33

def createable
  @createable
end

#customObject (readonly)

Returns the value of attribute custom.



33
34
35
# File 'lib/active_record/connection_adapters/column_definition.rb', line 33

def custom
  @custom
end

#labelObject (readonly)

Returns the value of attribute label.



33
34
35
# File 'lib/active_record/connection_adapters/column_definition.rb', line 33

def label
  @label
end

#reference_toObject (readonly)

Returns the value of attribute reference_to.



33
34
35
# File 'lib/active_record/connection_adapters/column_definition.rb', line 33

def reference_to
  @reference_to
end

#updateableObject (readonly)

Returns the value of attribute updateable.



33
34
35
# File 'lib/active_record/connection_adapters/column_definition.rb', line 33

def updateable
  @updateable
end

Instance Method Details

#get_type(field_type) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/active_record/connection_adapters/column_definition.rb', line 63

def get_type(field_type)
    case field_type
      when /int/i
        :integer
      when /currency|percent/i
        :float
      when /datetime/i
        :datetime
      when /date/i
        :date
      when /id|string|textarea/i
        :text
      when /phone|fax|email|url/i
        :string
      when /blob|binary/i
        :binary
      when /boolean/i
        :boolean
      when /picklist/i
        :text
      when /reference/i
        :text
    end
end

#human_nameObject



88
89
90
# File 'lib/active_record/connection_adapters/column_definition.rb', line 88

def human_name
  @label
end

#is_name?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/active_record/connection_adapters/column_definition.rb', line 59

def is_name?
  @name_field
end