Class: Graphlyte::WithField
- Inherits:
-
Object
- Object
- Graphlyte::WithField
- Defined in:
- lib/graphlyte/selection_builder.rb
Overview
The return value from ‘select!`. Allows further modifications (aliasing, directives) to the field.
Instance Method Summary collapse
- #alias(name, &block) ⇒ Object
-
#initialize(field, builder) ⇒ WithField
constructor
A new instance of WithField.
- #method_missing(name, *_args, **kwargs, &block) ⇒ Object
- #respond_to_missing? ⇒ Boolean
Constructor Details
#initialize(field, builder) ⇒ WithField
Returns a new instance of WithField.
38 39 40 41 |
# File 'lib/graphlyte/selection_builder.rb', line 38 def initialize(field, builder) @field = field @builder = builder end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *_args, **kwargs, &block) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/graphlyte/selection_builder.rb', line 51 def method_missing(name, *_args, **kwargs, &block) directive = Syntax::Directive.new(name.to_s) directive.arguments = @builder.argument_builder!.build(kwargs) if kwargs.any? @field.selection += @builder.build!(&block) if block_given? @field.directives << directive self end |
Instance Method Details
#alias(name, &block) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/graphlyte/selection_builder.rb', line 43 def alias(name, &block) @field.as = name @field.selection += @builder.build!(&block) if block_given? self end |
#respond_to_missing? ⇒ Boolean
63 64 65 |
# File 'lib/graphlyte/selection_builder.rb', line 63 def respond_to_missing?(*) true end |