Module: Sequel::Plugins::Wisper::InstanceMethods

Defined in:
lib/sequel/plugins/wisper.rb

Instance Method Summary collapse

Instance Method Details

#after_commitObject



82
83
84
85
# File 'lib/sequel/plugins/wisper.rb', line 82

def after_commit
  super
  broadcast(:after_commit, event_param)
end

#after_createObject



53
54
55
56
57
58
# File 'lib/sequel/plugins/wisper.rb', line 53

def after_create
  super
  broadcast(:after_create, event_param)
  db.after_commit { broadcast(:"create_#{model_name}_successful", event_param) }
  db.after_rollback { broadcast(:"create_#{model_name}_failed", event_param) }
end

#after_destroyObject



77
78
79
80
# File 'lib/sequel/plugins/wisper.rb', line 77

def after_destroy
  super
  broadcast(:after_destroy, event_param)
end

#after_destroy_commitObject



92
93
94
95
96
# File 'lib/sequel/plugins/wisper.rb', line 92

def after_destroy_commit
  super
  broadcast(:after_destroy_commit, event_param)
  broadcast(:"destroy_#{model_name}_successful", event_param)
end

#after_destroy_rollbackObject



98
99
100
101
102
# File 'lib/sequel/plugins/wisper.rb', line 98

def after_destroy_rollback
  super
  broadcast(:after_destroy_rollback, event_param)
  broadcast(:"destroy_#{model_name}_failed", event_param)
end

#after_rollbackObject



87
88
89
90
# File 'lib/sequel/plugins/wisper.rb', line 87

def after_rollback
  super
  broadcast(:after_rollback, event_param)
end

#after_saveObject



43
44
45
46
# File 'lib/sequel/plugins/wisper.rb', line 43

def after_save
  super
  broadcast(:after_save, event_param)
end

#after_updateObject



65
66
67
68
69
70
# File 'lib/sequel/plugins/wisper.rb', line 65

def after_update
  super
  broadcast(:after_update, event_param)
  db.after_commit { broadcast(:"update_#{model_name}_successful", event_param) }
  db.after_rollback { broadcast(:"update_#{model_name}_failed", event_param) }
end

#after_validationObject



33
34
35
36
# File 'lib/sequel/plugins/wisper.rb', line 33

def after_validation
  super
  broadcast(:after_validation, event_param)
end

#around_validationObject



104
105
106
107
108
109
110
111
112
113
114
# File 'lib/sequel/plugins/wisper.rb', line 104

def around_validation
  res = super
rescue => error
  res = nil
ensure
  if on_save? && !res
    action = new? ? 'create' : 'update'
    broadcast(:"#{action}_#{model_name}_failed", event_param)
  end
  raise error if error
end

#before_createObject



48
49
50
51
# File 'lib/sequel/plugins/wisper.rb', line 48

def before_create
  broadcast(:before_create, event_param)
  super
end

#before_destroyObject



72
73
74
75
# File 'lib/sequel/plugins/wisper.rb', line 72

def before_destroy
  broadcast(:before_destroy, event_param)
  super
end

#before_saveObject



38
39
40
41
# File 'lib/sequel/plugins/wisper.rb', line 38

def before_save
  broadcast(:before_save, event_param)
  super
end

#before_updateObject



60
61
62
63
# File 'lib/sequel/plugins/wisper.rb', line 60

def before_update
  broadcast(:before_update, event_param)
  super
end

#before_validationObject



28
29
30
31
# File 'lib/sequel/plugins/wisper.rb', line 28

def before_validation
  broadcast(:before_validation, event_param)
  super
end

#save(*args) ⇒ Object



24
25
26
# File 'lib/sequel/plugins/wisper.rb', line 24

def save(*args)
  on_save { super }
end