multitenant-mysql 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,3 +7,6 @@
7
7
 
8
8
  1.2.1 (April 1, 2013)
9
9
  * fixed bug (https://github.com/eugenekorpan/multitenant-mysql/issues/25)
10
+
11
+ 1.2.2 (Jun 20, 2013)
12
+ * fixed issue (https://github.com/eugenekorpan/multitenant-mysql/issues/28)
@@ -1,45 +1,52 @@
1
- class ActiveRecord::Base
2
- def self.acts_as_tenants_bucket
3
- after_create do
4
- password = Multitenant::Mysql::DB.configs['password']
5
- tenant_name = self.send(Multitenant::Mysql.configs.bucket_field)
6
- connection = Multitenant::Mysql::DB.connection
7
- connection.execute "GRANT ALL PRIVILEGES ON *.* TO '#{tenant_name}'@'localhost' IDENTIFIED BY '#{password}' WITH GRANT OPTION;"
8
- connection.execute "flush privileges;"
1
+ ActiveRecord::Base.class_eval do
2
+
3
+ class << self
4
+
5
+ def acts_as_tenants_bucket
6
+ after_create do
7
+ password = Multitenant::Mysql::DB.configs['password']
8
+ tenant_name = self.send(Multitenant::Mysql.configs.bucket_field)
9
+ connection = Multitenant::Mysql::DB.connection
10
+ connection.execute "GRANT ALL PRIVILEGES ON *.* TO '#{tenant_name}'@'localhost' IDENTIFIED BY '#{password}' WITH GRANT OPTION;"
11
+ connection.execute "flush privileges;"
12
+ end
9
13
  end
10
- end
11
14
 
12
- def self.acts_as_tenant
13
- view_name = model_name.to_s.downcase.pluralize + "_view"
14
- # check whether the view exists in db
15
- if ActiveRecord::Base.connection.table_exists? view_name
16
- self.class_eval do
17
- cattr_accessor :original_table_name
18
-
19
- self.original_table_name = self.table_name
20
- self.table_name = view_name
21
- self.primary_key = :id
22
-
23
- def self.new(*args)
24
- object = super(*args)
25
- object.id = nil # workaround for https://github.com/rails/rails/issues/5982
26
- object
15
+ def acts_as_tenant
16
+ view_name = model_name.to_s.downcase.pluralize + "_view"
17
+ # check whether the view exists in db
18
+ if ActiveRecord::Base.connection.table_exists? view_name
19
+ self.class_eval do
20
+ cattr_accessor :original_table_name
21
+
22
+ self.original_table_name = self.table_name
23
+ self.table_name = view_name
24
+ self.primary_key = :id
25
+
26
+ def self.new(*args)
27
+ object = super(*args)
28
+ object.id = nil # workaround for https://github.com/rails/rails/issues/5982
29
+ object
30
+ end
27
31
  end
28
32
  end
29
33
  end
30
- end
31
34
 
32
- def self.inherited(child)
33
- super
35
+ alias_method :multitenant_mysql_chained_inherited, :inherited
34
36
 
35
- model_name = child.to_s
36
- if Multitenant::Mysql.configs.models.include? model_name
37
- child.send :acts_as_tenant
38
- end
37
+ def inherited(child)
38
+ multitenant_mysql_chained_inherited(child)
39
+
40
+ model_name = child.to_s
41
+ if Multitenant::Mysql.configs.models.include? model_name
42
+ child.send :acts_as_tenant
43
+ end
39
44
 
40
- if Multitenant::Mysql.configs.tenant? child
41
- child.send :acts_as_tenants_bucket
45
+ if Multitenant::Mysql.configs.tenant? child
46
+ child.send :acts_as_tenants_bucket
47
+ end
42
48
  end
43
49
 
44
50
  end
51
+
45
52
  end
@@ -1,5 +1,5 @@
1
1
  module Multitenant
2
2
  module Mysql
3
- VERSION = "1.2.1"
3
+ VERSION = "1.2.2"
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  adapter: mysql2
2
2
  username: root
3
- password:
3
+ password: password
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multitenant-mysql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-02 00:00:00.000000000 Z
12
+ date: 2013-06-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 1.8.24
109
+ rubygems_version: 1.8.21
110
110
  signing_key:
111
111
  specification_version: 3
112
112
  summary: Add multi-tenancy to Rails application using MySql views