Class: GraphQL::DSL::Directive

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/dsl/nodes/containers/directive.rb

Overview

Container for directive

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, arguments = {}) ⇒ Directive

Create directive container

Parameters:

  • name (String, Symbol)

    directive name

  • arguments (Hash) (defaults to: {})

    arguments

Raises:



21
22
23
24
25
26
# File 'lib/graphql/dsl/nodes/containers/directive.rb', line 21

def initialize(name, arguments = {})
  raise Error, 'Variable name must be specified' if name.nil? || name.empty?

  @name = name
  @arguments = arguments
end

Instance Attribute Details

#argumentsHash (readonly)

Returns arguments.

Returns:

  • (Hash)

    arguments



14
15
16
# File 'lib/graphql/dsl/nodes/containers/directive.rb', line 14

def arguments
  @arguments
end

#nameString, ... (readonly)

Returns directive name.

Returns:

  • (String, Symbol, nil)

    directive name



10
11
12
# File 'lib/graphql/dsl/nodes/containers/directive.rb', line 10

def name
  @name
end

Class Method Details

.from(value) ⇒ Directive

Create directive container from argument value

Parameters:

  • value

    argument value

Returns:



35
36
37
38
39
40
41
42
# File 'lib/graphql/dsl/nodes/containers/directive.rb', line 35

def from(value)
  case value
  when Directive then value
  when Symbol, String then new(value)
  else
    raise Error.new('Unsupported format of directive', class: value.class.name, value: value)
  end
end