Class: ECMBlockchain::DataFile
- Inherits:
-
Object
- Object
- ECMBlockchain::DataFile
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/ecm-blockchain-api/models/data_file_model.rb
Instance Attribute Summary collapse
-
#base64 ⇒ Object
Returns the value of attribute base64.
-
#digitalSignature ⇒ Object
Returns the value of attribute digitalSignature.
-
#fileHash ⇒ Object
readonly
Returns the value of attribute fileHash.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#storage ⇒ Object
Returns the value of attribute storage.
Class Method Summary collapse
Instance Method Summary collapse
- #added? ⇒ Boolean
-
#initialize(data = {}) ⇒ DataFile
constructor
A new instance of DataFile.
Constructor Details
#initialize(data = {}) ⇒ DataFile
Returns a new instance of DataFile.
30 31 32 33 34 35 36 37 38 |
# File 'lib/ecm-blockchain-api/models/data_file_model.rb', line 30 def initialize(data={}) data ||= {} @identifier = data[:identifier] @base64 = data[:base64] @storage = data[:storage] @fileHash = data[:fileHash] @href = data[:href] @digitalSignature = ECMBlockchain::DigitalSignature.new(data.fetch(:digitalSignature) {}) end |
Instance Attribute Details
#base64 ⇒ Object
Returns the value of attribute base64.
7 8 9 |
# File 'lib/ecm-blockchain-api/models/data_file_model.rb', line 7 def base64 @base64 end |
#digitalSignature ⇒ Object
Returns the value of attribute digitalSignature.
7 8 9 |
# File 'lib/ecm-blockchain-api/models/data_file_model.rb', line 7 def digitalSignature @digitalSignature end |
#fileHash ⇒ Object (readonly)
Returns the value of attribute fileHash.
8 9 10 |
# File 'lib/ecm-blockchain-api/models/data_file_model.rb', line 8 def fileHash @fileHash end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
8 9 10 |
# File 'lib/ecm-blockchain-api/models/data_file_model.rb', line 8 def href @href end |
#identifier ⇒ Object
Returns the value of attribute identifier.
7 8 9 |
# File 'lib/ecm-blockchain-api/models/data_file_model.rb', line 7 def identifier @identifier end |
#storage ⇒ Object
Returns the value of attribute storage.
7 8 9 |
# File 'lib/ecm-blockchain-api/models/data_file_model.rb', line 7 def storage @storage end |
Class Method Details
.verify(data = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ecm-blockchain-api/models/data_file_model.rb', line 13 def verify(data={}) file = self.new(data) raise ECMBlockchain::Error.raise_error( OpenStruct.new( code: 422, body: { error: { message: file.errors..first, details: '' } }.to_json ) ) unless file.valid? file end |
Instance Method Details
#added? ⇒ Boolean
40 41 42 |
# File 'lib/ecm-blockchain-api/models/data_file_model.rb', line 40 def added? self.valid? end |