class DirModel::Export::AggregateDir

Attributes

context[R]
dir_path[R]

Public Class Methods

new(context={}) click to toggle source

@param [Export] export_model export model class

# File lib/dir_model/export/aggregate_dir.rb, line 11
def initialize(context={})
  @context  = context.to_h.symbolize_keys
  @dir_path = Dir.mktmpdir
end

Public Instance Methods

append_model(export_dir_model_class, source_model, context={}) click to toggle source

Add a row_model to the @param [] source_model the source model of the export file model @param [Hash] context the extra context given to the instance of the file model

# File lib/dir_model/export/aggregate_dir.rb, line 19
def append_model(export_dir_model_class, source_model, context={})
  source_path = export_dir_model_class.new(source_model, context.reverse_merge(self.context)).path
  FileUtils.cp_r Dir.glob("#{source_path}/*"), dir_path
end
files() click to toggle source
# File lib/dir_model/export/aggregate_dir.rb, line 29
def files
  Dir["#{@dir_path}/**/*"].select { |f| File.file?(f) }
end
generate() { |self| ... } click to toggle source
# File lib/dir_model/export/aggregate_dir.rb, line 24
def generate
  yield self
  self
end