Class: CloudKit::OAuthStore
Overview
An OAuthStore is a thin abstraction around CloudKit::Store, providing consistent collection names, and allowing automatic migrations 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(uri = nil) ⇒ 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:.
-
#reset! ⇒ Object
:nodoc:.
-
#version ⇒ Object
Return the version number for this store.
Constructor Details
#initialize(uri = nil) ⇒ 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(uri=nil) @@store = Store.new( :collections => [ :cloudkit_oauth_nonces, :cloudkit_oauth_tokens, :cloudkit_oauth_request_tokens, :cloudkit_oauth_consumers], :adapter => SQLAdapter.new(uri)) 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(uri, ) end |
#get(uri, options = {}) ⇒ Object
:nodoc:
22 23 24 |
# File 'lib/cloudkit/oauth_store.rb', line 22 def get(uri, ={}) #:nodoc: @@store.get(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.
47 48 49 50 |
# File 'lib/cloudkit/oauth_store.rb', line 47 def load_static_consumer json = JSON.generate(:secret => '') @@store.put('/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(uri, ) end |
#put(uri, options = {}) ⇒ Object
:nodoc:
30 31 32 |
# File 'lib/cloudkit/oauth_store.rb', line 30 def put(uri, ={}) #:nodoc: @@store.put(uri, ) end |
#reset! ⇒ Object
:nodoc:
38 39 40 |
# File 'lib/cloudkit/oauth_store.rb', line 38 def reset! #:nodoc: @@store.reset! end |
#version ⇒ Object
Return the version number for this store.
43 |
# File 'lib/cloudkit/oauth_store.rb', line 43 def version; 1; end |