Module: Oare::Gateway

Defined in:
lib/extensions/gateway.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/extensions/gateway.rb', line 3

def method_missing(method, *args, &block)
  collection = ::ActiveResource::Base.oauth_enabled_classes
  if collection.keys.include? method
    constant = collection[method].join('::').constantize
    constant.access_token = self.access_token
    #Rails.logger.info  constant.access_token.inspect
    #Rails.logger.info  ::ActiveResource::Base.access_token.inspect
    #sleep 20
    constant
  else
    super(method, *args, &block)
  end
end

Instance Method Details

#access_tokenObject



17
18
19
20
21
22
23
24
25
# File 'lib/extensions/gateway.rb', line 17

def access_token
  ## This method assumes that the Gateway Model has the fields/methods for:
  #  oauth_token        : string,
  #  oauth_token_secret : string,
  #  consumer           : consumer token
  #

  OAuth::AccessToken.new(consumer, oauth_token, oauth_token_secret)
end