Sha256: a68b2d31eef7f6b600bc487d1e288fb5baafb871c3208dcf564815d4a353b55e
Contents?: true
Size: 1022 Bytes
Versions: 3
Compression:
Stored size: 1022 Bytes
Contents
require 'active_support/hash_with_indifferent_access' module DirModel module Export class AggregateDir include Utils attr_reader :export_dir_model_class, :context, :dir_path # @param [Export] export_model export model class def initialize(export_dir_model_class, context={}) @export_dir_model_class = export_dir_model_class @context = context.to_h.symbolize_keys @dir_path = Dir.mktmpdir end # 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 def append_model(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 alias_method :<<, :append_model def generate yield self self end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dir_model-0.3.1 | lib/dir_model/export/aggregate_dir.rb |
dir_model-0.3.0 | lib/dir_model/export/aggregate_dir.rb |
dir_model-0.2.0 | lib/dir_model/export/aggregate_dir.rb |