Class: Smuggle::Services::Export
- Inherits:
-
Object
- Object
- Smuggle::Services::Export
- Defined in:
- lib/smuggle/services/export.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(scope:, **options) ⇒ Object
-
#initialize(resolver: Smuggle::Exporter::Resolver.new) ⇒ Export
constructor
A new instance of Export.
Constructor Details
Class Method Details
.call(**args) ⇒ Object
6 7 8 |
# File 'lib/smuggle/services/export.rb', line 6 def self.call(**args) new.call(args) end |
Instance Method Details
#call(scope:, **options) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/smuggle/services/export.rb', line 14 def call(scope:, **) exporter = .fetch(:exporter) { @resolver.call(scope: scope) } CSV.generate do |csv| csv << exporter.header method = :each method = :find_each if scope.respond_to?(:find_each) scope.public_send(method) do |record| csv << exporter.new(record).to_csv end end end |