Class: ComplianceEngine::DataLoader

Inherits:
Object
  • Object
show all
Includes:
Observable
Defined in:
lib/compliance_engine/data_loader.rb

Overview

Load compliance engine data

Direct Known Subclasses

File

Defined Under Namespace

Classes: File, Json, Yaml

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value = {}, key: nil) ⇒ DataLoader

Initialize a new instance of the ComplianceEngine::DataLoader::File class

Parameters:

  • value (Hash) (defaults to: {})

    The data to initialize the object with

  • key (String) (defaults to: nil)

    The key to use for identifying the data



14
15
16
17
# File 'lib/compliance_engine/data_loader.rb', line 14

def initialize(value = {}, key: nil)
  self.data = value
  @key = key
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



19
20
21
# File 'lib/compliance_engine/data_loader.rb', line 19

def data
  @data
end

Instance Method Details

#keyString

Get the key for the data loader

The key is used to identify the data to observers. If a key is not provided during initialization, a random UUID will be generated.

Returns:

  • (String)

    The key for the data loader



39
40
41
42
43
44
# File 'lib/compliance_engine/data_loader.rb', line 39

def key
  return @key unless @key.nil?

  require 'securerandom'
  @key = "#{data.class}:#{SecureRandom.uuid}"
end