valkyrie-sequel 2.2.1 → 3.0.0.pre.beta.1

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: 02c82c0908c1a17e60365ffe3b82936ffed1c168ccc40183d78fc60000b4e7da
4
- data.tar.gz: 434ff68cfb53eab85acc6cbe6eefe691d27eea0e01e0249475b97675c0da5f68
3
+ metadata.gz: b6d42b77cece523b4eeacf7f4853bc20e0fac7f5b8df24e742ae4ef1e6b7df12
4
+ data.tar.gz: 6edac9cf3f494640dfe74e062dd3760d9f0386d8d3b60dcf2ea7f01190e3fc3d
5
5
  SHA512:
6
- metadata.gz: 1bf48b6add481dcd51d4f02f3a0454d8144f6d39106a264510e5f02c0764769344cdb343a8f05038b94614d79b3b16cc0430a25a683f5b0f047cca7d8c072768
7
- data.tar.gz: 00a6c97708c6f3653497f158d1a0aded088a73908d9559c4f276ae02f2768826a2ddb7306fa41ed5a1d146062f196f63995b5a7f6f0f4bbcc39c4e569e695446
6
+ metadata.gz: 53f9dc78cec19cb0eaac3e7001eaf2f8d2cf8c29e3ec10795fa0f1b69162ba34d8a237582c9f7345022fc0d82d422eac490be84eb8596f39941b2dffad2af812
7
+ data.tar.gz: 51faaaad25361de2f20885dafa49307a56bb75bd91a2a907607ae4228bef125764acf7d6ef162a34c2fbc50270ff3a6e5a5b1922074c33030a0415a2b4e97d87
@@ -8,9 +8,9 @@ module Valkyrie::Sequel
8
8
  @adapter = adapter
9
9
  end
10
10
 
11
- def save(resource:)
11
+ def save(resource:, external_resource: false)
12
12
  object_attributes = resource_factory.from_resource(resource: resource)
13
- output = create_or_update(resource: resource, attributes: object_attributes)
13
+ output = create_or_update(resource: resource, attributes: object_attributes, external_resource: external_resource)
14
14
  resource_factory.to_resource(object: output)
15
15
  end
16
16
 
@@ -121,11 +121,18 @@ module Valkyrie::Sequel
121
121
 
122
122
  private
123
123
 
124
- def create_or_update(resource:, attributes:)
124
+ def create_or_update(resource:, attributes:, external_resource:)
125
125
  attributes[:updated_at] = Time.now.utc
126
126
  attributes[:created_at] ||= Time.now.utc
127
- return create(resource: resource, attributes: attributes) unless resource.persisted? && !exists?(id: attributes[:id])
128
- update(resource: resource, attributes: attributes)
127
+ if exists?(id: attributes[:id])
128
+ update(resource: resource, attributes: attributes)
129
+ else
130
+ if !external_resource && resource.persisted?
131
+ # This resource has been deleted in the meantime, error.
132
+ raise Valkyrie::Persistence::ObjectNotFoundError, "The object #{resource.id} is previously persisted but not found at save time." unless exists?(id: attributes[:id])
133
+ end
134
+ create(resource: resource, attributes: attributes)
135
+ end
129
136
  end
130
137
 
131
138
  def create(resource:, attributes:)
@@ -146,7 +153,7 @@ module Valkyrie::Sequel
146
153
  end
147
154
 
148
155
  def exists?(id:)
149
- resources.select(1).first(id: id).nil?
156
+ !resources.select(1).first(id: id).nil?
150
157
  end
151
158
  end
152
159
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Valkyrie
3
3
  module Sequel
4
- VERSION = "2.2.1"
4
+ VERSION = "3.0.0-beta.1"
5
5
  end
6
6
  end
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_dependency "sequel", "~> 5.0"
24
24
  spec.add_dependency "sequel_pg", "~> 1.0"
25
- spec.add_dependency "valkyrie", ">= 2.1", "< 2.3"
25
+ spec.add_dependency "valkyrie", ">= 3.0.0-beta.1"
26
26
  spec.add_dependency "oj", "~> 3.0"
27
27
  spec.add_development_dependency "bundler", "~> 2.0"
28
28
  spec.add_development_dependency "rake"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valkyrie-sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 3.0.0.pre.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trey Pendragon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-01 00:00:00.000000000 Z
11
+ date: 2021-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -44,20 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '2.1'
48
- - - "<"
49
- - !ruby/object:Gem::Version
50
- version: '2.3'
47
+ version: 3.0.0.pre.beta.1
51
48
  type: :runtime
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
52
  - - ">="
56
53
  - !ruby/object:Gem::Version
57
- version: '2.1'
58
- - - "<"
59
- - !ruby/object:Gem::Version
60
- version: '2.3'
54
+ version: 3.0.0.pre.beta.1
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: oj
63
57
  requirement: !ruby/object:Gem::Requirement
@@ -214,11 +208,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
214
208
  version: '0'
215
209
  required_rubygems_version: !ruby/object:Gem::Requirement
216
210
  requirements:
217
- - - ">="
211
+ - - ">"
218
212
  - !ruby/object:Gem::Version
219
- version: '0'
213
+ version: 1.3.1
220
214
  requirements: []
221
- rubygems_version: 3.1.4
215
+ rubygems_version: 3.0.3
222
216
  signing_key:
223
217
  specification_version: 4
224
218
  summary: Valkyrie::MetadataAdapter for Postgres using Sequel.