Class: GraphqlDevise::MountMethod::OperationSanitizer

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql_devise/mount_method/operation_sanitizer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(default:, only:, skipped:) ⇒ OperationSanitizer

Returns a new instance of OperationSanitizer.



14
15
16
17
18
# File 'lib/graphql_devise/mount_method/operation_sanitizer.rb', line 14

def initialize(default:, only:, skipped:)
  @default = default
  @only    = only
  @skipped = skipped
end

Class Method Details

.call(default:, only:, skipped:) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/graphql_devise/mount_method/operation_sanitizer.rb', line 6

def self.call(default:, only:, skipped:)
  new(
    default: default,
    only:    only,
    skipped: skipped
  ).call
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
# File 'lib/graphql_devise/mount_method/operation_sanitizer.rb', line 20

def call
  operations = if @only.present?
    @default.slice(*@only)
  elsif @skipped.present?
    @default.except(*@skipped)
  else
    @default
  end
end