Module: Yammer::Configurable
Constant Summary collapse
- ENDPOINT =
'https://www.yammer.com'
- HTTP_ADAPTER =
Yammer::HttpAdapter
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#connection_options ⇒ Object
Returns the value of attribute connection_options.
-
#default_headers ⇒ Object
Returns the value of attribute default_headers.
-
#http_adapter ⇒ Object
Returns the value of attribute http_adapter.
-
#site_url ⇒ Object
Returns the value of attribute site_url.
Class Method Summary collapse
-
.default_options ⇒ Hash
Return a hash with the default options.
-
.keys ⇒ Array<String>
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
-
#disable_logging ⇒ Object
-
#enable_logging(output = 'stdout') ⇒ Object
-
#options ⇒ Hash
-
#reset! ⇒ Object
-
#with_logging(output) {|_self| ... } ⇒ Object
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
23 24 25 |
# File 'lib/yammer/configurable.rb', line 23 def access_token @access_token end |
#client_id ⇒ Object
Returns the value of attribute client_id.
23 24 25 |
# File 'lib/yammer/configurable.rb', line 23 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
23 24 25 |
# File 'lib/yammer/configurable.rb', line 23 def client_secret @client_secret end |
#connection_options ⇒ Object
Returns the value of attribute connection_options.
23 24 25 |
# File 'lib/yammer/configurable.rb', line 23 def @connection_options end |
#default_headers ⇒ Object
Returns the value of attribute default_headers.
23 24 25 |
# File 'lib/yammer/configurable.rb', line 23 def default_headers @default_headers end |
#http_adapter ⇒ Object
Returns the value of attribute http_adapter.
23 24 25 |
# File 'lib/yammer/configurable.rb', line 23 def http_adapter @http_adapter end |
#site_url ⇒ Object
Returns the value of attribute site_url.
23 24 25 |
# File 'lib/yammer/configurable.rb', line 23 def site_url @site_url end |
Class Method Details
.default_options ⇒ Hash
Return a hash with the default options
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/yammer/configurable.rb', line 28 def self. { :site_url => ENDPOINT, :client_id => ENV['YAMMER_CLIENT_ID'], :client_secret => ENV['YAMMER_CLIENT_SECRET'], :access_token => ENV['YAMMER_ACCESS_TOKEN'], :http_adapter => HTTP_ADAPTER, :connection_options => { :max_redirects => 5, :verify_ssl => true }, :default_headers => { 'Accept' => 'application/json', 'User-Agent' => "Yammer Ruby Gem #{Yammer::Version}" } } end |
.keys ⇒ Array<String>
44 45 46 |
# File 'lib/yammer/configurable.rb', line 44 def self.keys self..keys end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block
61 62 63 64 |
# File 'lib/yammer/configurable.rb', line 61 def configure yield self if block_given? self end |
#disable_logging ⇒ Object
70 71 72 |
# File 'lib/yammer/configurable.rb', line 70 def disable_logging self.http_adapter.log = nil end |
#enable_logging(output = 'stdout') ⇒ Object
66 67 68 |
# File 'lib/yammer/configurable.rb', line 66 def enable_logging(output='stdout') self.http_adapter.log = output end |
#options ⇒ Hash
49 50 51 |
# File 'lib/yammer/configurable.rb', line 49 def Hash[Yammer::Configurable.keys.map{|key| [key, instance_variable_get(:"@#{key}")]}] end |
#reset! ⇒ Object
53 54 55 56 57 58 |
# File 'lib/yammer/configurable.rb', line 53 def reset! Yammer::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", Yammer::Configurable.[key.to_sym]) end self end |
#with_logging(output) {|_self| ... } ⇒ Object
74 75 76 77 78 79 |
# File 'lib/yammer/configurable.rb', line 74 def with_logging(output) cached_output = self.http_adapter.log enable_logging(output) yield self if block_given? self.http_adapter.log = cached_output end |