Class: SfCli::Sf::Model::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/sf_cli/sf/model/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Generator

Returns a new instance of Generator.



9
10
11
# File 'lib/sf_cli/sf/model/generator.rb', line 9

def initialize(connection)
  @connection = connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



7
8
9
# File 'lib/sf_cli/sf/model/generator.rb', line 7

def connection
  @connection
end

#sf_sobjectObject (readonly)

Returns the value of attribute sf_sobject.



7
8
9
# File 'lib/sf_cli/sf/model/generator.rb', line 7

def sf_sobject
  @sf_sobject
end

Instance Method Details

#describe(object_name) ⇒ Object



22
23
24
# File 'lib/sf_cli/sf/model/generator.rb', line 22

def describe(object_name)
  connection.describe object_name
end

#generate(object_name) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/sf_cli/sf/model/generator.rb', line 13

def generate(object_name)
  schema = describe(object_name)
  class_definition = ClassDefinition.new(schema)

  instance_eval "::#{object_name} = #{class_definition}"
  klass = Object.const_get object_name.to_sym
  klass.connection = connection
end