rescue_unique_constraint 1.2.0 → 1.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ae927751df0dbaf9388e840db25719ee4a5bd6d
4
- data.tar.gz: 531bfc801a47a52c4b0e217663440341a00557a2
3
+ metadata.gz: 55de7ae1c3d780eaedf246b1f67e7cf6fd9b6f64
4
+ data.tar.gz: d35de4f38f093f526e8a3b11497103fdad7fd93e
5
5
  SHA512:
6
- metadata.gz: 3a72284d65d5ca068ca7ad3a0b1332566122cbbb4086685ec6fa0ad329611f235ddc7876c8dbd1ca8eb0fd52fb77d8fc9f6a4d28c279a63e80fe34c77d41f57e
7
- data.tar.gz: 7a0c92cf066504cf0f1aae321c400b208cc9e95016ea5bdab50b90d2f44ea0fbdb312d6fe90790c513048d18971e980d569314491600419012bc722ad9dd5d74
6
+ metadata.gz: 2954275c9aefff4a96de130fe19f43cfa05bfef820646325884df732223f6a02c0ac71e5cd80f460cf00f8a37af5fded59c80ba7ad666f440288db4edddf00ca
7
+ data.tar.gz: d9f7dbe85c99b9282968f334bab83277b7c49ffc52060211743915242c527b8545089a1e5c3ed8af6fde36bf2825da4de47a0476d68584fcfc96da6f0bf4d4bc
@@ -0,0 +1,9 @@
1
+ module RescueUniqueConstraint
2
+ module Adapter
3
+ class MysqlAdapter
4
+ def index_error?(index, error_message)
5
+ error_message[/#{index.name}/]
6
+ end
7
+ end
8
+ end
9
+ end
@@ -25,6 +25,8 @@ module RescueUniqueConstraint
25
25
  def database_adapter
26
26
  @_database_adapter ||= (
27
27
  case database_name
28
+ when :mysql2
29
+ Adapter::MysqlAdapter.new
28
30
  when :postgresql
29
31
  Adapter::PostgresqlAdapter.new
30
32
  when :sqlite
@@ -1,3 +1,3 @@
1
1
  module RescueUniqueConstraint
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require 'rescue_unique_constraint/version'
2
2
  require 'rescue_unique_constraint/index'
3
3
  require 'rescue_unique_constraint/rescue_handler'
4
+ require 'rescue_unique_constraint/adapter/mysql_adapter'
4
5
  require 'rescue_unique_constraint/adapter/postgresql_adapter'
5
6
  require 'rescue_unique_constraint/adapter/sqlite_adapter'
6
7
  require 'active_record'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rescue_unique_constraint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tam Dang
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-02-14 00:00:00.000000000 Z
12
+ date: 2018-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -131,6 +131,7 @@ files:
131
131
  - README.md
132
132
  - Rakefile
133
133
  - lib/rescue_unique_constraint.rb
134
+ - lib/rescue_unique_constraint/adapter/mysql_adapter.rb
134
135
  - lib/rescue_unique_constraint/adapter/postgresql_adapter.rb
135
136
  - lib/rescue_unique_constraint/adapter/sqlite_adapter.rb
136
137
  - lib/rescue_unique_constraint/index.rb
@@ -158,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
159
  version: '0'
159
160
  requirements: []
160
161
  rubyforge_project:
161
- rubygems_version: 2.4.3
162
+ rubygems_version: 2.6.13
162
163
  signing_key:
163
164
  specification_version: 4
164
165
  summary: Turns ActiveRecord::RecordNotUnique errors into ActiveRecord errors