Class: SObjectModel::Generator
- Inherits:
-
Object
- Object
- SObjectModel::Generator
- Defined in:
- lib/sobject_model/generator.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #connected? ⇒ Boolean
- #generate(*object_types) ⇒ Object
-
#initialize(connection) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(connection) ⇒ Generator
Returns a new instance of Generator.
8 9 10 |
# File 'lib/sobject_model/generator.rb', line 8 def initialize(connection) @connection = connection end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/sobject_model/generator.rb', line 6 def connection @connection end |
Instance Method Details
#connected? ⇒ Boolean
12 13 14 |
# File 'lib/sobject_model/generator.rb', line 12 def connected? connection.nil? == false end |
#generate(*object_types) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sobject_model/generator.rb', line 16 def generate(*object_types) generated_types = [] object_types.each do |object_type| next if generated? object_type schema = describe(object_type) class_definition = ClassDefinition.new(schema) instance_eval "::#{object_type} = #{class_definition}" klass = Object.const_get object_type.to_sym klass.connection = connection SObjectModel.generated_classes << klass generated_types << object_type end generated_types end |