Module: GraphqlRails::ChainableOptions

Included in:
Model::Configuration
Defined in:
lib/graphql_rails/concerns/chainable_options.rb

Overview

Allows defining methods chained way

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

NOT_SET =
Object.new

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



17
18
19
# File 'lib/graphql_rails/concerns/chainable_options.rb', line 17

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#initialize_copy(other) ⇒ Object



21
22
23
24
# File 'lib/graphql_rails/concerns/chainable_options.rb', line 21

def initialize_copy(other)
  super
  @chainable_option = other.instance_variable_get(:@chainable_option).dup
end

#with(**options) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/graphql_rails/concerns/chainable_options.rb', line 26

def with(**options)
  options.each do |method_name, args|
    send_args = [method_name]
    send_args << args if method(method_name).parameters.present?
    public_send(*send_args)
  end
  self
end