Class: GraphqlRails::Router::Route
- Inherits:
-
Object
- Object
- GraphqlRails::Router::Route
- Defined in:
- lib/graphql_rails/router/route.rb
Overview
Generic class for any type graphql action. Should not be used directly
Direct Known Subclasses
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.
-
#on ⇒ Object
readonly
Returns the value of attribute on.
-
#relative_path ⇒ Object
readonly
Returns the value of attribute relative_path.
-
#scope_names ⇒ Object
readonly
Returns the value of attribute scope_names.
Instance Method Summary collapse
- #collection? ⇒ Boolean
- #field_options ⇒ Object
-
#initialize(name, on:, to: '', groups: nil, scope_names: [], **options) ⇒ Route
constructor
rubocop:disable Metrics/ParameterLists.
- #path ⇒ Object
- #show_in_group?(group_name) ⇒ Boolean
Constructor Details
#initialize(name, on:, to: '', groups: nil, scope_names: [], **options) ⇒ Route
rubocop:disable Metrics/ParameterLists
12 13 14 15 16 17 18 19 20 |
# File 'lib/graphql_rails/router/route.rb', line 12 def initialize(name, on:, to: '', groups: nil, scope_names: [], **) # rubocop:disable Metrics/ParameterLists @name = name.to_s.camelize(:lower) @module_name = [:module].to_s @function = [:function] @groups = groups @relative_path = to @on = on.to_sym @scope_names = scope_names end |
Instance Attribute Details
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
10 11 12 |
# File 'lib/graphql_rails/router/route.rb', line 10 def groups @groups end |
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
10 11 12 |
# File 'lib/graphql_rails/router/route.rb', line 10 def module_name @module_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/graphql_rails/router/route.rb', line 10 def name @name end |
#on ⇒ Object (readonly)
Returns the value of attribute on.
10 11 12 |
# File 'lib/graphql_rails/router/route.rb', line 10 def on @on end |
#relative_path ⇒ Object (readonly)
Returns the value of attribute relative_path.
10 11 12 |
# File 'lib/graphql_rails/router/route.rb', line 10 def relative_path @relative_path end |
#scope_names ⇒ Object (readonly)
Returns the value of attribute scope_names.
10 11 12 |
# File 'lib/graphql_rails/router/route.rb', line 10 def scope_names @scope_names end |
Instance Method Details
#collection? ⇒ Boolean
28 29 30 |
# File 'lib/graphql_rails/router/route.rb', line 28 def collection? on == :collection end |
#field_options ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/graphql_rails/router/route.rb', line 38 def if function { function: function } else { resolver: resolver, extras: [:lookahead], ** } end end |
#path ⇒ Object
22 23 24 25 26 |
# File 'lib/graphql_rails/router/route.rb', line 22 def path return relative_path if module_name.empty? [module_name, relative_path].join('/') end |
#show_in_group?(group_name) ⇒ Boolean
32 33 34 35 36 |
# File 'lib/graphql_rails/router/route.rb', line 32 def show_in_group?(group_name) return true if groups.nil? || groups.empty? groups.include?(group_name&.to_sym) end |