Class: Importer::ImportedObject::Simple

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

Overview

Simple imported object details. It’s not stored in database (as with ActiveRecord imported object).

Attributes:

  • data - object’s detected attributes hash

  • validation_errors - object’s validation errors hash

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Simple

Returns a new instance of Simple.

Raises:

  • (ArgumentError)


13
14
15
16
# File 'lib/importer/imported_object/simple.rb', line 13

def initialize(attributes = {})
  raise ArgumentError.new(":import attribute is required.") unless attributes[:import]
  @import = attributes[:import]
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



11
12
13
# File 'lib/importer/imported_object/simple.rb', line 11

def data
  @data
end

#importObject (readonly)

Returns the value of attribute import.



10
11
12
# File 'lib/importer/imported_object/simple.rb', line 10

def import
  @import
end

#objectObject

Returns the value of attribute object.



11
12
13
# File 'lib/importer/imported_object/simple.rb', line 11

def object
  @object
end

#stateObject

Returns the value of attribute state.



11
12
13
# File 'lib/importer/imported_object/simple.rb', line 11

def state
  @state
end

#validation_errorsObject

Returns the value of attribute validation_errors.



11
12
13
# File 'lib/importer/imported_object/simple.rb', line 11

def validation_errors
  @validation_errors
end

Instance Method Details

#saveObject Also known as: save!



18
19
20
# File 'lib/importer/imported_object/simple.rb', line 18

def save
  import.add_object(self)
end