Top Level Namespace

Defined Under Namespace

Modules: Lasso

Instance Method Summary collapse

Instance Method Details

#define_oauth_one(parent) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/lasso/model/oauth_one.rb', line 1

def define_oauth_one(parent)
  eval <<OAUTHONE
    class OAuthOne#{parent} < #{parent}

      alias_attribute :oauth_token,        :token_a
      alias_attribute :oauth_token_secret, :token_b

      validates_presence_of :oauth_token, :oauth_token_secret

      def client
        @client ||= OAuth::Consumer.new(config(:key), config(:secret), :site => config(:site), :request_token_path => config(:request_token_path), :authorize_path => config(:authorize_path), :access_token_path => config(:access_token_path))
      end

      def access
        @access ||= OAuth::AccessToken.new(client, oauth_token, oauth_token_secret)
      end

    end
OAUTHONE
end

#define_oauth_two(parent) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/lasso/model/oauth_two.rb', line 1

def define_oauth_two(parent)
  eval <<OAUTHTWO
    class OAuthTwo#{parent} < #{parent}

      alias_attribute :access_token,  :token_a
      alias_attribute :refresh_token, :token_b
  
      validates_presence_of :access_token
  
      def client
        @client ||= OAuth2::Client.new(config(:key), config(:secret), :site => config(:site), :authorize_path => config(:authorize_path), :type => 'web_server', :access_token_path => config(:access_token_path))
      end
  
      def access
        @access ||= OAuth2::AccessToken.new(client, access_token, refresh_token)
      end
    end
OAUTHTWO
end