Class: Importer::ImportedObject

Inherits:
Object
  • Object
show all
Defined in:
lib/importer/imported_object.rb

Overview

Instances of this class are created during import process and contain detailed information about imported objects.

Attributes:

  • state - an imported object can be in one of three states:

    • new_object - new object was detected and successfully imported

    • existing_object - already existing object was detected and successfully imported

    • invalid_object - detected object could not have been imported because of validation errors

  • object - pointer to actual object created or updated during import

  • data - detected object’s attributes hash

  • validation_errors - list of validation errors for invalid object

Instances of this class are built via Import’s build_imported_object method.

If you need you can implement your own version of ImportedObject class (f.e. activerecord-based). To use it you must also implement custom version of Import class that builds instances of CustomImportedObject with it’s build_imported_object method.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ImportedObject

Returns a new instance of ImportedObject.



25
26
27
28
29
30
# File 'lib/importer/imported_object.rb', line 25

def initialize(attributes = {})
  @state             = attributes[:state]
  @object            = attributes[:object]
  @data              = attributes[:data]
  @validation_errors = attributes[:validation_errors]
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



23
24
25
# File 'lib/importer/imported_object.rb', line 23

def data
  @data
end

#objectObject

Returns the value of attribute object.



23
24
25
# File 'lib/importer/imported_object.rb', line 23

def object
  @object
end

#stateObject

Returns the value of attribute state.



23
24
25
# File 'lib/importer/imported_object.rb', line 23

def state
  @state
end

#validation_errorsObject

Returns the value of attribute validation_errors.



23
24
25
# File 'lib/importer/imported_object.rb', line 23

def validation_errors
  @validation_errors
end