Module: PactBroker::Api::Resources::Authorization

Included in:
BaseResource
Defined in:
lib/pact_broker/api/resources/authorization.rb

Instance Method Summary collapse

Instance Method Details

#actionObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/pact_broker/api/resources/authorization.rb', line 5

def action
  if read_methods.include?(request.method)
    :read
  elsif update_methods.include?(request.method)
    :update
  elsif create_methods.include?(request.method)
    :create
  elsif delete_methods.include?(request.method)
    :delete
  else
    raise "Cannot map #{request.method} to an action"
  end
end

#create_methodsObject



27
28
29
# File 'lib/pact_broker/api/resources/authorization.rb', line 27

def create_methods
  %w{POST PUT}
end

#delete_methodsObject



31
32
33
# File 'lib/pact_broker/api/resources/authorization.rb', line 31

def delete_methods
  %w{DELETE}
end

#read_methodsObject



19
20
21
# File 'lib/pact_broker/api/resources/authorization.rb', line 19

def read_methods
  %w{GET HEAD OPTIONS}
end

#update_methodsObject



23
24
25
# File 'lib/pact_broker/api/resources/authorization.rb', line 23

def update_methods
  %w{PUT PATCH}
end