Module: Playapi::Configurable
Constant Summary collapse
- DEFAULT_CONNECTION_MIDDLEWARE =
[ Faraday::Request::Multipart, Faraday::Request::UrlEncoded, FaradayMiddleware::ParseJson ]
Instance Attribute Summary collapse
-
#client_id ⇒ Object
writeonly
Sets the attribute client_id.
-
#client_secret ⇒ Object
writeonly
Sets the attribute client_secret.
-
#connection_middleware ⇒ Object
Returns the value of attribute connection_middleware.
-
#connection_options ⇒ Object
Returns the value of attribute connection_options.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#identity_map ⇒ Object
Returns the value of attribute identity_map.
-
#oauth_token ⇒ Object
writeonly
Sets the attribute oauth_token.
Class Method Summary collapse
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
- #credentials? ⇒ Boolean
- #reset! ⇒ Object (also: #setup)
Instance Attribute Details
#client_id=(value) ⇒ Object (writeonly)
Sets the attribute client_id
4 5 6 |
# File 'lib/playapi/configurable.rb', line 4 def client_id=(value) @client_id = value end |
#client_secret=(value) ⇒ Object (writeonly)
Sets the attribute client_secret
4 5 6 |
# File 'lib/playapi/configurable.rb', line 4 def client_secret=(value) @client_secret = value end |
#connection_middleware ⇒ Object
Returns the value of attribute connection_middleware.
5 6 7 |
# File 'lib/playapi/configurable.rb', line 5 def connection_middleware @connection_middleware end |
#connection_options ⇒ Object
Returns the value of attribute connection_options.
5 6 7 |
# File 'lib/playapi/configurable.rb', line 5 def @connection_options end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
5 6 7 |
# File 'lib/playapi/configurable.rb', line 5 def endpoint @endpoint end |
#identity_map ⇒ Object
Returns the value of attribute identity_map.
5 6 7 |
# File 'lib/playapi/configurable.rb', line 5 def identity_map @identity_map end |
#oauth_token=(value) ⇒ Object (writeonly)
Sets the attribute oauth_token
4 5 6 |
# File 'lib/playapi/configurable.rb', line 4 def oauth_token=(value) @oauth_token = value end |
Class Method Details
.keys ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/playapi/configurable.rb', line 17 def keys @keys ||= [ :client_id, :client_secret, :oauth_token, :endpoint, :token_secret, :connection_options, :identity_map, :connection_middleware, ] end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block
36 37 38 39 40 |
# File 'lib/playapi/configurable.rb', line 36 def configure yield self validate_credential_type! self end |
#credentials? ⇒ Boolean
43 44 45 |
# File 'lib/playapi/configurable.rb', line 43 def credentials? credentials.values.all? end |
#reset! ⇒ Object Also known as: setup
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/playapi/configurable.rb', line 47 def reset! defaultz = {client_id: "F1Ox4PEhf1eiNGRge7kscIRgay1mh8cbi2zruIC1OI", client_secret: "xLeR0lXVdEtfjwP04w4FJKZm8KxS97Qg5o8Xbyw3JeE", oauth_token: "KqoCXCoyhrJTyGFtCYmiUcWModkTYBILiMHyKGQCBYg", token_secret: "b63V8SyY9ip8yigE5o6bsf3HFyza1wRfLnl3HyhhPz4", endpoint: "http://api.papi.io/"} # we can probably chuck conn_ops conn_ops = { :connection_options => {:headers => {:accept => "application/json", :user_agent => "PlayAPI Gem 0.1.1"}, :ssl => {:verify => false}} } #defaultz.merge!(conn_ops) defaultz.merge!(:connection_middleware => DEFAULT_CONNECTION_MIDDLEWARE) Playapi::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", defaultz[key]) end self end |