Class: GraphqlRails::Controller::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql_rails/controller/action.rb

Overview

analyzes route and extracts controller action related data

Instance Method Summary collapse

Constructor Details

#initialize(route) ⇒ Action

Returns a new instance of Action.



14
15
16
# File 'lib/graphql_rails/controller/action.rb', line 14

def initialize(route)
  @route = route
end

Instance Method Details

#action_configObject



46
47
48
# File 'lib/graphql_rails/controller/action.rb', line 46

def action_config
  controller.controller_configuration.action_config(name)
end

#argumentsObject



22
23
24
# File 'lib/graphql_rails/controller/action.rb', line 22

def arguments
  action_config.attributes.values
end

#controllerObject



26
27
28
# File 'lib/graphql_rails/controller/action.rb', line 26

def controller
  @controller ||= "#{namespaced_controller_name}_controller".classify.constantize
end

#descriptionObject



34
35
36
# File 'lib/graphql_rails/controller/action.rb', line 34

def description
  action_config.description
end

#nameObject



30
31
32
# File 'lib/graphql_rails/controller/action.rb', line 30

def name
  @name ||= relative_path.split('#').last
end

#return_typeObject



18
19
20
# File 'lib/graphql_rails/controller/action.rb', line 18

def return_type
  action_config.return_type
end

#type_argsObject



38
39
40
# File 'lib/graphql_rails/controller/action.rb', line 38

def type_args
  [type_parser.type_arg]
end

#type_optionsObject



42
43
44
# File 'lib/graphql_rails/controller/action.rb', line 42

def type_options
  { null: !type_parser.required? }
end