activerecord-cipherstash-pg-adapter 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6262922b580ca02288fe1dbf4a3b21bf985f6fb8c9fd5ac7e6703d20db749c81
4
- data.tar.gz: be8c972a4fd10bfbb6a35aae3b8b1c9a02f23fd78d25ef29d0ca9d14d5881c0b
3
+ metadata.gz: d3f6569db99eeff40bdc38fbd51f393a68978550ba6a88e076abe88178a6460f
4
+ data.tar.gz: 4df3a9c690bfdab57c6f145976635bbf1f0115f26280a837096416e5a39cf715
5
5
  SHA512:
6
- metadata.gz: 535dde7f708d635cfc0173a8e3330c6fbdeb14b2f574521b81604c759869c58386bd78390860a9b3d2229341b7bd70b3409198b6848ccf6a68b490737b8ccc7e
7
- data.tar.gz: 95697d9ef5f7276138049648f329cec41761d59be3bf97f520b7d3e0947d5b30cdfb35c138db36956a0e65a461b7e59bfa8aa66455f433e6a68cfe265758ea76
6
+ metadata.gz: f3351800d72a4bb087cf4502c4238b93bdb80f1b18b16d309d5203ce15f7499cdb61a2de0f39049db55f1adc36639692ecb52f7c82f40ff76a318c10dbf366b3
7
+ data.tar.gz: d0d596f49a41c6438369981d65355332f8bbdc9df960b911aedd50244487a16b99e121b08f5b8c4b5524f739a9db6dfcd126f02c6fcae4c8949da3e6217fb676
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecord
4
- Point = Struct.new(:x, :y)
5
-
6
4
  module ConnectionAdapters
7
5
  module CipherStashPG
6
+ Point = Struct.new(:x, :y)
7
+
8
8
  module OID # :nodoc:
9
9
  class Point < Type::Value # :nodoc:
10
10
  include ActiveModel::Type::Helpers::Mutable
@@ -31,10 +31,9 @@ module ActiveRecord
31
31
  end
32
32
 
33
33
  def serialize(value)
34
- case value
35
- when ActiveRecord::Point
34
+ if quacks_like_a_point?(value)
36
35
  "(#{number_for_point(value.x)},#{number_for_point(value.y)})"
37
- when ::Array
36
+ elsif ::Array == value
38
37
  serialize(build_point(*value))
39
38
  else
40
39
  super
@@ -42,7 +41,7 @@ module ActiveRecord
42
41
  end
43
42
 
44
43
  def type_cast_for_schema(value)
45
- if ActiveRecord::Point === value
44
+ if quacks_like_a_point?(value)
46
45
  [value.x, value.y]
47
46
  else
48
47
  super
@@ -55,7 +54,11 @@ module ActiveRecord
55
54
  end
56
55
 
57
56
  def build_point(x, y)
58
- ActiveRecord::Point.new(Float(x), Float(y))
57
+ CipherStashPG::Point.new(Float(x), Float(y))
58
+ end
59
+
60
+ def quacks_like_a_point?(value)
61
+ value.respond_to(:x) && value.respond_to(:y)
59
62
  end
60
63
  end
61
64
  end
@@ -1,10 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecord
4
- Point = Struct.new(:x, :y)
5
-
6
4
  module ConnectionAdapters
7
5
  module CipherStashPG
6
+ Point = Struct.new(:x, :y)
8
7
  module OID # :nodoc:
9
8
  class Point < Type::Value # :nodoc:
10
9
  include ActiveModel::Type::Helpers::Mutable
@@ -31,10 +30,9 @@ module ActiveRecord
31
30
  end
32
31
 
33
32
  def serialize(value)
34
- case value
35
- when ActiveRecord::Point
33
+ if quacks_like_a_point(value)
36
34
  "(#{number_for_point(value.x)},#{number_for_point(value.y)})"
37
- when ::Array
35
+ elsif ::Array === value
38
36
  serialize(build_point(*value))
39
37
  else
40
38
  super
@@ -42,7 +40,7 @@ module ActiveRecord
42
40
  end
43
41
 
44
42
  def type_cast_for_schema(value)
45
- if ActiveRecord::Point === value
43
+ if quacks_like_a_point?(value)
46
44
  [value.x, value.y]
47
45
  else
48
46
  super
@@ -55,7 +53,11 @@ module ActiveRecord
55
53
  end
56
54
 
57
55
  def build_point(x, y)
58
- ActiveRecord::Point.new(Float(x), Float(y))
56
+ CipherStashPG::Point.new(Float(x), Float(y))
57
+ end
58
+
59
+ def quacks_like_a_point?(value)
60
+ value.respond_to(:x) && value.respond_to(:y)
59
61
  end
60
62
  end
61
63
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ActiveRecord
2
- CIPHERSTASH_PG_ADAPTER_VERSION = "0.7.5"
2
+ CIPHERSTASH_PG_ADAPTER_VERSION = "0.7.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-cipherstash-pg-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Howard
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-22 00:00:00.000000000 Z
11
+ date: 2023-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord