aptible-auth 0.3.2 → 0.4.0

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: de55501fb9d9bba196c315fa4c9e3c4bbc5db1a5
4
- data.tar.gz: 625a173e5f59d42eea65758ab64d64b86152bb29
3
+ metadata.gz: ac454bc3eef567b367a3eaa632816d61c2d15eb1
4
+ data.tar.gz: 060414e6cd796507a114fec0da56b739e3c263fc
5
5
  SHA512:
6
- metadata.gz: a6f702280e3e3481a521b0fac4b3965f6bdd6a4b8fad15d95520b0399a69d7c214d142f6f91ac2dc9a9c81495574d301c4b5ecc6540da72a47ad006e366e572a
7
- data.tar.gz: 67aaf8c6ba45fb3f15c22b3955545600398ecbd3e259d68581e335131619f1270baa7544414296ff06d8af8bb9cdb9cb2c567f311d3477cef810d50c3d08632c
6
+ metadata.gz: c3e20eb1f2657602b71b3f957b29beb37f47b09f92d8948914d10a298b94decc987909e6918d3a8fa719da5d7e1ba55e18fd9a78b7b1ac7faa904e853d2d1bcc
7
+ data.tar.gz: 0f419c0662ff23d311fb5251d4bb65f835f9406fd88153b3ee1b8fe87df373f115b6bbad034d27202507bfe7f8484323ea6c995f241afc85f55c28b97dafc4b7
@@ -6,7 +6,7 @@ require 'English'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'aptible-auth'
9
- spec.version = '0.3.2'
9
+ spec.version = '0.4.0'
10
10
  spec.authors = ['Frank Macreery']
11
11
  spec.email = ['frank@macreery.com']
12
12
  spec.description = 'Ruby client for auth.aptible.com'
@@ -1,4 +1,5 @@
1
1
  module Aptible
2
2
  class Auth::Client < Auth::Resource
3
+ belongs_to :user
3
4
  end
4
5
  end
@@ -1,4 +1,6 @@
1
1
  module Aptible
2
2
  class Auth::Membership < Auth::Resource
3
+ belongs_to :role
4
+ belongs_to :user
3
5
  end
4
6
  end
@@ -12,17 +12,17 @@ module Aptible
12
12
  end
13
13
 
14
14
  def self.all(options = {})
15
- resource = new(options).find_by_url(collection_url)
15
+ resource = find_by_url(collection_url, options)
16
16
  resource.send(basename).entries
17
17
  end
18
18
 
19
- def self.find(id)
20
- find_by_url("#{collection_url}/#{id}")
19
+ def self.find(id, options = {})
20
+ find_by_url("#{collection_url}/#{id}", options)
21
21
  end
22
22
 
23
- def self.find_by_url(url)
23
+ def self.find_by_url(url, options = {})
24
24
  # REVIEW: Should exception be raised if return type mismatch?
25
- new.find_by_url(url)
25
+ new(options).find_by_url(url)
26
26
  rescue
27
27
  nil
28
28
  end
@@ -40,6 +40,17 @@ module Aptible
40
40
  end
41
41
  # rubocop:enable PredicateName
42
42
 
43
+ def self.belongs_to(relation)
44
+ define_method relation do
45
+ get unless loaded
46
+ if (memoized = instance_variable_get("@#{relation}"))
47
+ memoized
48
+ else
49
+ instance_variable_set("@#{relation}", links[relation].get)
50
+ end
51
+ end
52
+ end
53
+
43
54
  private
44
55
 
45
56
  def self.define_has_many_getter(relation)
@@ -1,5 +1,7 @@
1
1
  module Aptible
2
2
  class Auth::Role < Auth::Resource
3
+ belongs_to :organization
4
+
3
5
  def privileged?
4
6
  !!attributes['privileged']
5
7
  end
@@ -1,4 +1,5 @@
1
1
  module Aptible
2
2
  class Auth::Session < Auth::Resource
3
+ belongs_to :user
3
4
  end
4
5
  end
@@ -11,7 +11,7 @@ describe Aptible::Auth::Resource do
11
11
  describe '.find' do
12
12
  it 'should call find_by_url' do
13
13
  url = 'https://auth.aptible.com/roles/42'
14
- expect(Aptible::Auth::Role).to receive(:find_by_url).with url
14
+ expect(Aptible::Auth::Role).to receive(:find_by_url).with url, {}
15
15
  Aptible::Auth::Role.find(42)
16
16
  end
17
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptible-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
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-03-10 00:00:00.000000000 Z
11
+ date: 2014-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_config