Sha256: db905518d8e80d4f53bb7aa8cf669e59d14a7aec200e483cd883cacabb400119

Contents?: true

Size: 935 Bytes

Versions: 11

Compression:

Stored size: 935 Bytes

Contents

require 'mcfly/migration'
require 'mcfly/has_mcfly'
require 'mcfly/controller'
require 'mcfly/version'
require 'active_support'

module Mcfly
  # ATTRIBUTION: some of the code in this project has been shamelessly
  # lifted form paper_trail.

  # Sets who is responsible for any changes that occur.  You would
  # normally use this in a migration or on the console, when working
  # with models directly.
  def self.whodunnit=(value)
    mcfly_store[:whodunnit] = value
    sval = value[:id] rescue -1
    ActiveRecord::Base.connection.execute("SET mcfly.whodunnit = #{sval};")
  end

  def self.whodunnit
    mcfly_store[:whodunnit]
  end

  private

  # Thread-safe hash to hold Mcfly's data.
  def self.mcfly_store
    Thread.current[:mcfly] ||= {}
  end
end

ActiveSupport.on_load(:active_record) do
  include Delorean::Model
  include Mcfly::Model
end

ActiveSupport.on_load(:action_controller) do
  include Mcfly::Controller
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mcfly-0.1.0 lib/mcfly.rb
mcfly-0.0.22 lib/mcfly.rb
mcfly-0.0.21 lib/mcfly.rb
mcfly-0.0.20 lib/mcfly.rb
mcfly-0.0.19 lib/mcfly.rb
mcfly-0.0.18 lib/mcfly.rb
mcfly-0.0.17 lib/mcfly.rb
mcfly-0.0.16 lib/mcfly.rb
mcfly-0.0.15 lib/mcfly.rb
mcfly-0.0.14 lib/mcfly.rb
mcfly-0.0.13 lib/mcfly.rb