Class: ECMBlockchain::AssetModel

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/ecm-blockchain-api/models/asset_model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ AssetModel

Returns a new instance of AssetModel.



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 32

def initialize(data={})
  @uuid = data.fetch(:uuid) { nil }
  @txId = data.fetch(:txId) { nil }
  @groupId = data.fetch(:groupId) { nil }
  @title = data.fetch(:title) { nil }
  @summary = data.fetch(:summary) { nil }
  @createdBy = data.fetch(:createdBy) { nil }
  @owner = data.fetch(:owner) { nil }
  @file = ECMBlockchain::DataFile.new(data.fetch(:file) { })
  @content = ECMBlockchain::DataContent.new(data.fetch(:content) { })
end

Instance Attribute Details

#accessObject

Returns the value of attribute access.



8
9
10
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 8

def access
  @access
end

#contentObject

Returns the value of attribute content.



8
9
10
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 8

def content
  @content
end

#created_atObject

Returns the value of attribute created_at.



8
9
10
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 8

def created_at
  @created_at
end

#createdByObject

Returns the value of attribute createdBy.



8
9
10
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 8

def createdBy
  @createdBy
end

#eventsObject

Returns the value of attribute events.



8
9
10
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 8

def events
  @events
end

#fileObject

Returns the value of attribute file.



8
9
10
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 8

def file
  @file
end

#groupIdObject

Returns the value of attribute groupId.



8
9
10
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 8

def groupId
  @groupId
end

#lastInteractionObject

Returns the value of attribute lastInteraction.



8
9
10
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 8

def lastInteraction
  @lastInteraction
end

#ownerObject

Returns the value of attribute owner.



8
9
10
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 8

def owner
  @owner
end

#summaryObject

Returns the value of attribute summary.



8
9
10
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 8

def summary
  @summary
end

#titleObject

Returns the value of attribute title.



8
9
10
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 8

def title
  @title
end

#txIdObject

Returns the value of attribute txId.



8
9
10
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 8

def txId
  @txId
end

#uuidObject

Returns the value of attribute uuid.



8
9
10
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 8

def uuid
  @uuid
end

Class Method Details

.verify(data = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 15

def verify(data={})
  asset = self.new(data)
  raise ECMBlockchain::Error.raise_error(
    OpenStruct.new(
      code: 422, 
      body: { 
        error: { 
          message: asset.errors.full_messages.first,
          details: ''
        }
      }.to_json 
    )
  ) unless asset.valid?
  asset
end

Instance Method Details

#errorObject



48
49
50
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 48

def error
  nil
end

#success?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/ecm-blockchain-api/models/asset_model.rb', line 44

def success?
  true
end