class GraphQL::ResultCache::Condition

Public Class Methods

new(config, obj:, args:, ctx: @if = config[:if]) click to toggle source
# File lib/graphql/result_cache/condition.rb, line 4
def initialize config, obj:, args:, ctx:
  @if = config[:if]
  @obj = obj
  @args = args
  @ctx = ctx
end

Public Instance Methods

true?() click to toggle source
# File lib/graphql/result_cache/condition.rb, line 11
def true?
  return false if except?
  case @if
  when Symbol
    @obj.send(@if)
  when Proc
    @if.call(@obj, @args, @ctx)
  else
    true
  end
end

Private Instance Methods

except?() click to toggle source
# File lib/graphql/result_cache/condition.rb, line 25
def except?
  except = ::GraphQL::ResultCache.except
  except.is_a?(Proc) ? except.call(@ctx) : except
end