recorder 1.2.1 → 1.2.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
  SHA256:
3
- metadata.gz: 2e0c1a0c2e47411273ae9c9ac9a8e285138a9c1db2013c606a32749fc869f1ef
4
- data.tar.gz: bbfa653c96171b63dfa0b974c59cf7d6fad3d59c9b7e6454cf1b9cacf64e16b7
3
+ metadata.gz: 11964998eab29e2ade0b5991c2dcd55f62918304afab5eab82acb8f7f4574813
4
+ data.tar.gz: 6a54bce4305e0529736140246332879b95bfb3770396ceb7ef6e4d64e383fd0f
5
5
  SHA512:
6
- metadata.gz: 1607e4d11cdefe2dd50f8c7966018e4da2f068e894e148edf41b4e6816b720a1ec40a80b91c2a6c9095901bf610a99028f8c11c53dcb235340799067142b7bcd
7
- data.tar.gz: 14f9ffe74d69077e3db56284e9dd15f7c304932de173eed0ffaceb85a3a5ea16fdcb71b74b0dc982afa1aabd0df73d8919deb782f7011313ccf2d2f8e958f925
6
+ metadata.gz: be73f56ca6cf864fcce8ff25cb66e2fe0c5b0c5cb59de32eb564c234a6edb5e8bba519d7bdc6255ad4ca559da5eda8456da009a09d376312ee3f23a6b6f84ca5
7
+ data.tar.gz: 7df337554a0136656250967b56d5df939f3eaf82c5164702ea4f159be322109a77ad994e0653f03616d22485e03c8fa6c06a2c167c3c8c6d8f8d3e3544dfe076
@@ -21,11 +21,13 @@ module Recorder
21
21
  recorder_dirty? && Recorder.store.recorder_enabled?
22
22
  end
23
23
 
24
- module ClassMethods
24
+ class_methods do
25
+ define_method :recorder_options do
26
+ @recorder_options ||= {}
27
+ end
28
+
25
29
  def recorder(options = {})
26
- define_method :recorder_options do
27
- options
28
- end
30
+ @recorder_options = options
29
31
 
30
32
  after_create do
31
33
  Recorder::Tape.new(self).record_create if recorder_record?
@@ -18,6 +18,7 @@ module Recorder
18
18
  )
19
19
  end
20
20
 
21
+ belongs_to :item, polymorphic: true, inverse_of: :revisions
21
22
  belongs_to :user
22
23
 
23
24
  validates :item_type, presence: true
@@ -27,20 +28,20 @@ module Recorder
27
28
 
28
29
  scope :ordered_by_created_at, -> { order(created_at: :desc) }
29
30
 
30
- def item
31
- return @item if defined?(@item)
32
- return if item_id.nil?
31
+ # def item
32
+ # return @item if defined?(@item)
33
+ # return if item_id.nil?
33
34
 
34
- @item = item_type.classify.constantize.new(data['attributes'])
35
+ # @item = item_type.classify.constantize.new(data['attributes'])
35
36
 
36
- if data['associations'].present?
37
- data['associations'].each do |name, association|
38
- @item.send("build_#{name}", association['attributes'])
39
- end
40
- end
37
+ # if data['associations'].present?
38
+ # data['associations'].each do |name, association|
39
+ # @item.send("build_#{name}", association['attributes'])
40
+ # end
41
+ # end
41
42
 
42
- @item
43
- end
43
+ # @item
44
+ # end
44
45
 
45
46
  # Get changeset for an item
46
47
  # @return [Recorder::Changeset]
@@ -7,7 +7,8 @@ module Recorder
7
7
 
8
8
  sidekiq_options Recorder.config.sidekiq_options
9
9
 
10
- def perform(**params)
10
+ def perform(params)
11
+ params['data'] = JSON.parse(params['data'])
11
12
  Recorder::Revision.create(params)
12
13
  end
13
14
  end
@@ -29,9 +29,12 @@ module Recorder
29
29
  end
30
30
 
31
31
  def record_async(params, options)
32
+ params[:data] = params[:data].to_json
33
+ params[:action_date] = params[:action_date].to_s
34
+
32
35
  Recorder::Sidekiq::RevisionsWorker.perform_in(
33
36
  options[:delay] || 2.seconds,
34
- **params
37
+ params.stringify_keys
35
38
  )
36
39
  end
37
40
  end
data/lib/recorder/tape.rb CHANGED
@@ -19,19 +19,19 @@ module Recorder
19
19
  def record_create
20
20
  data = data_for(:create, recorder_options)
21
21
 
22
- record(event: :create, data: data) if data.any?
22
+ record(event: 'create', data: data) if data.any?
23
23
  end
24
24
 
25
25
  def record_update
26
26
  data = data_for(:update, recorder_options)
27
27
 
28
- record(event: :update, data: data) if data.any?
28
+ record(event: 'update', data: data) if data.any?
29
29
  end
30
30
 
31
31
  def record_destroy
32
32
  data = data_for(:destroy, recorder_options)
33
33
 
34
- record(event: :destroy, data: data) if data.any?
34
+ record(event: 'destroy', data: data) if data.any?
35
35
  end
36
36
 
37
37
  protected
@@ -51,7 +51,7 @@ module Recorder
51
51
  item_id: item.id,
52
52
  **params
53
53
  },
54
- item.recorder_options
54
+ recorder_options
55
55
  )
56
56
  end
57
57
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Recorder
4
- VERSION = '1.2.1'
4
+ VERSION = '1.2.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recorder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Alexandrov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-16 00:00:00.000000000 Z
11
+ date: 2022-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord