Module: Hound::Model::ClassMethods
- Defined in:
- lib/hound/model.rb
Instance Method Summary collapse
-
#hound(options = {}) ⇒ Object
Tell Hound to track this models actions.
Instance Method Details
#hound(options = {}) ⇒ Object
Tell Hound to track this models actions.
options - a Hash of configuration options.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hound/model.rb', line 13 def hound( = {}) send :include, InstanceMethods has_many :actions, as: 'actionable', class_name: 'Hound::Action' [:actions] ||= Hound.config.actions [:actions] = Array([:actions]).map(&:to_s) class_attribute :hound_options self. = .dup attr_accessor :hound # Add action hooks after_create :hound_create if [:actions].include?('create') before_update :hound_update if [:actions].include?('update') after_destroy :hound_destroy if [:actions].include?('destroy') end |