Class: Kriterion::Item

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#find_section, #flush_compliance!, #full_keys, #primary_key, #to_h

Constructor Details

#initialize(data) ⇒ Item

Returns a new instance of Item.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/kriterion/item.rb', line 15

def initialize(data)
  super(data)

  @uuid         = data['uuid'] || SecureRandom.uuid
  @id           = data['id']
  @title        = data['title']
  @description  = data['description']
  @severity     = data['severity']
  @section_path = data['section_path']
  @parent_type  = data['parent_type']
  @parent_uuid  = data['parent_uuid']
  @resources    = data['resources'] || []
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



8
9
10
# File 'lib/kriterion/item.rb', line 8

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/kriterion/item.rb', line 6

def id
  @id
end

#parent_uuidObject (readonly)

Returns the value of attribute parent_uuid.



10
11
12
# File 'lib/kriterion/item.rb', line 10

def parent_uuid
  @parent_uuid
end

#resourcesObject

Returns the value of attribute resources.



13
14
15
# File 'lib/kriterion/item.rb', line 13

def resources
  @resources
end

#section_pathObject (readonly)

Returns the value of attribute section_path.



11
12
13
# File 'lib/kriterion/item.rb', line 11

def section_path
  @section_path
end

#severityObject (readonly)

Returns the value of attribute severity.



9
10
11
# File 'lib/kriterion/item.rb', line 9

def severity
  @severity
end

#titleObject (readonly)

Returns the value of attribute title.



7
8
9
# File 'lib/kriterion/item.rb', line 7

def title
  @title
end

#uuidObject (readonly)

Returns the value of attribute uuid.



5
6
7
# File 'lib/kriterion/item.rb', line 5

def uuid
  @uuid
end

Class Method Details

.primary_keyObject



52
53
54
# File 'lib/kriterion/item.rb', line 52

def self.primary_key
  :id
end

Instance Method Details

#complianceObject



29
30
31
# File 'lib/kriterion/item.rb', line 29

def compliance
  super(resources)
end

#expandable?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/kriterion/item.rb', line 44

def expandable?
  true
end

#expandable_keysObject



48
49
50
# File 'lib/kriterion/item.rb', line 48

def expandable_keys
  [:resources]
end

#parent_names(separator) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/kriterion/item.rb', line 33

def parent_names(separator)
  parents = []

  section_path.each_index do |index|
    parents << section_path[0..index].join(separator)
  end

  parents.delete(id)
  parents.reverse
end