Class: ToFactory::FileSync

Inherits:
Object
  • Object
show all
Defined in:
lib/to_factory/file_sync.rb

Instance Method Summary collapse

Constructor Details

#initialize(m = ToFactory::Finders::Model.new, fw = ToFactory::FileWriter.new, ff = ToFactory::Finders::Factory.new) ⇒ FileSync

Returns a new instance of FileSync.



3
4
5
6
7
8
9
# File 'lib/to_factory/file_sync.rb', line 3

def initialize(m  = ToFactory::Finders::Model.new,
               fw = ToFactory::FileWriter.new,
               ff = ToFactory::Finders::Factory.new)
  @model_finder = wrap_model(m)
  @file_writer  = fw
  @factory_finder = ff
end

Instance Method Details

#all_representations(exclusions = []) ⇒ Object



15
16
17
18
19
# File 'lib/to_factory/file_sync.rb', line 15

def all_representations(exclusions=[])
  Collation.organize(
    new_representations(exclusions),
    existing_representations)
end

#new_representations(exclusions = []) ⇒ Object



21
22
23
24
25
# File 'lib/to_factory/file_sync.rb', line 21

def new_representations(exclusions=[])
  instances = @model_finder.call(exclusions)

  instances.map{|r| Representation.from(r) }
end

#perform(exclusions = []) ⇒ Object



11
12
13
# File 'lib/to_factory/file_sync.rb', line 11

def perform(exclusions=[])
  @file_writer.write(all_representations exclusions)
end