Class: Upkeep::Subscriptions::Subscription

Inherits:
Data
  • Object
show all
Defined in:
lib/upkeep/subscriptions/store.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#graphObject (readonly)

Returns the value of attribute graph

Returns:

  • (Object)

    the current value of graph



12
13
14
# File 'lib/upkeep/subscriptions/store.rb', line 12

def graph
  @graph
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



12
13
14
# File 'lib/upkeep/subscriptions/store.rb', line 12

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



12
13
14
# File 'lib/upkeep/subscriptions/store.rb', line 12

def 
  @metadata
end

#recorderObject (readonly)

Returns the value of attribute recorder

Returns:

  • (Object)

    the current value of recorder



12
13
14
# File 'lib/upkeep/subscriptions/store.rb', line 12

def recorder
  @recorder
end

#subscriber_idObject (readonly)

Returns the value of attribute subscriber_id

Returns:

  • (Object)

    the current value of subscriber_id



12
13
14
# File 'lib/upkeep/subscriptions/store.rb', line 12

def subscriber_id
  @subscriber_id
end

Class Method Details

.from_h(snapshot) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/upkeep/subscriptions/store.rb', line 55

def self.from_h(snapshot)
  snapshot = Dependencies.symbolize_keys(snapshot)
  recorder = Runtime::Recorder.from_h(snapshot.fetch(:recorder))

  new(
    snapshot.fetch(:id),
    snapshot.fetch(:subscriber_id),
    recorder,
    recorder.graph,
    snapshot.fetch(:metadata)
  )
end

Instance Method Details

#explainObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/upkeep/subscriptions/store.rb', line 13

def explain
  dependency_nodes = graph.dependency_nodes
  dependencies = dependency_nodes.map(&:payload)

  {
    id: id,
    subscriber_id: subscriber_id,
    tables: active_record_tables(dependencies),
    identity: identity_dependencies(dependencies),
    frame_count: graph.frame_nodes.size,
    dependency_count: dependency_nodes.size,
    lookup_keys: lookup_keys_for(dependencies),
    metadata: 
  }
end

#identity_signature(frame_id) ⇒ Object



29
30
31
# File 'lib/upkeep/subscriptions/store.rb', line 29

def identity_signature(frame_id)
  recorder.identity_signature(frame_id)
end

#replay_recipe(frame_id) ⇒ Object



33
34
35
# File 'lib/upkeep/subscriptions/store.rb', line 33

def replay_recipe(frame_id)
  graph.node(frame_id).payload[:recipe]
end

#to_hObject



37
38
39
40
41
42
43
44
# File 'lib/upkeep/subscriptions/store.rb', line 37

def to_h
  {
    id: id,
    subscriber_id: subscriber_id,
    recorder: recorder.to_h,
    metadata: 
  }
end

#to_persistent_hObject



46
47
48
49
50
51
52
53
# File 'lib/upkeep/subscriptions/store.rb', line 46

def to_persistent_h
  {
    id: id,
    subscriber_id: subscriber_id,
    recorder: recorder.to_persistent_h,
    metadata: 
  }
end