Class: Igniter::Extensions::Contracts::Audit::Snapshot

Inherits:
Object
  • Object
show all
Defined in:
lib/igniter/extensions/contracts/audit/snapshot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graph:, profile_fingerprint:, events:, states:, children:, output_names:) ⇒ Snapshot

Returns a new instance of Snapshot.



10
11
12
13
14
15
16
17
18
19
# File 'lib/igniter/extensions/contracts/audit/snapshot.rb', line 10

def initialize(graph:, profile_fingerprint:, events:, states:, children:, output_names:)
  @graph = graph.to_s
  @profile_fingerprint = profile_fingerprint
  @events = events.freeze
  @states = states.transform_keys(&:to_sym).freeze
  @children = children.freeze
  @output_names = output_names.map(&:to_sym).freeze
  @event_count = @events.length
  freeze
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



8
9
10
# File 'lib/igniter/extensions/contracts/audit/snapshot.rb', line 8

def children
  @children
end

#event_countObject (readonly)

Returns the value of attribute event_count.



8
9
10
# File 'lib/igniter/extensions/contracts/audit/snapshot.rb', line 8

def event_count
  @event_count
end

#eventsObject (readonly)

Returns the value of attribute events.



8
9
10
# File 'lib/igniter/extensions/contracts/audit/snapshot.rb', line 8

def events
  @events
end

#graphObject (readonly)

Returns the value of attribute graph.



8
9
10
# File 'lib/igniter/extensions/contracts/audit/snapshot.rb', line 8

def graph
  @graph
end

#output_namesObject (readonly)

Returns the value of attribute output_names.



8
9
10
# File 'lib/igniter/extensions/contracts/audit/snapshot.rb', line 8

def output_names
  @output_names
end

#profile_fingerprintObject (readonly)

Returns the value of attribute profile_fingerprint.



8
9
10
# File 'lib/igniter/extensions/contracts/audit/snapshot.rb', line 8

def profile_fingerprint
  @profile_fingerprint
end

#statesObject (readonly)

Returns the value of attribute states.



8
9
10
# File 'lib/igniter/extensions/contracts/audit/snapshot.rb', line 8

def states
  @states
end

Instance Method Details

#event_typesObject



21
22
23
# File 'lib/igniter/extensions/contracts/audit/snapshot.rb', line 21

def event_types
  events.map(&:type).uniq
end

#state(name) ⇒ Object



25
26
27
# File 'lib/igniter/extensions/contracts/audit/snapshot.rb', line 25

def state(name)
  states.fetch(name.to_sym)
end

#to_hObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/igniter/extensions/contracts/audit/snapshot.rb', line 29

def to_h
  {
    graph: graph,
    profile_fingerprint: profile_fingerprint,
    event_count: event_count,
    output_names: output_names,
    events: events.map(&:to_h),
    states: states,
    children: children
  }
end