Class: GraphqlDevise::MountMethod::OperationSanitizer
- Inherits:
-
Object
- Object
- GraphqlDevise::MountMethod::OperationSanitizer
- Defined in:
- lib/graphql_devise/mount_method/operation_sanitizer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(default:, only:, skipped:, allow_destroy: false) ⇒ OperationSanitizer
constructor
A new instance of OperationSanitizer.
Constructor Details
#initialize(default:, only:, skipped:, allow_destroy: false) ⇒ OperationSanitizer
Returns a new instance of OperationSanitizer.
15 16 17 18 19 20 |
# File 'lib/graphql_devise/mount_method/operation_sanitizer.rb', line 15 def initialize(default:, only:, skipped:, allow_destroy: false) @default = default @only = only @skipped = skipped @allow_destroy = allow_destroy end |
Class Method Details
.call(default:, only:, skipped:, allow_destroy: false) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/graphql_devise/mount_method/operation_sanitizer.rb', line 6 def self.call(default:, only:, skipped:, allow_destroy: false) new( default: default, only: only, skipped: skipped, allow_destroy: allow_destroy ).call end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/graphql_devise/mount_method/operation_sanitizer.rb', line 22 def call # When `only` is provided the list is explicit, so `allow_destroy` operations are included # (and never warned about) whenever they are named in it. return @default.slice(*@only) if @only.present? selected = @skipped.present? ? @default.except(*@skipped) : @default reject_allow_destroy(selected) end |