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.



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

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.



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

def access
  @access
end

#contentObject

Returns the value of attribute content.



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

def content
  @content
end

#created_atObject

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#createdByObject

Returns the value of attribute createdBy.



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

def createdBy
  @createdBy
end

#eventsObject

Returns the value of attribute events.



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

def events
  @events
end

#fileObject

Returns the value of attribute file.



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

def file
  @file
end

#groupIdObject

Returns the value of attribute groupId.



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

def groupId
  @groupId
end

#lastInteractionObject

Returns the value of attribute lastInteraction.



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

def lastInteraction
  @lastInteraction
end

#ownerObject

Returns the value of attribute owner.



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

def owner
  @owner
end

#summaryObject

Returns the value of attribute summary.



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

def summary
  @summary
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#txIdObject

Returns the value of attribute txId.



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

def txId
  @txId
end

#uuidObject

Returns the value of attribute uuid.



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

def uuid
  @uuid
end

Class Method Details

.verify(data = {}) ⇒ Object



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

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



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

def error
  nil
end

#success?Boolean

Returns:

  • (Boolean)


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

def success?
  true
end