Class: Evento::Extractor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Extractor

Returns a new instance of Extractor.



7
8
9
# File 'lib/evento/extractor.rb', line 7

def initialize(klass)
  @klass = klass
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



5
6
7
# File 'lib/evento/extractor.rb', line 5

def klass
  @klass
end

Instance Method Details

#extract_audit_trail_association(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/evento/extractor.rb', line 17

def extract_audit_trail_association(options = {})
  name       = (options[:name] || :resource_state_transitions).to_sym
  reflection = extract_association_reflection(klass, name)

  return reflection if options[:reflection]

  reflection&.klass
end

#extract_events(options = {}) ⇒ Object



26
27
28
29
30
31
# File 'lib/evento/extractor.rb', line 26

def extract_events(options = {})
  events = []
  events += events_from_state_machine.map(&:to_s) if options[:state_machine]
  events += events_from_devise if options[:devise]
  events.sort
end

#extract_transaction_log_associationObject



11
12
13
14
15
# File 'lib/evento/extractor.rb', line 11

def extract_transaction_log_association
  reflection = extract_association_reflection(klass, :transaction_log_entries)

  reflection&.klass
end