log_book 0.6.1 → 0.6.3
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 +4 -4
- data/README.md +5 -0
- data/lib/log_book/version.rb +1 -1
- data/lib/log_book.rb +12 -1
- data/test/log_book_test.rb +11 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eeea49aa6e73b24e651d354848d74e5cab562bc9fd4cfa41179824249ee3bdba
|
4
|
+
data.tar.gz: e2ba899bdb4ec534d3f97ce6164c2c7e62ff0b9667f1396917f09803e8f74fa3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6313ed2fa0546d058d45930675dd0c77b11602a5beb5365d024c90adfd96eda90ee80887ec3ea1d1eb975cb1eb2948e544d8b869f28ab576779b2a5a9fe7bb9e
|
7
|
+
data.tar.gz: f3d02963f53897fcd2347054f4ea29ccd48a9319839921ccbb5c51b190db72ee1155fb7cf78eee471a93621f3a1dc805ea08d8fc19e3699d0a8796981fb33961
|
data/README.md
CHANGED
@@ -56,6 +56,11 @@ If you want to _mute_ a model change:
|
|
56
56
|
my_model.log_book_mute = true
|
57
57
|
my_model.save! # No LogBook::Event will be generated
|
58
58
|
|
59
|
+
If you want to _mute_ LogBook globally:
|
60
|
+
|
61
|
+
LogBook.mute = true
|
62
|
+
my_model.save! # No LogBook::Event will be generated
|
63
|
+
|
59
64
|
If you want to _ignore_ some fields from the changes Event:
|
60
65
|
|
61
66
|
class MyModel < ActiveRecord::Base
|
data/lib/log_book/version.rb
CHANGED
data/lib/log_book.rb
CHANGED
@@ -12,7 +12,11 @@ module LogBook
|
|
12
12
|
:destroy => "destroy"
|
13
13
|
}
|
14
14
|
|
15
|
+
@@muted = false
|
16
|
+
|
15
17
|
def self.event(historian, historizable, differences, tag_list)
|
18
|
+
return if @@muted
|
19
|
+
|
16
20
|
tag_list_composed = []
|
17
21
|
tag_list_composed << scope_tag(historian) if historian
|
18
22
|
tag_list_composed << kind_tag(historizable) if historizable
|
@@ -26,6 +30,14 @@ module LogBook
|
|
26
30
|
)
|
27
31
|
end
|
28
32
|
|
33
|
+
def self.muted=(value)
|
34
|
+
@@muted = value
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.muted
|
38
|
+
@@muted
|
39
|
+
end
|
40
|
+
|
29
41
|
private
|
30
42
|
|
31
43
|
def self.created(historian, historizable)
|
@@ -48,4 +60,3 @@ module LogBook
|
|
48
60
|
historizable.class.name.underscore
|
49
61
|
end
|
50
62
|
end
|
51
|
-
|
data/test/log_book_test.rb
CHANGED
@@ -135,4 +135,15 @@ class LogBookTest < MiniTest::Test
|
|
135
135
|
|
136
136
|
assert_equal(false, LogBook::Event.exists?(log_book_event.id))
|
137
137
|
end
|
138
|
+
|
139
|
+
def test_created_when_global_muted
|
140
|
+
item = Item.new(:title => "Item Title")
|
141
|
+
LogBook.muted = true
|
142
|
+
|
143
|
+
LogBook::Event.expects(:create!).never
|
144
|
+
|
145
|
+
item.save!
|
146
|
+
|
147
|
+
LogBook.muted = false
|
148
|
+
end
|
138
149
|
end
|