event_horizon 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.8
1
+ 0.0.9
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{event_horizon}
8
- s.version = "0.0.8"
8
+ s.version = "0.0.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jiri Zajpt"]
@@ -31,6 +31,13 @@ module EventHorizon
31
31
 
32
32
  module InstanceMethods
33
33
 
34
+ # Since Mongoid doesn't have polymorphic association support define
35
+ # events associations this way...
36
+ def events
37
+ type = self._type || self.class.name
38
+ Event.where(:document_id => self.id, :document_type => type)
39
+ end
40
+
34
41
  def fire!(event, options = {})
35
42
  self.call_event_callbacks_for(event)
36
43
  self.create_event(event, options)
@@ -28,6 +28,8 @@ class Event
28
28
 
29
29
  # Public methods
30
30
 
31
+ # Since Mongoid doesn't have polymorphic association support define
32
+ # events associations this way...
31
33
  def document
32
34
  self.document_type.constantize.find(self.document_id)
33
35
  rescue ::Mongoid::Errors::DocumentNotFound
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 8
9
- version: 0.0.8
8
+ - 9
9
+ version: 0.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jiri Zajpt