File: flow.rb

package info (click to toggle)
ruby-doorkeeper 5.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 992 kB
  • sloc: ruby: 4,644; makefile: 4
file content (44 lines) | stat: -rw-r--r-- 1,173 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true

module Doorkeeper
  module GrantFlow
    class Flow
      attr_reader :name, :grant_type_matches, :grant_type_strategy,
                  :response_type_matches, :response_type_strategy,
                  :response_mode_matches

      def initialize(name, **options)
        @name = name
        @grant_type_matches = options[:grant_type_matches]
        @grant_type_strategy = options[:grant_type_strategy]
        @response_type_matches = options[:response_type_matches]
        @response_type_strategy = options[:response_type_strategy]
        @response_mode_matches = options[:response_mode_matches]
      end

      def handles_grant_type?
        grant_type_matches.present?
      end

      def handles_response_type?
        response_type_matches.present?
      end

      def matches_grant_type?(value)
        grant_type_matches === value
      end

      def matches_response_type?(value)
        response_type_matches === value
      end

      def default_response_mode
        response_mode_matches[0]
      end

      def matches_response_mode?(value)
        response_mode_matches.include?(value)
      end
    end
  end
end