Class: AuditTracker::DSL::Tracking

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

Overview

AuditTracker::DSL::Setup is the DSL cotext of the block in ‘DSL::Setup.tracker`

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(&block) ⇒ Object



23
24
25
26
27
# File 'lib/audit_tracker/dsl.rb', line 23

def self.build(&block)
  tracker = new
  tracker.instance_eval(&block)
  tracker.tracker
end

Instance Method Details

#create(relation, **options) ⇒ Object



42
43
44
# File 'lib/audit_tracker/dsl.rb', line 42

def create(relation, **options)
  on(:create, relation, **options)
end

#on(event, relation, **options) ⇒ Object



33
34
35
36
# File 'lib/audit_tracker/dsl.rb', line 33

def on(event, relation, **options)
  @on ||= []
  @on << [event, relation, options]
end

#trackerObject



29
30
31
# File 'lib/audit_tracker/dsl.rb', line 29

def tracker
  ::AuditTracker::Tracker.new(on: @on, value: @value)
end

#update(relation, **options) ⇒ Object



38
39
40
# File 'lib/audit_tracker/dsl.rb', line 38

def update(relation, **options)
  on(:save, relation, **options)
end

#value(&block) ⇒ Object



46
47
48
# File 'lib/audit_tracker/dsl.rb', line 46

def value(&block)
  @value = block
end