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.
-
#export_dir_model_class ⇒ Object
readonly
Returns the value of attribute export_dir_model_class.
Instance Method Summary collapse
-
#append_model(source_model, context = {}) ⇒ Object
(also: #<<)
Add a row_model to the.
- #files ⇒ Object
- #generate {|_self| ... } ⇒ Object
-
#initialize(export_dir_model_class, context = {}) ⇒ AggregateDir
constructor
A new instance of AggregateDir.
Methods included from Utils
Constructor Details
#initialize(export_dir_model_class, context = {}) ⇒ AggregateDir
11 12 13 14 15 |
# File 'lib/dir_model/export/aggregate_dir.rb', line 11 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 |
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 |
#export_dir_model_class ⇒ Object (readonly)
Returns the value of attribute export_dir_model_class.
8 9 10 |
# File 'lib/dir_model/export/aggregate_dir.rb', line 8 def export_dir_model_class @export_dir_model_class end |
Instance Method Details
#append_model(source_model, context = {}) ⇒ Object Also known as: <<
Add a row_model to the
20 21 22 23 |
# File 'lib/dir_model/export/aggregate_dir.rb', line 20 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 |
#files ⇒ Object
31 32 33 |
# File 'lib/dir_model/export/aggregate_dir.rb', line 31 def files Dir["#{@dir_path}/**/*"].select { |f| File.file?(f) } end |
#generate {|_self| ... } ⇒ Object
26 27 28 29 |
# File 'lib/dir_model/export/aggregate_dir.rb', line 26 def generate yield self self end |