Class: Graphiti::ActiveGraph::Extensions::QueryParams
- Inherits:
-
Object
- Object
- Graphiti::ActiveGraph::Extensions::QueryParams
- Defined in:
- lib/graphiti/active_graph/extensions/query_params.rb
Instance Attribute Summary collapse
-
#grouping_extra_params ⇒ Object
readonly
Returns the value of attribute grouping_extra_params.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#resource_class ⇒ Object
readonly
Returns the value of attribute resource_class.
Instance Method Summary collapse
- #extra_field?(type, name) ⇒ Boolean
- #group_by ⇒ Object
- #group_by_params ⇒ Object
- #group_by_params_hash ⇒ Object
-
#initialize(params, resource_class, grouping_extra_params: {}) ⇒ QueryParams
constructor
A new instance of QueryParams.
Constructor Details
#initialize(params, resource_class, grouping_extra_params: {}) ⇒ QueryParams
Returns a new instance of QueryParams.
5 6 7 8 9 |
# File 'lib/graphiti/active_graph/extensions/query_params.rb', line 5 def initialize(params, resource_class, grouping_extra_params: {}) @params = params @resource_class = resource_class @grouping_extra_params = grouping_extra_params end |
Instance Attribute Details
#grouping_extra_params ⇒ Object (readonly)
Returns the value of attribute grouping_extra_params.
3 4 5 |
# File 'lib/graphiti/active_graph/extensions/query_params.rb', line 3 def grouping_extra_params @grouping_extra_params end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/graphiti/active_graph/extensions/query_params.rb', line 3 def params @params end |
#resource_class ⇒ Object (readonly)
Returns the value of attribute resource_class.
3 4 5 |
# File 'lib/graphiti/active_graph/extensions/query_params.rb', line 3 def resource_class @resource_class end |
Instance Method Details
#extra_field?(type, name) ⇒ Boolean
23 24 25 |
# File 'lib/graphiti/active_graph/extensions/query_params.rb', line 23 def extra_field?(type, name) params.dig(:extra_fields, type)&.include?(name.to_s) end |
#group_by ⇒ Object
11 12 13 |
# File 'lib/graphiti/active_graph/extensions/query_params.rb', line 11 def group_by Grouping::Params.new(params, resource_class) end |
#group_by_params ⇒ Object
15 16 17 |
# File 'lib/graphiti/active_graph/extensions/query_params.rb', line 15 def group_by_params group_by_params_hash unless group_by.empty? end |
#group_by_params_hash ⇒ Object
19 20 21 |
# File 'lib/graphiti/active_graph/extensions/query_params.rb', line 19 def group_by_params_hash { group_by: group_by.grouping_criteria_list }.merge(grouping_extra_params) end |