Module: CsvRowModel::Model::Base

Extended by:
ActiveSupport::Concern
Included in:
CsvRowModel::Model
Defined in:
lib/csv_row_model/model/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#initialized_atDateTime (readonly)

Return when self has been intialized

Returns:

  • return when self has been intialized



11
12
13
# File 'lib/csv_row_model/model/base.rb', line 11

def initialized_at
  @initialized_at
end

#parentModel (readonly)

Return the parent, if this instance is a child

Returns:

  • return the parent, if this instance is a child



8
9
10
# File 'lib/csv_row_model/model/base.rb', line 8

def parent
  @parent
end

Class Method Details

.csv_string_model(&block) ⇒ Object (protected)

Called to add validations to the csv_string_model_class



46
47
48
# File 'lib/csv_row_model/model/base.rb', line 46

def csv_string_model(&block)
  csv_string_model_class.class_eval(&block)
end

.csv_string_model_classClass

Returns the Class with validations of the csv_string_model.

Returns:

  • the Class with validations of the csv_string_model



40
41
42
# File 'lib/csv_row_model/model/base.rb', line 40

def csv_string_model_class
  @csv_string_model_class ||= inherited_custom_class(:csv_string_model_class, CsvStringModel)
end

Instance Method Details

#abort?Boolean

Safe to override.

Returns:

  • returns true, if the entire csv file should stop reading



34
35
36
# File 'lib/csv_row_model/model/base.rb', line 34

def abort?
  false
end

#initialize(source = nil, options = {}) ⇒ Object

Parameters:

  • (defaults to: nil)

    not used here, see Input

  • (defaults to: {})

Options Hash (options):

  • :parent (String)

    if the instance is a child, pass the parent



19
20
21
22
# File 'lib/csv_row_model/model/base.rb', line 19

def initialize(source=nil, options={})
  @initialized_at = DateTime.now
  @parent = options[:parent]
end

#skip?Boolean

Safe to override.

Returns:

  • returns true, if this instance should be skipped



27
28
29
# File 'lib/csv_row_model/model/base.rb', line 27

def skip?
  !valid?
end