bsm-sso-client 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,15 +29,22 @@ class Bsm::Sso::Client::AbstractResource < Hash
29
29
  # @param [Hash] params, request params - see Excon::Connection#request
30
30
  # @return [Bsm::Sso::Client::AbstractResource] fetches object from remote
31
31
  def get(path, params = {})
32
- params = params.merge(:path => path)
32
+ params[:query] ||= params.delete(:params)
33
+ collection = params.delete(:collection)
34
+ params = params.merge(:path => path)
33
35
  params[:headers] = (params[:headers] || {}).merge(headers)
34
- response = site.get(params)
35
- return nil unless response.status == 200
36
36
 
37
- instance = new ActiveSupport::JSON.decode(response.body)
38
- instance if instance.id
37
+ response = site.get(params)
38
+ return (collection ? [] : nil) unless response.status == 200
39
+
40
+ result = ActiveSupport::JSON.decode(response.body)
41
+ result = Array.wrap(result).map do |record|
42
+ instance = new(record)
43
+ instance if instance.id
44
+ end.compact
45
+ collection ? result : result.first
39
46
  rescue MultiJson::DecodeError
40
- nil
47
+ collection ? [] : nil
41
48
  end
42
49
 
43
50
  end
@@ -2,6 +2,10 @@ class Bsm::Sso::Client::User < Bsm::Sso::Client::AbstractResource
2
2
 
3
3
  class << self
4
4
 
5
+ def all(options={})
6
+ get("/users", options.reverse_merge(:expects => [200, 404, 422], :collection => true))
7
+ end
8
+
5
9
  def sso_find(id)
6
10
  Bsm::Sso::Client.cache_store.fetch "users:#{id}", :expires_in => Bsm::Sso::Client.expire_after do
7
11
  get "/users/#{id}", :expects => [200, 404, 422]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bsm-sso-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
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: 2012-08-23 00:00:00.000000000 Z
12
+ date: 2012-08-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -188,7 +188,7 @@ dependencies:
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0'
190
190
  - !ruby/object:Gem::Dependency
191
- name: sqlite3-ruby
191
+ name: sqlite3
192
192
  requirement: !ruby/object:Gem::Requirement
193
193
  none: false
194
194
  requirements:
@@ -250,4 +250,3 @@ signing_key:
250
250
  specification_version: 3
251
251
  summary: BSM's internal SSO client
252
252
  test_files: []
253
- has_rdoc: