protokoll 0.5.3 → 0.6.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.
- data/lib/protokoll/counter.rb +1 -0
- data/lib/protokoll/protokoll.rb +8 -8
- data/lib/protokoll/version.rb +1 -1
- data/test/dummy/log/test.log +26349 -0
- data/test/protokoll_test.rb +19 -2
- metadata +2 -2
data/lib/protokoll/counter.rb
CHANGED
data/lib/protokoll/protokoll.rb
CHANGED
@@ -2,22 +2,22 @@ module Protokoll
|
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
module ClassMethods
|
5
|
-
|
5
|
+
|
6
6
|
# Class method available in models
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# == Example
|
9
9
|
# class Order < ActiveRecord::Base
|
10
10
|
# protokoll :number
|
11
11
|
# end
|
12
12
|
#
|
13
13
|
def protokoll(column, _options = {})
|
14
|
-
options = { :pattern => "%Y%m#####",
|
14
|
+
options = { :pattern => "%Y%m#####",
|
15
15
|
:number_symbol => "#",
|
16
16
|
:column => column,
|
17
17
|
:start => 0 }
|
18
18
|
|
19
19
|
options.merge!(_options)
|
20
|
-
|
20
|
+
|
21
21
|
# Defining custom method
|
22
22
|
send :define_method, "reserve_#{options[:column]}!".to_sym do
|
23
23
|
self[column] = Counter.next(self, options)
|
@@ -25,11 +25,11 @@ module Protokoll
|
|
25
25
|
|
26
26
|
# Signing before_create
|
27
27
|
before_create do |record|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
unless record[column].present?
|
29
|
+
record[column] = Counter.next(self, options)
|
30
|
+
end
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
end
|
data/lib/protokoll/version.rb
CHANGED