14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/api_notify/active_record/main.rb', line 14
def api_notify(fields, identificators, *args)
options = args.
after_update :post_via_api
after_create :post_via_api
after_destroy :delete_via_api
attr_accessor :skip_api_notify
define_method :notify_attributes do
fields
end
define_method :identificators do
identificators
end
METHODS.each do |method|
define_method "api_notify_#{method}_success" do |response|
end
define_method "api_notify_#{method}_failed" do |response|
end
end
options.each_pair do |key, value|
define_singleton_method key do
value
end
end
define_singleton_method :synchronizer do
begin
_api_route_name = api_route_name
ApiNotify::LOGGER.info "api_route_name2: #{api_route_name}"
rescue Exception => e
_api_route_name = class_name.pluralize
end
ApiNotify::ActiveRecord::Synchronizer.new _api_route_name.downcase, identificators.keys.first
end
end
|