Class: Signatory::Credentials
- Inherits:
-
Object
- Object
- Signatory::Credentials
- Defined in:
- lib/signatory/credentials.rb
Instance Attribute Summary collapse
-
#access_secret ⇒ Object
Returns the value of attribute access_secret.
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#key ⇒ Object
Returns the value of attribute key.
-
#secret ⇒ Object
Returns the value of attribute secret.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key, secret, access_token, access_secret) ⇒ Credentials
constructor
A new instance of Credentials.
- #token ⇒ Object
Constructor Details
#initialize(key, secret, access_token, access_secret) ⇒ Credentials
Returns a new instance of Credentials.
5 6 7 |
# File 'lib/signatory/credentials.rb', line 5 def initialize(key, secret, access_token, access_secret) @key, @secret, @access_token, @access_secret = key, secret, access_token, access_secret end |
Instance Attribute Details
#access_secret ⇒ Object
Returns the value of attribute access_secret.
3 4 5 |
# File 'lib/signatory/credentials.rb', line 3 def access_secret @access_secret end |
#access_token ⇒ Object
Returns the value of attribute access_token.
3 4 5 |
# File 'lib/signatory/credentials.rb', line 3 def access_token @access_token end |
#key ⇒ Object
Returns the value of attribute key.
3 4 5 |
# File 'lib/signatory/credentials.rb', line 3 def key @key end |
#secret ⇒ Object
Returns the value of attribute secret.
3 4 5 |
# File 'lib/signatory/credentials.rb', line 3 def secret @secret end |
Class Method Details
.load(source) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/signatory/credentials.rb', line 9 def self.load(source) h = if source.respond_to?(:read) YAML.load(source) elsif source.is_a?(Hash) source.inject({}){ |acc, (k, v)| acc[k.to_s] = v; acc} end new(h['key'], h['secret'], h['access_token'], h['access_secret']) end |
Instance Method Details
#token ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/signatory/credentials.rb', line 19 def token @consumer ||= OAuth::Consumer.new(key, secret, { :site => 'https://rightsignature.com', :scheme => :header, :http_method => :post, :request_token_path => "/oauth/request_token", :access_token_path => "/oauth/access_token", :authorize_path => "/oauth/authorize" }) @token ||= OAuth::AccessToken.new( @consumer, access_token, access_secret ) end |