syslog_client 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,7 +12,14 @@ module SyslogClient
|
|
12
12
|
raise ArgumentError, 'options should be instance of Hash' unless options.is_a?(::Hash)
|
13
13
|
options.symbolize_keys!
|
14
14
|
options.assert_valid_keys(:deal_id, :operation, :operation_time, :operator, :result, :message )
|
15
|
-
|
15
|
+
|
16
|
+
options.slice(:operation, :message, :operator, :result).map { |k, v| options[k] = v.to_s }
|
17
|
+
options[:deal_id] = options[:deal_id].to_i
|
18
|
+
if [Date, DateTime, Time].include?(operation[:operation_time].class)
|
19
|
+
options[:operation_time] = options[:operation_time].to_s(:db)
|
20
|
+
else
|
21
|
+
options[:operation_time] = options[:operation_time].to_s
|
22
|
+
end
|
16
23
|
end
|
17
24
|
|
18
25
|
def get_operator(operation)
|
data/lib/syslog_client/editor.rb
CHANGED
@@ -13,6 +13,14 @@ module SyslogClient
|
|
13
13
|
options.symbolize_keys!
|
14
14
|
options.assert_valid_keys(:user_id, :reason, :entry_class, :entry_id, :operation_time, :changes, :object)
|
15
15
|
|
16
|
+
options.slice(:user_id, :entry_id).map { |k, v| options[k] = v.to_i }
|
17
|
+
options.slice(:reason, :entry_class).map { |k, v| options[k] = v.to_s }
|
18
|
+
if [Date, DateTime, Time].include?(options[:operation_time].class)
|
19
|
+
options[:operation_time] = options[:operation_time].to_s(:db)
|
20
|
+
else
|
21
|
+
options[:operation_time] = options[:operation_time].to_s
|
22
|
+
end
|
23
|
+
|
16
24
|
if options[:changes]
|
17
25
|
_normalize_changes(options)
|
18
26
|
elsif obj = options[:object]
|
@@ -29,12 +37,11 @@ module SyslogClient
|
|
29
37
|
def log_of_changes(options)
|
30
38
|
options[:changes].inject([]) do |infos, change|
|
31
39
|
info = {
|
32
|
-
:operation => change[0],
|
33
|
-
:value => change[1][1],
|
34
|
-
:value_was => change[1][0],
|
40
|
+
:operation => change[0].to_s,
|
41
|
+
:value => change[1][1].to_s,
|
42
|
+
:value_was => change[1][0].to_s,
|
35
43
|
:type => 'editor'
|
36
44
|
}.merge(options.slice(:user_id, :reason, :entry_class, :entry_id, :operation_time))
|
37
|
-
info.map { |k, v| info[k] = v.to_s }
|
38
45
|
infos << info
|
39
46
|
end
|
40
47
|
end
|
@@ -12,7 +12,14 @@ module SyslogClient
|
|
12
12
|
raise ArgumentError, 'options should be instance of Hash' unless options.is_a?(::Hash)
|
13
13
|
options.symbolize_keys!
|
14
14
|
options.assert_valid_keys(:reason, :source, :deal_id, :tuan_shop_id, :shop_info_id, :operation_time)
|
15
|
-
|
15
|
+
|
16
|
+
options.slice(:reason, :source, :tuan_shop_id, :shop_info_id).map { |k, v| options[k] = v.to_s }
|
17
|
+
options[:deal_id] = options[:deal_id].to_i
|
18
|
+
if [Date, DateTime, Time].include?(options[:operation_time].class)
|
19
|
+
options[:operation_time] = options[:operation_time].to_s(:db)
|
20
|
+
else
|
21
|
+
options[:operation_time] = options[:operation_time].to_s
|
22
|
+
end
|
16
23
|
end
|
17
24
|
end
|
18
25
|
end
|