Module: Csvbuilder::Import::Attributes

Extended by:
ActiveSupport::Concern
Includes:
AttributesBase
Included in:
Csvbuilder::Import
Defined in:
lib/csvbuilder/importer/concerns/import/attributes.rb

Instance Method Summary collapse

Instance Method Details

#attribute_objectsObject



28
29
30
# File 'lib/csvbuilder/importer/concerns/import/attributes.rb', line 28

def attribute_objects
  @attribute_objects ||= _attribute_objects
end

#read_attribute_for_validation(attr) ⇒ Object



32
33
34
# File 'lib/csvbuilder/importer/concerns/import/attributes.rb', line 32

def read_attribute_for_validation(attr)
  source_row[self.class.column_names.index(attr)]
end

#valid?(*args) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
# File 'lib/csvbuilder/importer/concerns/import/attributes.rb', line 17

def valid?(*args)
  is_valid = super

  # The method attribute_objects was called by the valid? method through
  # the attribute getters. The memoization must be cleared now to propagate
  # the errors into the Attribute(s).
  instance_variable_set(:@attribute_objects, nil) unless is_valid

  is_valid
end