Sha256: abd5d99944706b500239729b9685233bc06ae37759ec14b591e6888d1f84c3d9

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

require 'singleton'
require 'yaml'
require 'change_log/config'
require 'change_log/controller'
require 'change_log/has_change_log'
require 'change_log/maintenance'

# ChangeLog's module methods can be called in both models and controllers.
module ChangeLog

  # Switches ChangeLog on or off.
  def self.enabled=(value)
    ChangeLog.config.enabled = value
  end

  # Returns `true` if ChangeLog is on, `false` otherwise.
  # ChangeLog is enabled by default.
  def self.enabled?
    !!ChangeLog.config.enabled
  end

  # Returns who is reponsible for any changes that occur.
  def self.whodidit
    change_log_store[:whodidit]
  end

  # Sets who is responsible for any changes that occur.
  # In a controller it automatically get the value from `current_user` action.
  def self.whodidit=(value)
    change_log_store[:whodidit] = value
  end
  
  
  private
  # Thread-safe hash to hold ChangeLog's data.
  def self.change_log_store
    Thread.current[:change_log] ||= {}
  end

  # Returns ChangeLog's configuration object.
  def self.config
    @@config ||= ChangeLog::Config.instance
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
change_log-0.0.5 lib/change_log.rb
change_log-0.0.4 lib/change_log.rb
change_log-0.0.3 lib/change_log.rb
change_log-0.0.2 lib/change_log.rb
change_log-0.0.1 lib/change_log.rb