Class: SfCli::Sf::Model::Generator
- Inherits:
-
Object
- Object
- SfCli::Sf::Model::Generator
- Defined in:
- lib/sf_cli/sf/model/generator.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#sf_sobject ⇒ Object
readonly
Returns the value of attribute sf_sobject.
Instance Method Summary collapse
- #describe(object_name) ⇒ Object
- #generate(object_name) ⇒ Object
-
#initialize(connection) ⇒ Generator
constructor
A new instance of Generator.
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
#connection ⇒ Object (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_sobject ⇒ Object (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 |