Module: ActiveReporting::ActiveRecordAdaptor

Defined in:
lib/active_reporting/active_record_adaptor.rb

Overview

This is included into every class that inherits from ActiveRecord::Base

Instance Method Summary collapse

Instance Method Details

#fact_modelActiveReporting::FactModel

Returns the ActiveReporting::FactModel related to the model.

If one is not explictily defined, a constant will be created which inherits from ActiveReporting::Factmodel named [MyModel]FactModel



12
13
14
15
16
17
18
19
20
21
# File 'lib/active_reporting/active_record_adaptor.rb', line 12

def fact_model
  const_name = "#{name}FactModel"
  @fact_model ||= begin
                    const_name.constantize
                  rescue NameError
                    const = Object.const_set(const_name, Class.new(ActiveReporting::FactModel))
                    const.model = self
                    const
                  end
end