Module: Aggrobot
- Defined in:
- lib/aggrobot.rb,
lib/aggrobot/errors.rb,
lib/aggrobot/helper.rb,
lib/aggrobot/version.rb,
lib/aggrobot/aggrobot.rb,
lib/aggrobot/aggregator.rb,
lib/aggrobot/sql_functions.rb,
lib/aggrobot/aggrobot_error.rb,
lib/aggrobot/sql_functions/mysql.rb,
lib/aggrobot/sql_functions/pgsql.rb,
lib/aggrobot/sql_functions/common.rb,
lib/aggrobot/sql_functions/sqlite.rb,
lib/aggrobot/query_planner/parameters_validator.rb,
lib/aggrobot/query_planner/default_query_planner.rb,
lib/aggrobot/query_planner/group_limit_query_planner.rb,
lib/aggrobot/query_planner/bucketed_groups_query_planner.rb
Defined Under Namespace
Modules: Helper, QueryPlanner, SQLFunctions Classes: Aggregator, Aggrobot, AggrobotError, ArgumentError, Error
Constant Summary collapse
- DEFAULT_GROUP_BY =
‘aggrobot_default_group’
1
- VERSION =
"0.1.0"
Class Method Summary collapse
- .block(&block) ⇒ Object
-
.setup(app) ⇒ Object
sets ROUNDING_DIGITS to percent_precision, default is 2.
-
.start(collection = nil, block_arg = nil, block_opts = nil, &block) ⇒ Object
when collection is given, starts aggregation by evaluating block on collection collection is not given, starts aggregation by evaluating block on full data set.
Class Method Details
.block(&block) ⇒ Object
31 32 33 |
# File 'lib/aggrobot.rb', line 31 def self.block(&block) block end |
.setup(app) ⇒ Object
sets ROUNDING_DIGITS to percent_precision, default is 2
36 37 38 |
# File 'lib/aggrobot.rb', line 36 def self.setup(app) SQLFunctions.setup(app.config.aggrobot.percent_precision) end |
.start(collection = nil, block_arg = nil, block_opts = nil, &block) ⇒ Object
when
collection is given, starts aggregation by evaluating block on collection
collection is not given, starts aggregation by evaluating block on full data set
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/aggrobot.rb', line 20 def self.start(collection = nil, block_arg = nil, block_opts = nil, &block) block_opts ||= block_arg if block block = block_arg if block_arg && block_arg.respond_to?(:call) raise 'Block parameter required' unless block original_block_context = eval "self", block.binding attrs = if block.arity > 0 block_opts.is_a?(Hash) ? block_opts : {count: collection.count} end Aggrobot.new(original_block_context, collection).instance_exec(attrs, &block) end |