Class: CSVStepImporter::Model::DAO
- Inherits:
-
Node
- Object
- Base
- Node
- CSVStepImporter::Model::DAO
show all
- Defined in:
- lib/csv_step_importer/model/dao.rb
Instance Attribute Summary collapse
Attributes inherited from Node
#children, #env, #parent
Instance Method Summary
collapse
Methods inherited from Node
#add_children, #validate_children
Methods inherited from Base
#assign_attributes, #inspect, #persisted?, #save, #save!, #to_s, #update
Constructor Details
#initialize(row:, **attributes) ⇒ DAO
Returns a new instance of DAO.
12
13
14
15
16
|
# File 'lib/csv_step_importer/model/dao.rb', line 12
def initialize(row:, **attributes)
super **attributes
self.row = row
end
|
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
6
7
8
|
# File 'lib/csv_step_importer/model/dao.rb', line 6
def id
@id
end
|
#row ⇒ Object
Returns the value of attribute row.
6
7
8
|
# File 'lib/csv_step_importer/model/dao.rb', line 6
def row
@row
end
|
Instance Method Details
#create_or_update ⇒ Object
28
29
30
31
|
# File 'lib/csv_step_importer/model/dao.rb', line 28
def create_or_update
true
end
|
#created_at ⇒ Object
37
38
39
|
# File 'lib/csv_step_importer/model/dao.rb', line 37
def created_at
current_timestamp
end
|
#current_timestamp ⇒ Object
33
34
35
|
# File 'lib/csv_step_importer/model/dao.rb', line 33
def current_timestamp
model.cache[:updated_at] ||= (::ActiveRecord::Base.default_timezone == :utc ? ::Time.now.utc : ::Time.now).to_s(:db)
end
|
#model ⇒ Object
18
19
20
|
# File 'lib/csv_step_importer/model/dao.rb', line 18
def model
parent.parent
end
|
#updated_at ⇒ Object
41
42
43
|
# File 'lib/csv_step_importer/model/dao.rb', line 41
def updated_at
current_timestamp
end
|
#value ⇒ Object
22
23
24
25
26
|
# File 'lib/csv_step_importer/model/dao.rb', line 22
def value
@value ||= columns.each_with_object({}) do |key, values|
values[key] = send key
end
end
|