Sha256: 56d8ba26bbd65965273e1e28ce7fc52d32658d7423e365e4cb446b23c2db51ad

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require 'active_record'
require 'active_support/current_attributes'
require 'dry-configurable'

require 'log_book/configuration'
require 'log_book/store'
require 'log_book/tree'
require 'log_book/save_records'
require 'log_book/record'
require 'log_book/recorder'
require 'log_book/controller_record'
require 'log_book/version'
require 'log_book/railtie'

module LogBook
  class << self
    def with_recording
      recording_was_disabled = recording_enabled
      enable_recording
      LogBook::Store.tree = LogBook::Tree.new

      yield

      LogBook::SaveRecords.call
    ensure
      disable_recording unless recording_was_disabled
    end

    def recording_enabled
      LogBook::Store.recording_enabled || LogBook.config.recording_enabled
    end

    def record_squashing_enabled
      LogBook::Store.record_squashing || LogBook.config.record_squashing
    end

    def disable_recording
      LogBook::Store.recording_enabled = false
    end

    def enable_recording
      LogBook::Store.recording_enabled = true
    end

    def action=(val)
      LogBook::Store.tree.action = val
    end

    def author=(val)
      LogBook::Store.tree.author = val
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_log_book-2.2.0 lib/rails_log_book.rb
rails_log_book-2.1.0 lib/rails_log_book.rb