Sha256: 7d461172b83e262f0248b436dcc4ec5834e248033b0bab86122c08c1ae0699b4
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
require 'aggrobot/query_planner/default_query_planner' require 'aggrobot/query_planner/group_limit_query_planner' require 'aggrobot/query_planner/bucketed_groups_query_planner' module Aggrobot::QueryPlanner def self.create(collection, group_by, opts = nil) case when opts.nil? DefaultQueryPlanner.new(collection, group_by) when opts.key?(:limit_to) GroupLimitQueryPlanner.new(collection, group_by, opts) when opts.key?(:buckets) BucketedGroupsQueryPlanner.new(collection, group_by, opts) end end module ParametersValidator def self.validate_options(opts, required_parameters, optional_parameters) params = opts.keys # raise errors for required parameters raise_argument_error(opts, required_parameters, optional_parameters) unless (required_parameters - params).empty? # raise errors if any extra arguments given raise_argument_error(opts, required_parameters, optional_parameters) unless (params - required_parameters - optional_parameters).empty? end def self.raise_argument_error(opts, required_parameters, optional_parameters) raise ArgumentError, <<-ERR Wrong arguments given - #{opts} Required parameters are #{required_parameters} Optional parameters are #{optional_parameters} ERR end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aggrobot-0.0.2 | lib/aggrobot/query_planner.rb |