aptible-rails 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2965a7abfefca337a2b105445f5f9df4591a3ca
4
- data.tar.gz: 482ff4c256f427a7ba575495c66f53e664d91933
3
+ metadata.gz: 7bedece438efef08d383ca8934a4ac8b5eba9c9a
4
+ data.tar.gz: de3005acca106a6367146199741f2a54ef9e1a97
5
5
  SHA512:
6
- metadata.gz: f7f145fcabee51960cd7f8be13ca195378eb0741c16a649aa976c26ab5d1eab67f1c1f75564665385a87a5f80c64de352dc48d7d36edc8da870e811311948e4f
7
- data.tar.gz: e5412d65d5655e041a3fbcfd1cd647af791e79f05dbe0f651b636597d4b430e017a8f9a4462fc7eeb8a1c34c581d1db52aff891d6bbbe17c5555cd661570efd4
6
+ metadata.gz: 52b49e260842abce4b9f72c785258a77d601c75136b5f97cd041454dffdb7edbbba301b54f4974d9f7a53243b4ec86760219252f8286cab72d6c874cf5f6916d
7
+ data.tar.gz: 3f84c5b183c18e6265eb22b36f27e9510080da55bf034fd6ead6181563144eab8b90a9a212623de26bece3d1dfb72efec148a057d74f68c332048e4807aeaa79
@@ -8,7 +8,9 @@ module Aptible
8
8
 
9
9
  included do
10
10
  helper_method :auth, :api, :current_aptible_user,
11
- :current_organization
11
+ :current_organization, :subscribed?,
12
+ :has_acccount?, :email_verified?,
13
+ :subscribed_and_verified?
12
14
  end
13
15
 
14
16
  def auth
@@ -29,6 +31,27 @@ module Aptible
29
31
  session[:organization_url] ||= auth.organizations.first.href
30
32
  url = [session[:organization_url], token: service_token]
31
33
  @current_organization ||= Aptible::Auth::Organization.find_by_url(*url)
34
+ rescue
35
+ false
36
+ end
37
+
38
+ # rubocop:disable PredicateName
39
+ def has_account?
40
+ current_organization && current_organization.accounts.any?
41
+ end
42
+ # rubocop:enable PredicateName
43
+
44
+ def subscribed?
45
+ @has_subscription ||= has_account? &&
46
+ current_organization.accounts.any?(&:has_subscription?)
47
+ end
48
+
49
+ def email_verified?
50
+ current_aptible_user && current_aptible_user.verified?
51
+ end
52
+
53
+ def subscribed_and_verified?
54
+ has_account? && subscribed? && email_verified?
32
55
  end
33
56
 
34
57
  def service_token
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module Rails
3
- VERSION = '0.3.1'
3
+ VERSION = '0.3.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptible-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-03 00:00:00.000000000 Z
11
+ date: 2014-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_config