better_record 0.12.5 → 0.13.0
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21977d959c121c40a33fba8d9ce2672e542c591c9140c56e1f8252441eb82260
|
4
|
+
data.tar.gz: 758ad406a6f5527c615fb79f3f0a7d273962a05808ac13d504d21bb7e063cab3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cb7081304de5466efcb5717a4a20baec1591bdc68ef92566cfd00ac426b880f93b1b142d458f40e2f8f8f1ede9b098629681ff4a1d5db87ca27c77a41433966
|
7
|
+
data.tar.gz: 151b00bf0f2fcf80ec0b36d794b95c823442bef76d842b49c94f6c162d35abfab3abc0bffb54c6cd7bbdb93beacb9949966ddf6f19e8ecade041bf81b57ab995
|
@@ -33,7 +33,15 @@ module BetterRecord
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.user_type
|
36
|
-
BetterRecord::PolymorphicOverride.polymorphic_value(self.user.class)
|
36
|
+
self.user ? BetterRecord::PolymorphicOverride.polymorphic_value(self.user.class) : 'NULL'
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.user_id
|
40
|
+
self.user ? user.id : 'NULL'
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.user_ip
|
44
|
+
self.ip_address ? "'#{self.ip_address}'" : 'NULL'
|
37
45
|
end
|
38
46
|
|
39
47
|
# == Boolean Methods ======================================================
|
@@ -42,6 +42,14 @@ module BetterRecord
|
|
42
42
|
BetterRecord::Current.user_type
|
43
43
|
end
|
44
44
|
|
45
|
+
def current_user_id
|
46
|
+
BetterRecord::Current.user_id
|
47
|
+
end
|
48
|
+
|
49
|
+
def current_user_ip
|
50
|
+
BetterRecord::Current.user_ip
|
51
|
+
end
|
52
|
+
|
45
53
|
def default_print
|
46
54
|
column_names
|
47
55
|
end
|
@@ -90,29 +98,25 @@ module BetterRecord
|
|
90
98
|
|
91
99
|
def transaction(*args)
|
92
100
|
super(*args) do
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
#{ip}
|
113
|
-
WHERE NOT EXISTS (SELECT * FROM _app_user);
|
114
|
-
SQL
|
115
|
-
end
|
101
|
+
ActiveRecord::Base.connection.execute <<-SQL
|
102
|
+
CREATE TEMP TABLE IF NOT EXISTS
|
103
|
+
"_app_user" (user_id integer, user_type text, ip_address inet);
|
104
|
+
|
105
|
+
UPDATE
|
106
|
+
_app_user
|
107
|
+
SET
|
108
|
+
user_id=#{current_user_id},
|
109
|
+
user_type='#{current_user_type}',
|
110
|
+
ip_address=#{current_user_ip};
|
111
|
+
|
112
|
+
INSERT INTO
|
113
|
+
_app_user (user_id, user_type, ip_address)
|
114
|
+
SELECT
|
115
|
+
#{current_user_id},
|
116
|
+
'#{current_user_type}',
|
117
|
+
#{current_user_ip}
|
118
|
+
WHERE NOT EXISTS (SELECT * FROM _app_user);
|
119
|
+
SQL
|
116
120
|
|
117
121
|
yield
|
118
122
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: better_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sampson Crowley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|