activerecord-cipherstash-pg-adapter 0.7.5 → 0.7.7

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
  SHA256:
3
- metadata.gz: 6262922b580ca02288fe1dbf4a3b21bf985f6fb8c9fd5ac7e6703d20db749c81
4
- data.tar.gz: be8c972a4fd10bfbb6a35aae3b8b1c9a02f23fd78d25ef29d0ca9d14d5881c0b
3
+ metadata.gz: c479d248f2aa495f2f355c6b48cfd7f5a132f1605ba9ad555153c60ce0c89d2b
4
+ data.tar.gz: aba5141ccd9d1ab8a71244f9e7fa91379fc5a208496530170a6fe356d7ba1091
5
5
  SHA512:
6
- metadata.gz: 535dde7f708d635cfc0173a8e3330c6fbdeb14b2f574521b81604c759869c58386bd78390860a9b3d2229341b7bd70b3409198b6848ccf6a68b490737b8ccc7e
7
- data.tar.gz: 95697d9ef5f7276138049648f329cec41761d59be3bf97f520b7d3e0947d5b30cdfb35c138db36956a0e65a461b7e59bfa8aa66455f433e6a68cfe265758ea76
6
+ metadata.gz: fcf34a31fb873b0f2093b6cd351a4ae44e17e35045bae1b68c80f52bd05eb95144ff69f544e5dd616406d069baa56518fea1d639d15f06a7d22f3b46243b0fa4
7
+ data.tar.gz: ba5b049cb95e6b7edfd737f5ae151c6888d6da9e64ef809d43311845dca7724e90783b88d42346c0d159c1933c7f1cfe326e6e9e545a3b1e0551999041679112
@@ -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.7"
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.7
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