Module: TreasureData::Logger::Agent::Rails::ModelExtension

Defined in:
lib/td/logger/agent/rails/model.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



17
18
19
20
21
22
# File 'lib/td/logger/agent/rails/model.rb', line 17

def self.included(mod)
  cm = ClassMethods
  mod.class_eval do
    extend cm
  end
end

.initObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/td/logger/agent/rails/model.rb', line 6

def self.init
  # disable model extension ActiveRecord is not loaded
  # on Rails > 3 (other ORM is used)
  if !defined?(::ActiveRecord) &&
      ::Rails.respond_to?(:version) && ::Rails.version =~ /^3/
    return
  end
  require 'active_record'
  ::ActiveRecord::Base.send(:include, self)
end