Class: Auth::Observer

Inherits:
ActiveRecord::Observer
  • Object
show all
Defined in:
lib/auth/observer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.observe(*models) ⇒ Object

Attaches the observer to the supplied model classes.



6
7
8
9
10
11
# File 'lib/auth/observer.rb', line 6

def observe(*models)
  models.flatten!
  models.collect! { |model| model.is_a?(Symbol) ? model.to_s.camelize.constantize : model }
  observed_classes.concat models
  observed_classes.uniq!
end

.observed_classesObject



13
14
15
# File 'lib/auth/observer.rb', line 13

def observed_classes
  @observed_classes ||= []
end

Instance Method Details

#observed_classesObject



18
19
20
# File 'lib/auth/observer.rb', line 18

def observed_classes
  Set.new(self.class.observed_classes)
end