Class: Eventifier::TrackableClass

Inherits:
Object
  • Object
show all
Defined in:
lib/eventifier/trackable_class.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, klass_methods, options) ⇒ TrackableClass

Returns a new instance of TrackableClass.



8
9
10
11
12
13
14
# File 'lib/eventifier/trackable_class.rb', line 8

def initialize(klass, klass_methods, options)
  @klass, @klass_methods = klass, klass_methods

  @attributes = options.delete(:attributes) || {}
  @owner      = options.delete :owner
  @group_by   = options.delete :group_by
end

Class Method Details

.track(klass, klass_methods, attributes) ⇒ Object



4
5
6
# File 'lib/eventifier/trackable_class.rb', line 4

def self.track(klass, klass_methods, attributes)
  self.new(klass, klass_methods, attributes).track
end

Instance Method Details

#trackObject



16
17
18
19
20
21
22
23
# File 'lib/eventifier/trackable_class.rb', line 16

def track
  add_relations
  generate_observer_callbacks

  observer.instance

  Eventifier::EventSubscriber.subscribe_to_all @klass, @klass_methods
end