Class: QueryBuilderContext
- Inherits:
-
Object
- Object
- QueryBuilderContext
- Defined in:
- lib/graphql/groups/query_builder_context.rb
Instance Attribute Summary collapse
-
#current_proc ⇒ Object
readonly
Returns the value of attribute current_proc.
-
#grouping ⇒ Object
readonly
Returns the value of attribute grouping.
Instance Method Summary collapse
- #combine_procs(base_proc, new_proc) ⇒ Object
-
#initialize(groupings = [], current_proc = nil) ⇒ QueryBuilderContext
constructor
A new instance of QueryBuilderContext.
- #update(grouping, new_proc) ⇒ Object
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_proc ⇒ Object (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 |
#grouping ⇒ Object (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 |