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.



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

def initialize(connection)
  @connection = connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



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

def connection
  @connection
end

Instance Method Details

#describe(object_name) ⇒ Object



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

def describe(object_name)
  connection.describe object_name
end

#generate(object_name) ⇒ Object



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

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