Class: DirModel::Export::AggregateDir
- Inherits:
-
Object
- Object
- DirModel::Export::AggregateDir
- Includes:
- Utils
- Defined in:
- lib/dir_model/export/aggregate_dir.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#dir_path ⇒ Object
readonly
Returns the value of attribute dir_path.
Instance Method Summary collapse
-
#append_model(export_dir_model_class, source_model, context = {}) ⇒ Object
Add a row_model to the.
- #files ⇒ Object
- #generate {|_self| ... } ⇒ Object
-
#initialize(context = {}) ⇒ AggregateDir
constructor
A new instance of AggregateDir.
Methods included from Utils
Constructor Details
#initialize(context = {}) ⇒ AggregateDir
Returns a new instance of AggregateDir.
11 12 13 14 |
# File 'lib/dir_model/export/aggregate_dir.rb', line 11 def initialize(context={}) @context = context.to_h.symbolize_keys @dir_path = Dir.mktmpdir end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
8 9 10 |
# File 'lib/dir_model/export/aggregate_dir.rb', line 8 def context @context end |
#dir_path ⇒ Object (readonly)
Returns the value of attribute dir_path.
8 9 10 |
# File 'lib/dir_model/export/aggregate_dir.rb', line 8 def dir_path @dir_path end |
Instance Method Details
#append_model(export_dir_model_class, source_model, context = {}) ⇒ Object
Add a row_model to the
19 20 21 22 |
# 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 ⇒ Object
29 30 31 |
# File 'lib/dir_model/export/aggregate_dir.rb', line 29 def files Dir["#{@dir_path}/**/*"].select { |f| File.file?(f) } end |
#generate {|_self| ... } ⇒ Object
24 25 26 27 |
# File 'lib/dir_model/export/aggregate_dir.rb', line 24 def generate yield self self end |