activerecord-cipherstash-pg-adapter 0.7.4 → 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: 3143ffac51d8f2da78746d887737441c5e1364e0bf8a5104f8edf56d09bc41af
4
- data.tar.gz: 126f55dd18ef7350432acbf5110878ff6caa123f3b7b4a0f1fba84562ce47c16
3
+ metadata.gz: d3f6569db99eeff40bdc38fbd51f393a68978550ba6a88e076abe88178a6460f
4
+ data.tar.gz: 4df3a9c690bfdab57c6f145976635bbf1f0115f26280a837096416e5a39cf715
5
5
  SHA512:
6
- metadata.gz: f059e01b4e65b1d327779bb2cef342a48ab1d342c20c3f15511bd5ba497ccba1fdbf2852e89152a6c7d7653e4a5d2637a3f1c8b704694405dcd07c4c35c55375
7
- data.tar.gz: ae96560bba84b8ab7c90d111eaa4a6888a749deb2f1502576dc5757268e3d405ddc3194fe1a5ff2c933cb679933255825ac49d69334c6e1c757e5c7dd6e666f8
6
+ metadata.gz: f3351800d72a4bb087cf4502c4238b93bdb80f1b18b16d309d5203ce15f7499cdb61a2de0f39049db55f1adc36639692ecb52f7c82f40ff76a318c10dbf366b3
7
+ data.tar.gz: d0d596f49a41c6438369981d65355332f8bbdc9df960b911aedd50244487a16b99e121b08f5b8c4b5524f739a9db6dfcd126f02c6fcae4c8949da3e6217fb676
data/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.7.5] - 2023-05-22
10
+
11
+ ### Changed
12
+
13
+ - Bump version of cipherstash-pg to 1.0.0.beta.7.
14
+
9
15
  ## [0.7.4] - 2023-05-17
10
16
 
11
17
  ### Changed
@@ -31,5 +31,5 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  # Runtime dependencies here; dev+test go in Gemfile.
33
33
  spec.add_dependency "activerecord", ">= 6.0.0", "< 8.0.0"
34
- spec.add_dependency "cipherstash-pg", ">= 1.0.0.beta.6"
34
+ spec.add_dependency "cipherstash-pg", ">= 1.0.0.beta.7"
35
35
  end
@@ -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.4"
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.4
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-17 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
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 1.0.0.beta.6
39
+ version: 1.0.0.beta.7
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 1.0.0.beta.6
46
+ version: 1.0.0.beta.7
47
47
  description: CipherStash PostgreSQL adapter for ActiveRecord.
48
48
  email:
49
49
  - robin@cipherstash.com