activerecord-redundancy 0.3.3 → 0.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e68d174487cbdb7ec2061bf60b3a39058f645fa
4
- data.tar.gz: c6a6434b61bc4cd1275a1cf4529b36e19b35640b
3
+ metadata.gz: 2a99315b6ab5b75fa9f75e316eb1b89eaeee46ce
4
+ data.tar.gz: a1924f47a0babed76fc894152b49b3c20f759770
5
5
  SHA512:
6
- metadata.gz: 9875b90b5647087742c36a47d6e2ed9d179afa5f428352dda99a655179d4b882e44fed248d5629941828c7a7268f01185c7ee9a4d2acaac69b0e469b9788c619
7
- data.tar.gz: 918fee0e77240ed84720392af096f75d8138071606e28dd3ff49efa66466a7b796622d48f9b4bd87aac26c1dec21a8cb1e203bd97735fdb58f4e08b63a7c9469
6
+ metadata.gz: e28a0907c6d60ab12ec1fea777be6a0c067289074b436d3a689fe5482c9c5cb7a10001cf7b50aa611b74ec8f51f3ead6d551ccc5a73933c35d6804fb32eef1c0
7
+ data.tar.gz: 32ba11f593050aa82759c59ef6cc381f9f1243004ecb48838c09eb864b8898e89915a3a601309bfa99d2c6442cb37c987dbb71e257e384c899dba1c1809ca66f
@@ -3,6 +3,19 @@ require 'redundancy/utils'
3
3
  module Redundancy
4
4
  extend ActiveSupport::Concern
5
5
 
6
+ def self.update_redundancies
7
+ ActiveRecord::Base.subclasses.each do |klass|
8
+ klass.try :update_redundancies
9
+ end
10
+ end
11
+
12
+ def update_redundancies
13
+ self.class.redundancies.each do |redundancy|
14
+ redundancy.force_update!(self)
15
+ end
16
+ save(validate: false)
17
+ end
18
+
6
19
  included do
7
20
  before_save :update_redundancies_before_save
8
21
  after_save :update_redundancies_after_save
@@ -22,20 +35,14 @@ module Redundancy
22
35
  end
23
36
  end
24
37
 
25
- def update_redundancies
26
- self.class.redundancies.each do |redundancy|
27
- redundancy.force_update!(self)
28
- end
29
- end
30
-
31
38
  module ClassMethods
32
39
  def cache_column association, attribute, options = {}
33
- options.assert_valid_keys(:cache_column, :inverse_of)
40
+ options.assert_valid_keys(:cache_column, :default)
34
41
  Utils.cache_column self, association, attribute, options
35
42
  end
36
43
 
37
44
  def cache_method association, attribute, options = {}
38
- options.assert_valid_keys(:cache_column, :inverse_of)
45
+ options.assert_valid_keys(:cache_method)
39
46
  Utils.cache_method self, association, attribute, options
40
47
  end
41
48
 
@@ -45,9 +52,7 @@ module Redundancy
45
52
 
46
53
  def update_redundancies
47
54
  all.each do |record|
48
- redundancies.each do |redundancy|
49
- redundancy.force_update!(record)
50
- end
55
+ record.update_redundancies
51
56
  end
52
57
  end
53
58
 
@@ -2,89 +2,117 @@ module Redundancy
2
2
 
3
3
  class UpdateBase
4
4
  attr_reader :options
5
- attr_reader :source, :dest, :klass
6
- attr_reader :change_if, :update, :force
7
- attr_reader :target, :value
5
+ attr_reader :klass, :source, :dest, :change_if
6
+ attr_reader :context
8
7
 
9
8
  def initialize options
10
9
  @options = options
11
- @source, @dest = options[:source], options[:dest]
12
10
  @klass = options[:klass]
13
-
11
+ @source, @dest = options[:source], options[:dest]
14
12
  @change_if = options[:change_if]
15
13
  @update = options[:update] || false
14
+
15
+ cleanup_context
16
16
  end
17
17
 
18
18
  def force_update! record
19
- @force = true
20
- @update = true
21
- before_save record
22
- after_save record
19
+ set_context :force, true
23
20
  end
24
21
 
22
+ # ActiveRecord Hooks
25
23
  def before_save record
26
24
  end
27
25
 
28
26
  def after_save record
29
27
  end
30
28
 
