sequent 0.1.9 → 0.1.10

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d2fce46d6a1e3cf678095978eef7e50640510f4d
4
- data.tar.gz: 1da9ad9573f554a2fde4ccb45847a2c6102316fc
3
+ metadata.gz: 17b7ed3c1ef96f46ab49ba1f980e06d596b50a30
4
+ data.tar.gz: cc6ab65e25cfbe2822a88aaf4308683d4ba18eab
5
5
  SHA512:
6
- metadata.gz: 238fb123246feaaf104bd9e8cfee06241378c6d274a4c90cb88e761c3b6728277e5faef94f555c88cf5ef3c7b7abe8d86034d651a36d91d37eaa65bfaba65e3b
7
- data.tar.gz: 5e3ac92286b6178c2147c301c3edc7db5a499f60e734886b2d9e39764a5a79cc7778205b5519a670e039a2fb9c2abbbe0ab739954c0e00c4786c11b5bdd91c3a
6
+ metadata.gz: 0cc5a1eabb3991255cbbf40fc4bdb50a25bb57dcec04f7a81a624307beb719efe225acfdf541291524b48e699ea91f3dc0886e1ce4965de1b2bfb8155466ea90
7
+ data.tar.gz: 22461d8b930f1fea40c72032bd9115af5e21ca19ef63cd460a7ebe80ddd8cf5e7a61518b3971923937fa14ca0d024d2bb42747c73ad8202881235a8a8fe18766
@@ -1,63 +1,53 @@
1
1
  class Symbol
2
-
3
2
  def self.deserialize_from_json(value)
4
3
  value.blank? ? nil : value.try(:to_sym)
5
4
  end
6
-
7
5
  end
8
6
 
9
7
  class String
10
-
11
8
  def self.deserialize_from_json(value)
12
9
  value
13
10
  end
14
-
15
11
  end
16
12
 
17
13
  class Integer
18
-
19
14
  def self.deserialize_from_json(value)
20
15
  value.blank? ? nil : value.to_i
21
16
  end
17
+ end
22
18
 
19
+ class Float
20
+ def self.deserialize_from_json(value)
21
+ value.blank? ? nil : value.to_f
22
+ end
23
23
  end
24
24
 
25
25
  class Boolean
26
-
27
26
  def self.deserialize_from_json(value)
28
27
  value.nil? ? nil : (value.present? ? value : false)
29
28
  end
30
-
31
29
  end
32
30
 
33
31
  class Date
34
-
35
32
  def self.deserialize_from_json(value)
36
33
  value.blank? ? nil : Date.iso8601(value.dup)
37
34
  end
38
-
39
35
  end
40
36
 
41
37
  class DateTime
42
-
43
38
  def self.deserialize_from_json(value)
44
39
  value.blank? ? nil : DateTime.iso8601(value.dup)
45
40
  end
46
-
47
41
  end
48
42
 
49
43
  class Array
50
-
51
44
  def self.deserialize_from_json(value)
52
45
  value
53
46
  end
54
-
55
47
  end
56
48
 
57
49
  class Hash
58
-
59
50
  def self.deserialize_from_json(value)
60
51
  value
61
52
  end
62
-
63
53
  end
@@ -9,6 +9,7 @@ module Sequent
9
9
  ::Symbol => ->(value) { Symbol.deserialize_from_json(value) },
10
10
  ::String => ->(value) { value },
11
11
  ::Integer => ->(value) { parse_to_integer(value) },
12
+ ::Float => ->(value) { parse_to_float(value) },
12
13
  ::Boolean => ->(value) { parse_to_bool(value) },
13
14
  ::Date => ->(value) { parse_to_date(value) },
14
15
  ::DateTime => ->(value) { parse_to_date_time(value) },
@@ -19,6 +20,10 @@ module Sequent
19
20
  Integer(value) unless value.blank?
20
21
  end
21
22
 
23
+ def self.parse_to_float(value)
24
+ Float(value) unless value.blank?
25
+ end
26
+
22
27
  def self.parse_to_bool(value)
23
28
  if value.blank? && !(value.is_a?(TrueClass) || value.is_a?(FalseClass))
24
29
  nil
@@ -81,6 +81,10 @@ module Sequent
81
81
  if self.class.struct_cache.has_key?(struct_class_name)
82
82
  struct_class = self.class.struct_cache[struct_class_name]
83
83
  else
84
+ if column_names.include? :aggregate_id
85
+ @indices[record_class] ||= []
86
+ @indices[record_class] << [:aggregate_id]
87
+ end
84
88
 
85
89
  # We create a struct on the fly.
86
90
  # Since the replay happens in memory we implement the ==, eql? and hash methods
@@ -110,9 +114,6 @@ module Sequent
110
114
 
111
115
  yield record if block_given?
112
116
  @record_store[record_class] << record
113
- if record.respond_to? :aggregate_id
114
- @record_index[[record_class, record.aggregate_id]] = record
115
- end
116
117
 
117
118
  if indexed?(record_class)
118
119
  do_with_cache_keys(record_class, record) do |key|
@@ -179,9 +180,7 @@ module Sequent
179
180
  end
180
181
 
181
182
  def find_records(record_class, where_clause)
182
- if where_clause.has_key? :aggregate_id and where_clause.size == 1
183
- [@record_index[[record_class, where_clause[:aggregate_id]]]].compact
184
- elsif use_index?(record_class, where_clause)
183
+ if use_index?(record_class, where_clause)
185
184
  values = get_index(record_class, where_clause).map { |field| where_clause[field] }
186
185
  @record_index[[record_class, *values]] || []
187
186
  else
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sequent
2
- VERSION = '0.1.9'
2
+ VERSION = '0.1.10'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Vonk
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-09-28 00:00:00.000000000 Z
13
+ date: 2015-10-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord