saasable 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -1,4 +1,7 @@
1
1
  module Saasable::Errors
2
2
  class MultipleSaasDocuments < StandardError; end
3
+ class NoSaasDocuments < StandardError; end
4
+
5
+ class MultipleSaasFound < StandardError; end
3
6
  class SaasNotFound < StandardError; end
4
7
  end
@@ -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
- unless Saasable::SaasDocument.saas_document.nil?
20
- @current_saas = Saasable::SaasDocument.saas_document.where(:hosts => request.host).first
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{saasable}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Rafael Gaspar}]
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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rafael Gaspar