31
- def get_target_from_association record
32
- @target = dest[:association] ? record.send(dest[:association]) : record
29
+ protected
30
+
31
+ # Context
32
+ def set_context key, value
33
+ @context[key] = value
34
+ end
35
+
36
+ def cleanup_context
37
+ @context = {}
38
+ end
39
+
40
+ def update
41
+ @context[:update] || @update
42
+ end
43
+
44
+ def force
45
+ @context[:force]
33
46
  end
34
47
 
35
- def get_target_from_prev_id record
36
- prev_id = record.send(:attribute_was, dest[:prev_id])
37
- return unless prev_id
38
- @target = dest[:klass].where(id: prev_id)
48
+ def update_method
49
+ @context[:update_method] || (update ? :update_attribute : :write_attribute)
39
50
  end
40
51
 
41
- def get_target_from_relation_first_record
42
- @target = @target.first if @target.kind_of? ActiveRecord::Relation
52
+ def context key
53
+ @context[key]
43
54
  end
44
55
 
45
- def get_value_from_association record
46
- @value = source[:association] ? record.send(source[:association]) : record
47
- @value = value && source[:attribute] && value.send(source[:attribute])
48
- @value = nil if source[:nil_unless] && !record.send(source[:nil_unless])
49
- @value
56
+ def get_target_from_association record, key = :default
57
+ set_context :"target_#{key}", dest[:association] ? record.send(dest[:association]) : record
50
58
  end
51
59
 
52
- def get_value_from_source record
53
- @value = source
60
+ def get_target_from_prev_association record, key = :default
61
+ set_context :"target_#{key}", record.send(:attribute_was, dest[:association])
54
62
  end
55
63
 
56
- def get_value_from_target record
57
- @value = target && source[:attribute] && target.send(source[:attribute])
64
+ def get_target_from_foreign_key record, key = :default
65
+ id = record.send(:attribute_was, dest[:foreign_key])
66
+ return unless id
67
+ set_context :"target_#{key}", dest[:klass].where(id: id)
68
+ end
69
+
70
+ def get_target_from_relation_first_record key = :default
71
+ target = context(:"target_#{key}")
72
+ set_context :"target_#{key}", target.first if target.kind_of? ActiveRecord::Relation
73
+ end
74
+
75
+ def get_value_from_association record, key = :default
76
+ value = source[:association] ? record.send(source[:association]) : record
77
+ value = value && source[:attribute] && value.send(source[:attribute])
78
+ value = nil if source[:nil_unless] && !record.send(source[:nil_unless])
79
+ set_context :"value_#{key}", value
80
+ end
81
+
82
+ def get_value_from_default record, key = :default
83
+ set_context :"value_#{key}", source[:default]
84
+ end
85
+
86
+ def get_value_from_target record, key = :default
87
+ target = context(:"target_#{key}")
88
+ set_context :"value_#{key}", target && source[:attribute] && target.send(source[:attribute])
58
89
  end
59
90
 
60
91
  def raise_if_class_mismatch record
61
92
  raise ArgumentError, "record class mismatch, expected #{klass}, got #{record.class}" unless record.kind_of? klass
62
93
  end
63
94
 
64
- def update_target record
95
+ def update_target record, key = :default
96
+ target = context(:"target_#{key}")
97
+ value = context(:"value_#{key}")
98
+
65
99
  case target
66
100
  when ActiveRecord::Base
67
101
  return if target.send(:read_attribute, dest[:attribute]) == value
68
- log "#{ update ? "update" : "write" } #{target.class}(#{target.id})##{dest[:attribute]} with #{value.inspect}"
69
- log "#{change_if}: #{record.send(change_if).inspect}, #{dest[:association]||"self"}.id: #{target.id}" if change_if
70
- if update
71
- target.send(:update_attribute, dest[:attribute], value)
72
- else
73
- target.send(:write_attribute, dest[:attribute], value)
74
- end
102
+ log "#{update_method} #{target.class}(#{target.id})##{dest[:attribute]} with #{value.inspect}"
103
+ target.send(update_method, dest[:attribute], value)
75
104
  when ActiveRecord::Relation
76
- log "update #{target.class}##{dest[:attribute]} with #{value.inspect}"
105
+ log "update_all #{target.class}##{dest[:attribute]} with #{value.inspect}"
77
106
  target.send(:update_all, dest[:attribute] => value)
78
107
  end
79
108
  end
80
109
 
81
- def force_update_target record
82
- @update = true
83
- update_target record
110
+ def need_update? record
111
+ force || !change_if || record.send(:attribute_changed?, change_if)
84
112
  end
85
113
 
86
- def need_update? record
87
- @force || !change_if || record.send(:attribute_changed?, change_if)
114
+ def foreign_key_changed? record
115
+ record.send(:attribute_changed?, dest[:foreign_key])
88
116
  end
89
117
 
90
118
  # require 'colorize'
@@ -12,6 +12,8 @@ module Redundancy
12
12
  get_value_from_association record
13
13
 
14
14
  update_target record
15
+ ensure
16
+ cleanup_context
15
17
  end
16
18
 
17
19
  end
@@ -0,0 +1,27 @@
1
+ require 'redundancy/update_base'
2
+
3
+ module Redundancy
4
+
5
+ class UpdateColumnWithPrev < UpdateBase
6
+
7
+ def before_save record
8
+ raise_if_class_mismatch record
9
+ return unless need_update? record
10
+
11
+ get_target_from_association record
12
+ get_value_from_association record
13
+
14
+ update_target record
15
+
16
+ return unless foreign_key_changed? record
17
+ get_target_from_foreign_key record, :prev
18
+ get_value_from_default record, :prev
19
+
20
+ update_target record, :prev
21
+ ensure
22
+ cleanup_context
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,34 @@
1
+ require 'redundancy/update_base'
2
+
3
+ module Redundancy
4
+
5
+ class UpdateMethodWithPrev < UpdateBase
6
+
7
+ def before_save record
8
+ raise_if_class_mismatch record
9
+ return unless foreign_key_changed? record
10
+
11
+ get_target_from_foreign_key record, :prev
12
+ get_target_from_relation_first_record :prev
13
+ end
14
+
15
+ def after_save record
16
+ return unless need_update? record
17
+ set_context :update_method, :update_column
18
+
19
+ get_target_from_association record
20
+ get_value_from_target record
21
+
22
+ update_target record
23
+
24
+ return unless context(:"target_prev")
25
+
26
+ get_value_from_target record, :prev
27
+ update_target record, :prev
28
+ ensure
29
+ cleanup_context
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -1,7 +1,6 @@
1
1
  require 'redundancy/update_column'
2
- require 'redundancy/update_prev_column'
3
- require 'redundancy/update_method'
4
- require 'redundancy/update_prev_method'
2
+ require 'redundancy/update_column_with_prev'
3
+ require 'redundancy/update_method_with_prev'
5
4
 
6
5
  module Redundancy
7
6
 
@@ -17,7 +16,7 @@ module Redundancy
17
16
  foreign_key = reflection.foreign_key
18
17
  remote_klass = reflection.klass
19
18
 
20
- inverse_association = get_inverse_association local_klass, remote_klass, options
19
+ inverse_association = get_inverse_association local_klass, remote_klass, reflection.options
21
20
 
22
21
  cache_column = options[:cache_column] || :"#{association}_#{attribute}"
23
22
 
@@ -30,17 +29,44 @@ module Redundancy
30
29
  )
31
30
 
32
31
  when :has_one
33
- remote_klass.redundancies << UpdateColumn.new(
34
- source: { association: nil, attribute: attribute, nil_unless: foreign_key },
35
- dest: { association: inverse_association, attribute: cache_column },
36
- change_if: foreign_key, klass: remote_klass
37
- )
38
-
39
- remote_klass.redundancies << UpdatePrevColumn.new(
40
- source: options[:default],
41
- dest: { klass: local_klass, prev_id: foreign_key, attribute: cache_column },
42
- change_if: foreign_key, klass: remote_klass
43
- )
32
+ if reflection.through_reflection
33
+
34
+ through_reflection = reflection.through_reflection
35
+ if through_reflection.through_reflection
36
+ raise ArgumentError, "Multi level has_one through reflection is not support yet!"
37
+ end
38
+
39
+ through_foreign_key = through_reflection.foreign_key
40
+ through_remote_klass = through_reflection.klass
41
+ through_association = reflection.source_reflection_name
42
+ through_inverse_association = get_inverse_association local_klass, through_remote_klass
43
+
44
+ case through_reflection.macro
45
+ when :belongs_to
46
+ local_klass.redundancies << UpdateColumn.new(
47
+ source: { association: association, attribute: attribute },
48
+ dest: { association: nil, attribute: cache_column },
49
+ change_if: through_foreign_key, klass: local_klass
50
+ )
51
+
52
+ when :has_one
53
+ raise ArgumentError, "has_one through has_one reflection is not support yet!"
54
+ end
55
+
56
+ through_remote_klass.redundancies << UpdateColumn.new(
57
+ source: { association: through_association, attribute: attribute },
58
+ dest: { association: through_inverse_association, attribute: cache_column },
59
+ change_if: foreign_key, klass: through_remote_klass
60
+ )
61
+
62
+ else
63
+ remote_klass.redundancies << UpdateColumnWithPrev.new(
64
+ source: { association: nil, attribute: attribute, nil_unless: foreign_key, default: options[:default] },
65
+ dest: { klass: local_klass, foreign_key: foreign_key, association: inverse_association, attribute: cache_column },
66
+ change_if: foreign_key, klass: remote_klass
67
+ )
68
+
69
+ end
44
70
 
