Module: Aggrobot
- Defined in:
- lib/aggrobot.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/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
Constant Summary
collapse
- DEFAULT_GROUP_BY =
SqlFunctions.sanitize('aggrobot_default_group')
- VERSION =
"0.0.2"
Class Method Summary
collapse
Class Method Details
.block(&block) ⇒ Object
28
29
30
|
# File 'lib/aggrobot.rb', line 28
def self.block(&block)
block
end
|
.setup(app) ⇒ Object
32
33
34
|
# File 'lib/aggrobot.rb', line 32
def self.setup(app)
SqlFunctions.const_set(:ROUNDING_DIGITS, app.config.aggrobot.percent_precision || 2)
end
|
.start(collection = nil, block_arg = nil, block_opts = nil, &block) ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/aggrobot.rb', line 17
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
|