effective_logging 1.10.1 → 1.10.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a0761fe17b1a89eae022643b9a8fd78eb8c97ec
4
- data.tar.gz: f7fd1e4ab6e62489250fd391e3e391ea055741f1
3
+ metadata.gz: 4c25bb89ed7d4ea61f1a557b544bc2476d87346a
4
+ data.tar.gz: c648b6749add1af7a26aa1ae8afc189b90b906b3
5
5
  SHA512:
6
- metadata.gz: e22222aa91554582ceb840aef218db9ad9cb4df111f1b7a2dfc5092446f4a6d8833bbe235e964618b7c6afa6ab28f434eecc8186d57a234c503fb4fcb66b6444
7
- data.tar.gz: 64d75979741116fd9a36f89eb4f3211738684a2a4c37d8ef6d4cbde89db3dec875beaa367cd0e606b50cd94a9d94e2886d9c321d56902c1aa8ca9b27787e3dbf
6
+ metadata.gz: 9900a5a17e851dae1b6e41a61c73972c29b91108bfb1359a436baa828f00c07e30ddfd46112cb51b145f8e8f9b3852d1d94c83d23cc8e6c3944a54737aeae470
7
+ data.tar.gz: 0da0a1ce53129cbe60680b5766e7dac74a2710e3ac6295247e0fcb10a1d0aeb1bfecbcb2dcb15333cd39ba22784f48313d7ceb5ce518d3dfe462f4c81de353cb
data/README.md CHANGED
@@ -261,6 +261,12 @@ First, require the javascript in your application.js:
261
261
  //= require effective_logging
262
262
  ```
263
263
 
264
+ and add the user permission:
265
+
266
+ ```ruby
267
+ can :create, Effective::Log
268
+ ```
269
+
264
270
  then logging an event from JavaScript is almost the same one-liner as from ruby:
265
271
 
266
272
  ```javascript
@@ -10,7 +10,13 @@ if defined?(EffectiveDatatables)
10
10
  table_column :created_at
11
11
  table_column :id, visible: false
12
12
 
13
- unless attributes[:user_id] || attributes[:user] || (attributes[:user] == false)
13
+ if attributes[:user] == false
14
+ # Do not include
15
+ elsif attributes[:user_id].present?
16
+ table_column :user, filter: { collection: User.where(id: Array(attributes[:user_id])) }
17
+ elsif attributes[:user].present?
18
+ table_column :user, filter: { collection: User.where(id: Array(attributes[:user]).map { |user| user.to_param }) }
19
+ else
14
20
  table_column :user
15
21
  end
16
22
 
@@ -49,8 +55,8 @@ if defined?(EffectiveDatatables)
49
55
  end
50
56
 
51
57
  if (attributes[:user] || attributes[:user_id]).present?
52
- user_id = attributes[:user_id] || (attributes[:user].kind_of?(User) ? attributes[:user].id : attributes[:user].to_i)
53
- collection = collection.where('user_id = ? OR (associated_id = ? AND associated_type = ?)', user_id, user_id, 'User')
58
+ user_ids = Array(attributes[:user].presence || attributes[:user_id]).map { |user| user.kind_of?(User) ? user.id : user.to_i }
59
+ collection = collection.where('user_id IN (?) OR (associated_id IN (?) AND associated_type = ?)', user_ids, user_ids, 'User')
54
60
  end
55
61
 
56
62
  if attributes[:associated_id] && attributes[:associated_type]
@@ -46,6 +46,10 @@ module Effective
46
46
  "Log #{id}"
47
47
  end
48
48
 
49
+ def message=(msg)
50
+ write_attribute(:message, msg.kind_of?(String) ? msg.to_s[0...255] : msg)
51
+ end
52
+
49
53
  def log(message, status = EffectiveLogging.statuses.first, options = {})
50
54
  EffectiveLogger.log(message, status, (options || {}).merge(parent: self))
51
55
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveLogging
2
- VERSION = '1.10.1'.freeze
2
+ VERSION = '1.10.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.1
4
+ version: 1.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-10 00:00:00.000000000 Z
11
+ date: 2017-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails