Class: DataMetaPii::RegKeyVo

Inherits:
Object
  • Object
show all
Defined in:
lib/dataMetaPii.rb

Overview

PII Registry Key Value Object, encapsulates the PII Registry Key with attributes

Constant Summary collapse

LEVEL =

The map key for the level

'level'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, attrs) ⇒ RegKeyVo

Creates an instance for the given parameters, see the properties with the same names.

Raises:

  • (ArgumentError)


135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/dataMetaPii.rb', line 135

def initialize(key, attrs)
    @key, @attrs = key, attrs
    # single the level out:
    levelSpec = attrs[LEVEL]

    raise ArgumentError, %<Impact level missing or empty in #{@attrs.inspect}> unless levelSpec && !levelSpec.empty?

    @level = levelSpec.to_sym

    raise ArgumentError, %<Unsupported Impact Level #{@attrs.inspect}. Supported levels are: #{
        ALL_IMPACTS.map(&:to_s).join(', ')}> unless ALL_IMPACTS.member?(@level)

    raise ArgumentError, %<Invalid PII key: "#{@key}"> unless @key =~ /^\w+$/
end

Instance Attribute Details

#attrsObject

Returns the value of attribute attrs.



131
132
133
# File 'lib/dataMetaPii.rb', line 131

def attrs
  @attrs
end

#keyString

Returns unique key for the given enum.

Returns:

  • (String)

    unique key for the given enum



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/dataMetaPii.rb', line 127

class RegKeyVo
# The map key for the level
    LEVEL = 'level'

    attr_accessor :key, :level, :attrs
Creates an instance for the given parameters, see the properties with the same names.

    def initialize(key, attrs)
        @key, @attrs = key, attrs
        # single the level out:
        levelSpec = attrs[LEVEL]

        raise ArgumentError, %<Impact level missing or empty in #{@attrs.inspect}> unless levelSpec && !levelSpec.empty?

        @level = levelSpec.to_sym

        raise ArgumentError, %<Unsupported Impact Level #{@attrs.inspect}. Supported levels are: #{
            ALL_IMPACTS.map(&:to_s).join(', ')}> unless ALL_IMPACTS.member?(@level)

        raise ArgumentError, %<Invalid PII key: "#{@key}"> unless @key =~ /^\w+$/
    end

# textual representation of this instance
    def to_s; "#{key}(#{@level})" end

# Builds a textual tree image for logging and/or console output
    def to_tree_image(indent = '')
        next_ident = indent + DataMetaPii::INDENT
        %<#{indent}#{@key}:
#{next_ident}#{@attrs.keys.map{|k| "#{k}=#{@attrs[k]}"}.join("\n#{next_ident}")}>
    end
end

#levelSymbol

Returns the impact level.

Returns:

  • (Symbol)

    the impact level



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/dataMetaPii.rb', line 127

class RegKeyVo
# The map key for the level
    LEVEL = 'level'

    attr_accessor :key, :level, :attrs
Creates an instance for the given parameters, see the properties with the same names.

    def initialize(key, attrs)
        @key, @attrs = key, attrs
        # single the level out:
        levelSpec = attrs[LEVEL]

        raise ArgumentError, %<Impact level missing or empty in #{@attrs.inspect}> unless levelSpec && !levelSpec.empty?

        @level = levelSpec.to_sym

        raise ArgumentError, %<Unsupported Impact Level #{@attrs.inspect}. Supported levels are: #{
            ALL_IMPACTS.map(&:to_s).join(', ')}> unless ALL_IMPACTS.member?(@level)

        raise ArgumentError, %<Invalid PII key: "#{@key}"> unless @key =~ /^\w+$/
    end

# textual representation of this instance
    def to_s; "#{key}(#{@level})" end

# Builds a textual tree image for logging and/or console output
    def to_tree_image(indent = '')
        next_ident = indent + DataMetaPii::INDENT
        %<#{indent}#{@key}:
#{next_ident}#{@attrs.keys.map{|k| "#{k}=#{@attrs[k]}"}.join("\n#{next_ident}")}>
    end
end

Instance Method Details

#to_sObject

textual representation of this instance



151
# File 'lib/dataMetaPii.rb', line 151

def to_s; "#{key}(#{@level})" end

#to_tree_image(indent = '') ⇒ Object

Builds a textual tree image for logging and/or console output



154
155
156
157
158
# File 'lib/dataMetaPii.rb', line 154

def to_tree_image(indent = '')
    next_ident = indent + DataMetaPii::INDENT
    %<#{indent}#{@key}:
#{next_ident}#{@attrs.keys.map{|k| "#{k}=#{@attrs[k]}"}.join("\n#{next_ident}")}>
end