Module: Aperitiiif::Records
- Included in:
- Batch
- Defined in:
- lib/aperitiiif/batch/records.rb
Overview
TO DO COMMENT
Instance Method Summary collapse
- #find_record(item_id, records = self.records) ⇒ Object
- #load_records! ⇒ Object
- #records ⇒ Object
- #records_file_configured?(file = config.records_file) ⇒ Boolean
- #records_file_exists?(file = config.records_file) ⇒ Boolean
-
#records_from_file(file = config.records_file, defaults = config.records_defaults) ⇒ Object
has smell :reek:DuplicateMethodCall.
Instance Method Details
#find_record(item_id, records = self.records) ⇒ Object
11 12 13 |
# File 'lib/aperitiiif/batch/records.rb', line 11 def find_record(item_id, records = self.records) records.find { |record| record.id == item_id } end |
#load_records! ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/aperitiiif/batch/records.rb', line 37 def load_records! self.items = items.map do |item| record = find_record(item.id, records) item.record = record if record.present? item end end |
#records ⇒ Object
7 8 9 |
# File 'lib/aperitiiif/batch/records.rb', line 7 def records @records ||= records_from_file end |
#records_file_configured?(file = config.records_file) ⇒ Boolean
23 24 25 26 27 28 |
# File 'lib/aperitiiif/batch/records.rb', line 23 def records_file_configured?(file = config.records_file) return true if file.present? warn 'WARNING:: No records file configured'.colorize(:yellow) false end |
#records_file_exists?(file = config.records_file) ⇒ Boolean
30 31 32 33 34 35 |
# File 'lib/aperitiiif/batch/records.rb', line 30 def records_file_exists?(file = config.records_file) return true if File.file?(file) warn "WARNING:: Couldn't find records file #{file}".colorize(:yellow) false end |
#records_from_file(file = config.records_file, defaults = config.records_defaults) ⇒ Object
has smell :reek:DuplicateMethodCall
16 17 18 19 20 21 |
# File 'lib/aperitiiif/batch/records.rb', line 16 def records_from_file(file = config.records_file, defaults = config.records_defaults) return [] unless records_file_configured? file return [] unless records_file_exists? file Utils.csv_records file, defaults end |