module GraphQL::Client::CollocatedEnforcement

def enforce_collocated_callers(mod, methods, path)

Returns nothing.

path - String filename to assert calling from
methods - Array of Symbol method names
mod - Target Module/Class

Internal: Decorate method with collocated caller enforcement.
def enforce_collocated_callers(mod, methods, path)
  mod.prepend(Module.new do
    methods.each do |method|
      define_method(method) do |*args, &block|
        location = caller_locations(1, 1)[0]
        CollocatedEnforcement.verify_collocated_path(location, path, method) do
          super(*args, &block)
        end
      end
    end
  end)
end