log_book 0.6.1 → 0.6.3

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
  SHA256:
3
- metadata.gz: 3ba38b6769d1e3ce4158b5c961f87c65561eb3ea49e7dcc1a9232b12dc61378e
4
- data.tar.gz: 991cd4b51ebd117eca1f61f3bd8083c82dfad477028ce483e79aee48d2bd6334
3
+ metadata.gz: eeea49aa6e73b24e651d354848d74e5cab562bc9fd4cfa41179824249ee3bdba
4
+ data.tar.gz: e2ba899bdb4ec534d3f97ce6164c2c7e62ff0b9667f1396917f09803e8f74fa3
5
5
  SHA512:
6
- metadata.gz: a7a71db90398ef4e9d9c9ae6754a470ec2a0771603f5b1ee53b1cb115c46f92565c236cd12f45f9cad3b05bf1af2765c541c628df9f80bc1add75fb4c71aa8a0
7
- data.tar.gz: e29d9b47f58ddd2b59a0fa8acffecf00a80313ae5093411b3a99a005f60b069019404a2e6108a3cbbed583d44fce05a8c01549616bc6e48c82419f9d992913ec
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
@@ -1,3 +1,3 @@
1
1
  module LogBook
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.3"
3
3
  end
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
-
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log_book
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Guillen