Class: QueryBuilderContext

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/groups/query_builder_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(groupings = [], current_proc = nil) ⇒ QueryBuilderContext

Returns a new instance of QueryBuilderContext.



7
8
9
10
# File 'lib/graphql/groups/query_builder_context.rb', line 7

def initialize(groupings = [], current_proc = nil)
  @grouping = groupings
  @current_proc = current_proc
end

Instance Attribute Details

#current_procObject (readonly)

Returns the value of attribute current_proc.



5
6
7
# File 'lib/graphql/groups/query_builder_context.rb', line 5

def current_proc
  @current_proc
end

#groupingObject (readonly)

Returns the value of attribute grouping.



4
5
6
# File 'lib/graphql/groups/query_builder_context.rb', line 4

def grouping
  @grouping
end

Instance Method Details

#combine_procs(base_proc, new_proc) ⇒ Object



18
19
20
# File 'lib/graphql/groups/query_builder_context.rb', line 18

def combine_procs(base_proc, new_proc)
  proc { new_proc.call(base_proc.call) }
end

#update(grouping, new_proc) ⇒ Object



12
13
14
15
16
# File 'lib/graphql/groups/query_builder_context.rb', line 12

def update(grouping, new_proc)
  new_grouping = @grouping + [grouping]
  combined_proc = combine_procs(@current_proc, new_proc)
  QueryBuilderContext.new(new_grouping, combined_proc)
end