Module: Rails::GraphQL::Helpers::WithCallbacks::Setup
- Defined in:
- lib/rails/graphql/helpers/with_callbacks.rb
Overview
Add the ability to set up filters before the actual execution of the callback
Instance Method Summary collapse
-
#default_exclusive(value, **xargs) ⇒ Object
Set the default
exclusive
value for the givenfor
event names. -
#default_exclusive?(event_name) ⇒ Boolean
Check if the given
event_name
should be thread as exclusive or non-exclusive by default. -
#event_filters ⇒ Object
Return the list of event filters hooks.
-
#event_types ⇒ Object
Use the default list of event types when it’s not set.
Instance Method Details
#default_exclusive(value, **xargs) ⇒ Object
Set the default exclusive
value for the given for
event names
38 39 40 41 42 |
# File 'lib/rails/graphql/helpers/with_callbacks.rb', line 38 def default_exclusive(value, **xargs) new_values = Array.wrap(xargs.fetch(:for)).map(&:to_sym).product([value]).to_h @callback_exclusive ||= superclass.try(:callback_exclusive)&.dup || {} @callback_exclusive.merge!(new_values) end |
#default_exclusive?(event_name) ⇒ Boolean
Check if the given event_name
should be thread as exclusive or non-exclusive by default
46 47 48 49 50 51 52 |
# File 'lib/rails/graphql/helpers/with_callbacks.rb', line 46 def default_exclusive?(event_name) if defined?(@callback_exclusive) @callback_exclusive[event_name] else superclass.try(:default_exclusive?, event_name) end end |
#event_filters ⇒ Object
Return the list of event filters hooks
32 33 34 35 |
# File 'lib/rails/graphql/helpers/with_callbacks.rb', line 32 def event_filters return @event_filters if defined? @event_filters superclass.try(:event_filters) || EMPTY_HASH end |
#event_types ⇒ Object
Use the default list of event types when it’s not set
27 28 29 |
# File 'lib/rails/graphql/helpers/with_callbacks.rb', line 27 def event_types(*, **) (super if defined? super).presence || DEFAULT_EVENT_TYPES end |