Method: Mochigome::ModelExtensions::ClassMethods#has_mochigome_aggregations

Defined in:
lib/model_extensions.rb

#has_mochigome_aggregations(name = :default) {|settings| ... } ⇒ Object

TODO: Split out aggregation stuff into its own module

Yields:

  • (settings)


48
49
50
51
52
53
54
55
56
# File 'lib/model_extensions.rb', line 48

def has_mochigome_aggregations(name = :default)
  name = name.to_sym
  if mochigome_aggregation_settings_sets[name].try(:model) == self
    raise Mochigome::ModelSetupError.new("Can't overwrite aggregation settings for #{self.name}")
  end
  settings = AggregationSettings.new(self)
  yield settings if block_given?
  mochigome_aggregation_settings_sets[name] = settings
end