Class: ActionController::TestRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/oauth/client/action_controller_request.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.use_oauth=(value) ⇒ Object (writeonly)

Sets the attribute use_oauth

Parameters:

  • value

    the value to set the attribute use_oauth to.



30
31
32
# File 'lib/oauth/client/action_controller_request.rb', line 30

def use_oauth=(value)
  @use_oauth = value
end

Class Method Details

.use_oauth?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/oauth/client/action_controller_request.rb', line 33

def self.use_oauth?
  @use_oauth
end

Instance Method Details

#apply_oauth!Object



46
47
48
49
50
51
52
53
54
# File 'lib/oauth/client/action_controller_request.rb', line 46

def apply_oauth!
  return unless ActionController::TestRequest.use_oauth? && @oauth_options

  @oauth_helper = OAuth::Client::Helper.new(self,
                                            @oauth_options.merge(request_uri: (respond_to?(:fullpath) ? fullpath : request_uri)))
  @oauth_helper.amend_user_agent_header(env)

  send("set_oauth_#{@oauth_options[:scheme]}")
end

#configure_oauth(consumer = nil, token = nil, options = {}) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/oauth/client/action_controller_request.rb', line 37

def configure_oauth(consumer = nil, token = nil, options = {})
  @oauth_options = { consumer: consumer,
                     token: token,
                     scheme: "header",
                     signature_method: nil,
                     nonce: nil,
                     timestamp: nil }.merge(options)
end

#set_oauth_headerObject



56
57
58
# File 'lib/oauth/client/action_controller_request.rb', line 56

def set_oauth_header
  env["Authorization"] = @oauth_helper.header
end

#set_oauth_parametersObject



60
61
62
63
# File 'lib/oauth/client/action_controller_request.rb', line 60

def set_oauth_parameters
  @query_parameters = @oauth_helper.parameters_with_oauth
  @query_parameters.merge!(oauth_signature: @oauth_helper.signature)
end

#set_oauth_query_stringObject



65
# File 'lib/oauth/client/action_controller_request.rb', line 65

def set_oauth_query_string; end