Class: GraphqlRails::Router::EventRoute
- Inherits:
-
Object
- Object
- GraphqlRails::Router::EventRoute
- Defined in:
- lib/graphql_rails/router/event_route.rb
Overview
stores subscription type graphql action info
Instance Attribute Summary collapse
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#scope_names ⇒ Object
readonly
Returns the value of attribute scope_names.
-
#subscription_class ⇒ Object
readonly
Returns the value of attribute subscription_class.
Instance Method Summary collapse
- #event? ⇒ Boolean
- #field_options ⇒ Object
-
#initialize(name, subscription_class: nil, groups: nil, scope_names: [], **options) ⇒ EventRoute
constructor
A new instance of EventRoute.
- #mutation? ⇒ Boolean
- #query? ⇒ Boolean
- #show_in_group?(group_name) ⇒ Boolean
- #subscription ⇒ Object
Constructor Details
#initialize(name, subscription_class: nil, groups: nil, scope_names: [], **options) ⇒ EventRoute
Returns a new instance of EventRoute.
11 12 13 14 15 16 17 |
# File 'lib/graphql_rails/router/event_route.rb', line 11 def initialize(name, subscription_class: nil, groups: nil, scope_names: [], **) @name = name.to_s.camelize(:lower) @module_name = [:module].to_s @groups = groups @subscription_class = subscription_class @scope_names = scope_names end |
Instance Attribute Details
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
9 10 11 |
# File 'lib/graphql_rails/router/event_route.rb', line 9 def groups @groups end |
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
9 10 11 |
# File 'lib/graphql_rails/router/event_route.rb', line 9 def module_name @module_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/graphql_rails/router/event_route.rb', line 9 def name @name end |
#scope_names ⇒ Object (readonly)
Returns the value of attribute scope_names.
9 10 11 |
# File 'lib/graphql_rails/router/event_route.rb', line 9 def scope_names @scope_names end |
#subscription_class ⇒ Object (readonly)
Returns the value of attribute subscription_class.
9 10 11 |
# File 'lib/graphql_rails/router/event_route.rb', line 9 def subscription_class @subscription_class end |
Instance Method Details
#event? ⇒ Boolean
47 48 49 |
# File 'lib/graphql_rails/router/event_route.rb', line 47 def event? true end |
#field_options ⇒ Object
25 26 27 |
# File 'lib/graphql_rails/router/event_route.rb', line 25 def { subscription: subscription } end |
#mutation? ⇒ Boolean
39 40 41 |
# File 'lib/graphql_rails/router/event_route.rb', line 39 def mutation? false end |
#query? ⇒ Boolean
43 44 45 |
# File 'lib/graphql_rails/router/event_route.rb', line 43 def query? false end |
#show_in_group?(group_name) ⇒ Boolean
19 20 21 22 23 |
# File 'lib/graphql_rails/router/event_route.rb', line 19 def show_in_group?(group_name) return true if groups.nil? || groups.empty? groups.include?(group_name&.to_sym) end |
#subscription ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/graphql_rails/router/event_route.rb', line 29 def subscription if subscription_class.present? subscription_class.is_a?(String) ? Object.const_get(subscription_class) : subscription_class else klass_name = ['subscriptions/', name.underscore, 'subscription'].join('_').camelize Object.const_get(klass_name) end end |