Sha256: dfb14a5ac3cdfe72e42d183a6e18a3f8fbbe45522df456f3f2a7b5adbb7fea70
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
require "active_record" require "active_support/core_ext/module" require "protected_attributes" require "acts-as-taggable-on" require_relative "log_book/version" require_relative "log_book/plugin" require_relative "log_book/utils" module LogBook OPERATIONS = { :create => "create", :update => "update", :destroy => "destroy" } def self.event(historian, historizable, text, tag_list) tag_list_composed = [] tag_list_composed << scope_tag(historian) if historian tag_list_composed << kind_tag(historizable) if historizable tag_list_composed += [tag_list].flatten if tag_list LogBook::Event.create!( :historian => historian, :historizable => historizable, :text => text, :tag_list => tag_list_composed ) end private def self.created(historian, historizable) LogBook.event(historian, historizable, "#{historizable.class.name} created", LogBook::OPERATIONS[:create]) end def self.updated(historian, historizable) LogBook.event(historian, historizable, "#{historizable.class.name} updated [#{LogBook::Utils.pretty_changes(historizable)}]", LogBook::OPERATIONS[:update]) end def self.destroyed(historian, historizable) LogBook.event(historian, historizable, "#{historizable.class.name} destroyed", LogBook::OPERATIONS[:destroy]) end def self.scope_tag(historian) historian.class.name.underscore end def self.kind_tag(historizable) historizable.class.name.underscore end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
log_book-0.1.7 | lib/log_book.rb |