Class: CloudKit::OAuthStore
Overview
An OAuthStore is a thin abstraction around CloudKit::Store, providing consistent collection names, and allowing automatic upgrades in later releases if needed.
Constant Summary collapse
- @@store =
nil
Instance Method Summary collapse
-
#delete(uri, options = {}) ⇒ Object
:nodoc:.
-
#get(uri, options = {}) ⇒ Object
:nodoc:.
-
#initialize ⇒ OAuthStore
constructor
Initialize a Store for use with OAuth middleware.
-
#load_static_consumer ⇒ Object
Load the static consumer entity if it does not already exist.
-
#post(uri, options = {}) ⇒ Object
:nodoc:.
-
#put(uri, options = {}) ⇒ Object
:nodoc:.
-
#version ⇒ Object
Return the version number for this store.
Constructor Details
#initialize ⇒ OAuthStore
Initialize a Store for use with OAuth middleware. Load the static consumer resource if it does not exist.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/cloudkit/oauth_store.rb', line 11 def initialize @@store = Store.new( :collections => [ :cloudkit_oauth_nonces, :cloudkit_oauth_tokens, :cloudkit_oauth_request_tokens, :cloudkit_oauth_consumers] ) unless @@store load_static_consumer end |
Instance Method Details
#delete(uri, options = {}) ⇒ Object
:nodoc:
34 35 36 |
# File 'lib/cloudkit/oauth_store.rb', line 34 def delete(uri, ={}) #:nodoc: @@store.delete(CloudKit::URI.new(uri), ) end |
#get(uri, options = {}) ⇒ Object
:nodoc:
22 23 24 |
# File 'lib/cloudkit/oauth_store.rb', line 22 def get(uri, ={}) #:nodoc: @@store.get(CloudKit::URI.new(uri), ) end |
#load_static_consumer ⇒ Object
Load the static consumer entity if it does not already exist. See the OAuth Discovery spec for more info on static consumers.
43 44 45 46 |
# File 'lib/cloudkit/oauth_store.rb', line 43 def load_static_consumer json = JSON.generate(:secret => '') @@store.put(CloudKit::URI.new('/cloudkit_oauth_consumers/cloudkitconsumer'), :json => json) end |
#post(uri, options = {}) ⇒ Object
:nodoc:
26 27 28 |
# File 'lib/cloudkit/oauth_store.rb', line 26 def post(uri, ={}) #:nodoc: @@store.post(CloudKit::URI.new(uri), ) end |
#put(uri, options = {}) ⇒ Object
:nodoc:
30 31 32 |
# File 'lib/cloudkit/oauth_store.rb', line 30 def put(uri, ={}) #:nodoc: @@store.put(CloudKit::URI.new(uri), ) end |
#version ⇒ Object
Return the version number for this store.
39 |
# File 'lib/cloudkit/oauth_store.rb', line 39 def version; 1; end |