45
71
  end
46
72
 
@@ -51,7 +77,7 @@ module Redundancy
51
77
  )
52
78
  end
53
79
 
54
- def self.cache_method klass, association, attribute, options
80
+ def self.cache_method klass, association, attribute, options = {}
55
81
  local_klass = klass
56
82
 
57
83
  reflection = get_reflection local_klass, association
@@ -63,27 +89,23 @@ module Redundancy
63
89
 
64
90
  cache_method = options[:cache_method] || :"raw_#{attribute}"
65
91
 
66
- local_klass.redundancies << UpdateMethod.new(
67
- source: { attribute: cache_method },
68
- dest: { association: association, attribute: attribute },
69
- change_if: options[:change_if], klass: local_klass
70
- )
71
-
72
- local_klass.redundancies << UpdatePrevMethod.new(
92
+ local_klass.redundancies << UpdateMethodWithPrev.new(
73
93
  source: { attribute: cache_method },
74
- dest: { klass: remote_klass, prev_id: foreign_key, attribute: attribute },
75
- change_if: foreign_key, klass: local_klass
94
+ dest: { klass: remote_klass, foreign_key: foreign_key, association: association, attribute: attribute },
95
+ change_if: nil, klass: local_klass
76
96
  )
77
97
 
78
98
  end
79
99
 
100
+ private
101
+
80
102
  def self.get_reflection klass, association
81
103
  reflection = klass.reflect_on_association(association)
82
104
  raise ArgumentError, "Unknown association :#{association}" unless reflection
83
105
  reflection
84
106
  end
85
107
 
86
- def self.get_inverse_association klass, reflection_klass, options
108
+ def self.get_inverse_association klass, reflection_klass, options = {}
87
109
  model_name = klass.model_name
88
110
  inverse_associations = options[:inverse_of]
89
111
  inverse_associations ||= [model_name.plural, model_name.singular].map(&:to_sym)
@@ -96,7 +118,6 @@ module Redundancy
96
118
  inverse_association
97
119
  end
98
120
 
99
-
100
121
  end
101
122
 
102
123
  end
@@ -1,3 +1,3 @@
1
1
  module Redundancy
2
- VERSION = "0.3.3"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -54,7 +54,7 @@ class HasManyBelongsToAssociationTest < ActiveSupport::TestCase
54
54
  assert_equal user.name, post.user_name
55
55
 
56
56
  user.update_attribute(:name, "Other Name")
57
- user.posts.each do |post|
57
+ user.posts.reload.each do |post|
58
58
  assert_equal user.name, post.user_name
59
59
  end
60
60
  assert_equal user.name, post.reload.user_name
@@ -0,0 +1,44 @@
1
+ require 'test_helper'
2
+
3
+ class HasOneThroughBelongsToAssociationTest < ActiveSupport::TestCase
4
+
5
+ # has_one:through:belongs_to association
6
+ test "should update post.account_email when create post" do
7
+ account = accounts(:one)
8
+ user = users(:one)
9
+ post = Post.create(title: 'title', content: 'content', user: user)
10
+ assert_equal account.email, post.account_email
11
+ end
12
+
13
+ test "should update post.account_email when update post.user" do
14
+ account = accounts(:one)
15
+ user = users(:one)
16
+ post = posts(:two)
17
+ assert_not_equal account.email, post.account_email
18
+
19
+ post.update_attribute(:user, user)
20
+ assert_equal account.email, post.account_email
21
+ assert_equal account.email, post.reload.account_email
22
+ end
23
+
24
+ test "should update post.account_email when update user.account" do
25
+ account = accounts(:one)
26
+ user = users(:two)
27
+ post = posts(:two)
28
+ assert_not_equal account.email, post.account_email
29
+
30
+ user.update_attribute(:account, account)
31
+ assert_equal account.email, post.reload.account_email
32
+ end
33
+
34
+ test "should update post.account_email when update account.email" do
35
+ account = accounts(:one)
36
+ user = users(:one)
37
+ post = posts(:one)
38
+ assert_equal account.email, post.account_email
39
+
40
+ account.update_attribute(:email, "other@email.com")
41
+ assert_equal account.email, post.reload.account_email
42
+ end
43
+
44
+ end
@@ -6,7 +6,7 @@ class OptionsTest < ActiveSupport::TestCase
6
6
  test "should update post.username when create post" do
7
7
  user = users(:one)
8
8
  post = Post.create(title: 'title', content: 'content', user: user)
9
- assert_equal post.username, user.name
9
+ assert_equal user.name, post.username
10
10
  end
11
11
 
12
- end
12
+ end
@@ -7,6 +7,7 @@ one:
7
7
  user_id: 1
8
8
  user_name: Name 1
9
9
  username: Name 1
10
+ account_email: one@one.com
10
11
  star: 3
11
12
 
12
13
  two:
@@ -16,4 +17,5 @@ two:
16
17
  user_id: 2
17
18
  user_name: Name 2
18
19
  username: Name 2
20
+ account_email: two@two.com
19
21
  star: 5
@@ -12,16 +12,34 @@ ActiveRecord::Migration.verbose = false
12
12
  ActiveRecord::Schema.define do
13
13
 
14
14
  create_table "accounts", force: true do |t|
15
- t.string "user_name"
16
15
  t.string "email"
16
+ t.string "user_name"
17
+ t.string "session_name"
18
+ t.datetime "created_at"
19
+ t.datetime "updated_at"
20
+ end
21
+
22
+ create_table "users", force: true do |t|
23
+ t.integer "account_id"
24
+ t.string "account_email"
25
+ t.string "session_name"
26
+ t.integer "posts_count"
27
+ t.integer "posts_star"
28
+ t.string "name"
17
29
  t.datetime "created_at"
18
30
  t.datetime "updated_at"
19
31
  end
20
32
 
33
+ create_table "sessions", force: true do |t|
34
+ t.integer "user_id"
35
+ t.string "name"
36
+ end
37
+
21
38
  create_table "posts", force: true do |t|
22
39
  t.integer "user_id"
23
40
  t.string "user_name"
24
41
  t.string "username"
42
+ t.string "account_email"
25
43
  t.integer "star"
26
44
  t.string "title"
27
45
  t.text "content"
@@ -31,16 +49,6 @@ ActiveRecord::Schema.define do
31
49
 
32
50
  add_index "posts", ["user_id"], name: "index_posts_on_user_id"
33
51
 
34
- create_table "users", force: true do |t|
35
- t.integer "account_id"
36
- t.string "account_email"
37
- t.integer "posts_count"
38
- t.integer "posts_star"
39
- t.string "name"
40
- t.datetime "created_at"
41
- t.datetime "updated_at"
42
- end
43
-
44
52
  end
45
53
 
46
54
  autoload :Account, 'support/models/account'
@@ -1,5 +1,7 @@
1
1
  class Account < ActiveRecord::Base
2
2
  has_one :user
3
+ has_one :session, through: :user
4
+ has_many :posts, through: :user
3
5
 
4
6
  cache_column :user, :name
5
7
  end
@@ -1,5 +1,8 @@
1
1
  class Post < ActiveRecord::Base
2
2
  belongs_to :user
3
+ has_one :account, through: :user
4
+
5
+ cache_column :account, :email
3
6
 
4
7
  cache_column :user, :name
5
8
  cache_column :user, :name, cache_column: :username
@@ -0,0 +1,3 @@
1
+ class Session < ActiveRecord::Base
2
+ belongs_to :user
3
+ end
@@ -1,6 +1,7 @@
1
1
  class User < ActiveRecord::Base
2
- has_many :posts
3
2
  belongs_to :account
3
+ has_one :session
4
+ has_many :posts
4
5
 
5
6
  cache_column :account, :email
6
7
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-redundancy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Theo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-27 00:00:00.000000000 Z
11
+ date: 2016-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -44,6 +44,34 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: pry
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: pry-byebug
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
47
75
  - !ruby/object:Gem::Dependency
48
76
  name: pry-rescue
49
77
  requirement: !ruby/object:Gem::Requirement
@@ -99,14 +127,14 @@ files:
99
127
  - lib/redundancy.rb
100
128
  - lib/redundancy/update_base.rb
101
129
  - lib/redundancy/update_column.rb
102
- - lib/redundancy/update_method.rb
103
- - lib/redundancy/update_prev_column.rb
104
- - lib/redundancy/update_prev_method.rb
130
+ - lib/redundancy/update_column_with_prev.rb
131
+ - lib/redundancy/update_method_with_prev.rb
105
132
  - lib/redundancy/utils.rb
106
133
  - lib/redundancy/version.rb
107
134
  - test/cache_column/belongs_to_has_one_association_test.rb
108
135
  - test/cache_column/has_many_belongs_to_association_test.rb
109
136
  - test/cache_column/has_one_belongs_to_association_test.rb
137
+ - test/cache_column/has_one_through_belongs_to_association_test.rb
110
138
  - test/cache_column/options_test.rb
111
139
  - test/cache_method/has_many_belongs_to_association_test.rb
112
140
  - test/fixtures/accounts.yml
@@ -115,6 +143,7 @@ files:
115
143
  - test/support/environment.rb
116
144
  - test/support/models/account.rb
117
145
  - test/support/models/post.rb
146
+ - test/support/models/session.rb
118
147
  - test/support/models/user.rb
119
148
  - test/test_helper.rb
120
149
  homepage: https://github.com/bbtfr/activerecord-redundancy
@@ -137,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
166
  version: '0'
138
167
  requirements: []
139
168
  rubyforge_project:
140
- rubygems_version: 2.4.6
169
+ rubygems_version: 2.5.1
141
170
  signing_key:
142
171
  specification_version: 4
143
172
  summary: Redundancy for better performance, non painful
@@ -145,6 +174,7 @@ test_files:
145
174
  - test/cache_column/belongs_to_has_one_association_test.rb
146
175
  - test/cache_column/has_many_belongs_to_association_test.rb
147
176
  - test/cache_column/has_one_belongs_to_association_test.rb
177
+ - test/cache_column/has_one_through_belongs_to_association_test.rb
148
178
  - test/cache_column/options_test.rb
149
179
  - test/cache_method/has_many_belongs_to_association_test.rb
150
180
  - test/fixtures/accounts.yml
@@ -153,6 +183,6 @@ test_files:
153
183
  - test/support/environment.rb
154
184
  - test/support/models/account.rb
155
185
  - test/support/models/post.rb
186
+ - test/support/models/session.rb
156
187
  - test/support/models/user.rb
157
188
  - test/test_helper.rb
158
- has_rdoc:
@@ -1,19 +0,0 @@
1
- require 'redundancy/update_base'
2
-
3
- module Redundancy
4
-
5
- class UpdateMethod < UpdateBase
6
-
7
- def after_save record
8
- raise_if_class_mismatch record
9
- return unless need_update? record
10
-
11
- get_target_from_association record
12
- get_value_from_target record
13
-
14
- force_update_target record
15
- end
16
-
17
- end
18
-
19
- end
@@ -1,19 +0,0 @@
1
- require 'redundancy/update_base'
2
-
3
- module Redundancy
4
-
5
- class UpdatePrevColumn < UpdateBase
6
-
7
- def before_save record
8
- raise_if_class_mismatch record
9
- return unless need_update? record
10
-
11
- get_target_from_prev_id record
12
- get_value_from_source record
13
-
14
- update_target record
15
- end
16
-
17
- end
18
-
19
- end
@@ -1,24 +0,0 @@
1
- require 'redundancy/update_base'
2
-
3
- module Redundancy
4
-
5
- class UpdatePrevMethod < UpdateBase
6
-
7
- def before_save record
8
- raise_if_class_mismatch record
9
- return unless need_update? record
10
-
11
- get_target_from_prev_id record
12
- get_target_from_relation_first_record
13
- end
14
-
15
- def after_save record
16
- return unless target
17
-
18
- get_value_from_target record
19
- force_update_target record
20
- end
21
-
22
- end
23
-
24
- end