Sha256: 8b64a9c59796aed0685f880e7f5ca968db9bb60d41f133b5f73430581a5678c4

Contents?: true

Size: 670 Bytes

Versions: 3

Compression:

Stored size: 670 Bytes

Contents

module LogBook
  module ControllerRecord
    extend ActiveSupport::Concern

    included do
      before_action :enable_recording
      around_action :record_squashing
    end

    def enable_recording
      LogBook.store[:controller] = self
      LogBook.store[:author] = current_author
      LogBook.store[:request_uuid] = try(:request).try(:uuid) || SecureRandom.hex
      LogBook.enable_recording
    end

    def record_squashing
      LogBook.with_record_squashing do
        yield
      end
    end

    def current_author
      raise NotImplementedError unless respond_to?(LogBook.config.author_method)
      send(LogBook.config.author_method)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_log_book-0.3.0 lib/log_book/controller_record.rb
rails_log_book-0.2.0 lib/log_book/controller_record.rb
rails_log_book-0.1.0 lib/log_book/controller_record.rb