Class: ActiveRecord::Acts::Partitioned::CopyFile
- Inherits:
-
Object
- Object
- ActiveRecord::Acts::Partitioned::CopyFile
- Defined in:
- lib/active_record/acts/partitioned/copy_proxy.rb
Instance Method Summary collapse
- #<<(hash) ⇒ Object
- #close ⇒ Object
-
#initialize(table_name, options = {}) ⇒ CopyFile
constructor
A new instance of CopyFile.
Constructor Details
#initialize(table_name, options = {}) ⇒ CopyFile
Returns a new instance of CopyFile.
52 53 54 55 56 57 58 59 |
# File 'lib/active_record/acts/partitioned/copy_proxy.rb', line 52 def initialize(table_name, = {}) @table_name = table_name @options = @header_written = false @filename = generate_filename @file = File.open(::COPY_FILE_DIRECTORY + @filename, "w") #write_meta end |
Instance Method Details
#<<(hash) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/active_record/acts/partitioned/copy_proxy.rb', line 61 def <<(hash) unless @header_written write_header(hash.keys) end # TODO: Write values @file << hash.values.map { |v| quote_and_escape(v) }.join(',') << "\n" end |
#close ⇒ Object
69 70 71 |
# File 'lib/active_record/acts/partitioned/copy_proxy.rb', line 69 def close @file.close end |