Skip to content

Commit

Permalink
Swap method name of 'all_transaction' and 'full_transaction'
Browse files Browse the repository at this point in the history
  • Loading branch information
akicho8 committed May 14, 2015
1 parent f83f371 commit ecb7235
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -174,7 +174,7 @@ User.count #=> 0
or

```ruby
Kamome.full_transaction do
Kamome.all_transaction do
# transaction kamome.yml all targets
end
```
Expand Down
8 changes: 4 additions & 4 deletions examples/0020_example.rb
Expand Up @@ -20,8 +20,8 @@
# | Kamome.transaction(:blue) | [2, 0, 1] | 明示的に blue のみをロールバックさせた |
# | Kamome.transaction(:green) | [2, 1, 0] | 明示的に green のみをロールバックさせた |
# | Kamome.transaction(:blue, :green) | [2, 0, 0] | 明示的に blue green の両方をロールバックさせた |
# | Kamome.full_transaction | [2, 0, 0] | 水平分割用のDBすべて (blue と green) をロールバックさせた |
# | Kamome.all_transaction | [0, 0, 0] | master を含め、水平分割用DBをロールバックさせた |
# | Kamome.all_transaction | [2, 0, 0] | 水平分割用のDBすべて (blue と green) をロールバックさせた |
# | Kamome.full_transaction | [0, 0, 0] | master を含め、水平分割用DBをロールバックさせた |
# |-----------------------------------+------------+-----------------------------------------------------------------------------------------------|

require "bundler/setup"
Expand Down Expand Up @@ -112,8 +112,8 @@ class Article < ActiveRecord::Base
Kamome.transaction(:blue) { code.call } rescue $!; counts.call # => [2, 0, 1]
Kamome.transaction(:green) { code.call } rescue $!; counts.call # => [2, 1, 0]
Kamome.transaction(:blue, :green) { code.call } rescue $!; counts.call # => [2, 0, 0]
Kamome.full_transaction { code.call } rescue $!; counts.call # => [2, 0, 0]
Kamome.all_transaction { code.call } rescue $!; counts.call # => [0, 0, 0]
Kamome.all_transaction { code.call } rescue $!; counts.call # => [2, 0, 0]
Kamome.full_transaction { code.call } rescue $!; counts.call # => [0, 0, 0]

# >> Kamome: nil => :blue
# >> Kamome: :blue => :blue
Expand Down
6 changes: 3 additions & 3 deletions lib/kamome.rb
Expand Up @@ -67,15 +67,15 @@ def transaction(*args, &block)
end

# 水平分割用の全てのdatabaseでトランザクションを実行する
def full_transaction(&block)
def all_transaction(&block)
nested_transaction(transaction_target_models(Kamome.config.shard_names), &block)
end

# マスターを含めて全てのdatabaseでトランザクションを実行する
def all_transaction(&block)
def full_transaction(&block)
tagged("master transaction") do
ActiveRecord::Base.transaction do
full_transaction(&block)
all_transaction(&block)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/kamome_spec.rb
Expand Up @@ -153,11 +153,11 @@
end
end

describe "Kamome.full_transaction" do
describe "Kamome.all_transaction" do
before do
Kamome.target = :blue
begin
Kamome.full_transaction do
Kamome.all_transaction do
Kamome.anchor(:green) do
model.create!(name: 'green')
end
Expand All @@ -179,10 +179,10 @@
end
end

describe "Kamome.all_transaction" do
describe "Kamome.full_transaction" do
before do
begin
Kamome.all_transaction do
Kamome.full_transaction do
Kamome.anchor(:blue) { User.create!.articles.create!(:name => "x") }
Kamome.anchor(:green) { User.create!.articles.create!(:name => "x") }
raise ActiveRecord::ActiveRecordError
Expand Down

0 comments on commit ecb7235

Please sign in to comment.