Sha256: fa3421639728df44bb763f345829108d84c0b40b8a43c2a9e418deddb1234036

Contents?: true

Size: 861 Bytes

Versions: 10

Compression:

Stored size: 861 Bytes

Contents

class <%= file_path.camelize %>Parser
  include ::CSVImporter

  model <%= file_path.camelize %>

  # will update_or_create via :<%= options[:columns].first %>
  identifier :<%= options[:columns].first %>

  # Examples of columns declaration
  # column :<%= options[:columns].first %>, to: ->(<%= options[:columns].first %>) { <%= options[:columns].first %>.downcase }, required: true
  # column :<%= options[:columns].first %>, as: [ /first.?name/i, /pr(é|e)nom/i ]
  # column :<%= options[:columns].first %>,  as: [ /last.?name/i, "nom" ]
  # column :<%= options[:columns].first %>,  to: ->(<%= options[:columns].first %>, record) { record.<%= options[:columns].first %> = <%= options[:columns].first %> ?  'a' : 'b' }
<% options[:columns].map do |column| %>
  column :<%= column.to_sym %>, required: true
<% end %>
  # or :abort
  #  when_invalid :skip
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
csv_import_magic-0.0.11 lib/generators/active_record/templates/csv_parser.rb
csv_import_magic-0.0.10 lib/generators/active_record/templates/csv_parser.rb
csv_import_magic-0.0.8 lib/generators/active_record/templates/csv_parser.rb
csv_import_magic-0.0.7 lib/generators/active_record/templates/csv_parser.rb
csv_import_magic-0.0.6 lib/generators/active_record/templates/csv_parser.rb
csv_import_magic-0.0.5 lib/generators/active_record/templates/csv_parser.rb
csv_import_magic-0.0.4 lib/generators/active_record/templates/csv_parser.rb
csv_import_magic-0.0.3 lib/generators/active_record/templates/csv_parser.rb
csv_import_magic-0.0.2 lib/generators/active_record/templates/csv_parser.rb
csv_import_magic-0.0.1 lib/generators/active_record/templates/csv_parser.rb