Module: Rails::GraphQL::Helpers::WithEvents::FixedTypes

Defined in:
lib/rails/graphql/helpers/with_events.rb

Overview

Helper module to define static list of valid event types

Instance Method Summary collapse

Instance Method Details

#event_types(*list, append: false, expose: false) ⇒ Object

Set or get the list of possible event types when attaching events



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rails/graphql/helpers/with_events.rb', line 33

def event_types(*list, append: false, expose: false)
  return (defined?(@event_types) && @event_types.presence) ||
    superclass.try(:event_types) || EMPTY_ARRAY if list.blank?

  new_list = list.flatten.compact.map(&:to_sym)
  new_list = event_types + new_list if append

  @event_types = new_list.uniq.freeze
  expose_events!(*list) if expose
  @event_types
end