Skip to content

Commit

Permalink
Add CsvService and FileService, and ImportService/Title (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikukyugamer authored Jun 11, 2023
1 parent 411595f commit 2a0e6f2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/service/csv_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'csv'

class CsvService
attr_accessor :filepath, :csv_table

def initialize(filepath)
@filepath = filepath
@csv_table = CSV.read(filepath, headers: true)
end
end
5 changes: 5 additions & 0 deletions app/service/file_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class FileService
def initialize
# TODO: 書く
end
end
20 changes: 20 additions & 0 deletions app/service/import_service/title.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module ImportService
class Title
def execute
ActiveRecord::Base.transaction do
::Title.import(columns, values, validate: true)
end
end

def columns
[:name]
end

def values
[
['abc'],
['def'],
]
end
end
end

0 comments on commit 2a0e6f2

Please sign in to comment.