saasable 0.1.0 → 0.1.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.
- data/VERSION +1 -1
- data/lib/saasable/errors.rb +3 -0
- data/lib/saasable/saas_document.rb +2 -2
- data/lib/saasable/scoped_controller.rb +15 -2
- data/saasable.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/saasable/errors.rb
CHANGED
@@ -2,8 +2,8 @@ module Saasable::SaasDocument
|
|
2
2
|
@saas_document = nil
|
3
3
|
|
4
4
|
def self.included klass
|
5
|
-
if @saas_document and @saas_document != klass
|
6
|
-
raise Saasable::Errors::MultipleSaasDocuments, "you can only have one Saasable::SaasDocument"
|
5
|
+
if @saas_document and @saas_document.name != klass.name
|
6
|
+
raise Saasable::Errors::MultipleSaasDocuments, "you can only have one Saasable::SaasDocument"
|
7
7
|
else
|
8
8
|
@saas_document = klass
|
9
9
|
end
|
@@ -16,8 +16,21 @@ module Saasable::ScopedController
|
|
16
16
|
|
17
17
|
private
|
18
18
|
def fetch_current_saas
|
19
|
-
|
20
|
-
|
19
|
+
if Saasable::SaasDocument.saas_document.nil?
|
20
|
+
if Rails.env.production?
|
21
|
+
raise Saasable::Errors::NoSaasDocuments, "you need to set one Saasable::SaasDocument"
|
22
|
+
else
|
23
|
+
return @current_saas = nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
possible_saas = Saasable::SaasDocument.saas_document.where(:hosts => request.host)
|
28
|
+
if possible_saas.empty?
|
29
|
+
raise Saasable::Errors::SaasNotFound, "no Saasable::SaasDocument found for the host: \"#{request.host}\""
|
30
|
+
elsif possible_saas.count > 1
|
31
|
+
raise Saasable::Errors::MultipleSaasFound, "more then 1 Saasable::SaasDocument found for the host: \"#{request.host}\""
|
32
|
+
else
|
33
|
+
@current_saas = possible_saas.first
|
21
34
|
end
|
22
35
|
end
|
23
36
|
|
data/saasable.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saasable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rafael Gaspar
|