euston-projections 1.0.4-java → 1.0.6-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'euston-projections'
3
- s.version = '1.0.4'
3
+ s.version = '1.0.6'
4
4
  s.platform = RUBY_PLATFORM.to_s == 'java' ? 'java' : Gem::Platform::RUBY
5
5
  s.authors = ['Lee Henson', 'Guy Boertje']
6
6
  s.email = ['lee.m.henson@gmail.com', 'guyboertje@gmail.com']
@@ -17,7 +17,15 @@ module Euston
17
17
  end
18
18
 
19
19
  def if_unhandled_or_new document_type, id, headers
20
- document = document_type.find(id) || document_type.new(_id: id)
20
+ if id.respond_to? :call
21
+ query = id
22
+ attributes = {}
23
+ else
24
+ query = ->() { document_type.find(id) }
25
+ attributes = { _id: id }
26
+ end
27
+
28
+ document = query.call || document_type.new(attributes)
21
29
 
22
30
  if_unhandled document, headers do
23
31
  yield document
@@ -31,6 +31,10 @@ module MongoProjection
31
31
  def prune_history_older_than time
32
32
  historical_messages.reject! { |m| m.timestamp < time }
33
33
  end
34
+
35
+ def act_as(role)
36
+ role.new(self)
37
+ end
34
38
  end
35
39
  end
36
40
  end
@@ -1,5 +1,5 @@
1
1
  module Euston
2
2
  module Projections
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: euston-projections
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.4
5
+ version: 1.0.6
6
6
  platform: java
7
7
  authors:
8
8
  - Lee Henson
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-12-01 00:00:00.000000000Z
13
+ date: 2011-12-08 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport