Module: Rails::GraphQL::Helpers::WithOwner

Defined in:
lib/rails/graphql/helpers/with_owner.rb

Overview

Helper focus on event execution when objects have a owner property, pratically allowing resolvers and similar to be called in the owner

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, **xargs, &block) ⇒ Object (private)



26
27
28
29
30
31
# File 'lib/rails/graphql/helpers/with_owner.rb', line 26

def method_missing(method_name, *args, **xargs, &block)
  return super unless owner_respond_to?(method_name)
  event.on_instance(owner) do |obj|
    obj.public_send(method_name, *args, **xargs, &block)
  end
end

Class Method Details

.included(other) ⇒ Object



9
10
11
12
# File 'lib/rails/graphql/helpers/with_owner.rb', line 9

def self.included(other)
  other.extend(WithOwner::ClassMethods)
  other.class_attribute(:owner, instance_writer: false)
end