Module: Gricer::ActiveModel::Statistics

Overview

Gricer’s statistics enhancements for ActiveModel

To add statistics to an ActiveRecord just include the module:

class SomeDataModel < ::ActiveRecord::Base
  include ActiveModel::Statistics
  [...]
end

This module provides two major enhancements:

Extendend attribute names

You can use relation attributes by using a dot in your attribute name.

Example:

For getting the name of the attribute name of Agent associated to the Request:

Gricer::Request.human_attributes('agent.name')

Statistics functions and filters

Methods for filtering, grouping, and counting records

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Extend the ActiveModel with the statistics class methods.

See Also:



29
30
31
# File 'lib/gricer/active_model/statistics.rb', line 29

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#model_typeObject



241
242
243
# File 'lib/gricer/active_model/statistics.rb', line 241

def model_type
  self.class.model_type
end