Class: AuditTracker::DSL::Tracking
- Inherits:
-
Object
- Object
- AuditTracker::DSL::Tracking
- 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
- #create(relation, **options) ⇒ Object
- #on(event, relation, **options) ⇒ Object
- #tracker ⇒ Object
- #update(relation, **options) ⇒ Object
- #value(&block) ⇒ Object
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, **) on(:create, relation, **) end |
#on(event, relation, **options) ⇒ Object
33 34 35 36 |
# File 'lib/audit_tracker/dsl.rb', line 33 def on(event, relation, **) @on ||= [] @on << [event, relation, ] end |
#tracker ⇒ Object
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, **) on(:save, relation, **) end |
#value(&block) ⇒ Object
46 47 48 |
# File 'lib/audit_tracker/dsl.rb', line 46 def value(&block) @value = block end |