Class: Accession::Submission::Payload

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/accession/accession/submission.rb

Overview

Accessioning requires a submission and sample file Payload consists of a hash of relevant files These files can be opened when the request is sent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(accessionables) ⇒ Payload

Returns a new instance of Payload


76
77
78
79
80
81
82
# File 'lib/accession/accession/submission.rb', line 76

def initialize(accessionables)
  @files = {}.tap do |f|
    accessionables.each do |accessionable|
      f[accessionable.schema_type.upcase] = accessionable.to_file
    end
  end
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files


74
75
76
# File 'lib/accession/accession/submission.rb', line 74

def files
  @files
end

Instance Method Details

#close!Object


92
93
94
95
96
# File 'lib/accession/accession/submission.rb', line 92

def close!
  files.values.each do |file|
    file.close!
  end
end

#each(&block) ⇒ Object


84
85
86
# File 'lib/accession/accession/submission.rb', line 84

def each(&block)
  files.each(&block)
end

#openObject


88
89
90
# File 'lib/accession/accession/submission.rb', line 88

def open
  Hash[files.collect { |k, v| [k, v.open] }]
end