rom-repository 1.4.0 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -6
- data/{LICENSE.txt → LICENSE} +1 -1
- data/README.md +18 -1
- data/lib/rom-repository.rb +1 -2
- data/lib/rom/repository.rb +9 -216
- data/lib/rom/repository/class_interface.rb +16 -33
- data/lib/rom/repository/relation_reader.rb +46 -0
- data/lib/rom/repository/root.rb +3 -59
- data/lib/rom/repository/version.rb +1 -1
- metadata +9 -98
- data/.gitignore +0 -3
- data/.rspec +0 -3
- data/.travis.yml +0 -27
- data/.yardopts +0 -2
- data/Gemfile +0 -38
- data/Rakefile +0 -19
- data/lib/rom/open_struct.rb +0 -35
- data/lib/rom/repository/changeset.rb +0 -155
- data/lib/rom/repository/changeset/associated.rb +0 -100
- data/lib/rom/repository/changeset/create.rb +0 -16
- data/lib/rom/repository/changeset/delete.rb +0 -17
- data/lib/rom/repository/changeset/pipe.rb +0 -97
- data/lib/rom/repository/changeset/restricted.rb +0 -28
- data/lib/rom/repository/changeset/stateful.rb +0 -282
- data/lib/rom/repository/changeset/update.rb +0 -82
- data/lib/rom/repository/command_compiler.rb +0 -257
- data/lib/rom/repository/command_proxy.rb +0 -26
- data/lib/rom/repository/header_builder.rb +0 -65
- data/lib/rom/repository/mapper_builder.rb +0 -23
- data/lib/rom/repository/relation_proxy.rb +0 -337
- data/lib/rom/repository/relation_proxy/combine.rb +0 -320
- data/lib/rom/repository/relation_proxy/wrap.rb +0 -78
- data/lib/rom/repository/struct_builder.rb +0 -83
- data/lib/rom/struct.rb +0 -113
- data/log/.gitkeep +0 -0
- data/rom-repository.gemspec +0 -23
- data/spec/integration/changeset_spec.rb +0 -193
- data/spec/integration/command_macros_spec.rb +0 -191
- data/spec/integration/command_spec.rb +0 -228
- data/spec/integration/multi_adapter_spec.rb +0 -73
- data/spec/integration/repository/aggregate_spec.rb +0 -58
- data/spec/integration/repository_spec.rb +0 -406
- data/spec/integration/root_repository_spec.rb +0 -106
- data/spec/integration/typed_structs_spec.rb +0 -64
- data/spec/shared/database.rb +0 -79
- data/spec/shared/mappers.rb +0 -35
- data/spec/shared/models.rb +0 -41
- data/spec/shared/plugins.rb +0 -66
- data/spec/shared/relations.rb +0 -115
- data/spec/shared/repo.rb +0 -86
- data/spec/shared/seeds.rb +0 -30
- data/spec/shared/structs.rb +0 -140
- data/spec/spec_helper.rb +0 -83
- data/spec/support/mapper_registry.rb +0 -9
- data/spec/support/mutant.rb +0 -10
- data/spec/unit/changeset/associate_spec.rb +0 -120
- data/spec/unit/changeset/map_spec.rb +0 -111
- data/spec/unit/changeset_spec.rb +0 -186
- data/spec/unit/relation_proxy_spec.rb +0 -202
- data/spec/unit/repository/changeset_spec.rb +0 -197
- data/spec/unit/repository/inspect_spec.rb +0 -18
- data/spec/unit/repository/session_spec.rb +0 -251
- data/spec/unit/repository/transaction_spec.rb +0 -42
- data/spec/unit/session_spec.rb +0 -46
- data/spec/unit/struct_builder_spec.rb +0 -128
data/lib/rom/repository/root.rb
CHANGED
@@ -57,9 +57,9 @@ module ROM
|
|
57
57
|
end
|
58
58
|
|
59
59
|
# @see Repository#initialize
|
60
|
-
def initialize(container,
|
60
|
+
def initialize(container, options = EMPTY_HASH)
|
61
61
|
super
|
62
|
-
@root =
|
62
|
+
@root = set_relation(self.class.root)
|
63
63
|
end
|
64
64
|
|
65
65
|
# Compose a relation aggregate from the root relation
|
@@ -97,63 +97,7 @@ module ROM
|
|
97
97
|
#
|
98
98
|
# @api public
|
99
99
|
def aggregate(*args)
|
100
|
-
|
101
|
-
root.combine(*args)
|
102
|
-
else
|
103
|
-
args.reduce(root) { |a, e| a.combine(e) }
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
# @overload changeset(name, *args)
|
108
|
-
# Delegate to Repository#changeset
|
109
|
-
#
|
110
|
-
# @see Repository#changeset
|
111
|
-
#
|
112
|
-
# @overload changeset(data)
|
113
|
-
# Builds a create changeset for the root relation
|
114
|
-
#
|
115
|
-
# @example
|
116
|
-
# user_repo.changeset(name: "Jane")
|
117
|
-
#
|
118
|
-
# @param data [Hash] New data
|
119
|
-
#
|
120
|
-
# @return [Changeset::Create]
|
121
|
-
#
|
122
|
-
# @overload changeset(primary_key, data)
|
123
|
-
# Builds an update changeset for the root relation
|
124
|
-
#
|
125
|
-
# @example
|
126
|
-
# user_repo.changeset(1, name: "Jane Doe")
|
127
|
-
#
|
128
|
-
# @param primary_key [Object] Primary key for restricting relation
|
129
|
-
#
|
130
|
-
# @return [Changeset::Update]
|
131
|
-
#
|
132
|
-
# @overload changeset(changeset_class)
|
133
|
-
# Return a changeset prepared for repo's root relation
|
134
|
-
#
|
135
|
-
# @example
|
136
|
-
# changeset = user_repo.changeset(MyChangeset)
|
137
|
-
#
|
138
|
-
# changeset.relation == user_repo.root
|
139
|
-
# # true
|
140
|
-
#
|
141
|
-
# @param [Class] changeset_class Your custom changeset class
|
142
|
-
#
|
143
|
-
# @return [Changeset]
|
144
|
-
#
|
145
|
-
# @see Repository#changeset
|
146
|
-
#
|
147
|
-
# @api public
|
148
|
-
def changeset(*args)
|
149
|
-
if args.first.is_a?(Symbol) && relations.key?(args.first)
|
150
|
-
super
|
151
|
-
elsif args.first.is_a?(Class)
|
152
|
-
klass, *rest = args
|
153
|
-
super(klass[klass.relation || self.class.root], *rest)
|
154
|
-
else
|
155
|
-
super(root.name, *args)
|
156
|
-
end
|
100
|
+
root.combine(*args)
|
157
101
|
end
|
158
102
|
end
|
159
103
|
end
|
metadata
CHANGED
@@ -1,63 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rom-repository
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rom
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3.3'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '3.3'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rom-mapper
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
17
|
- - "~>"
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0.5'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: dry-core
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0.3'
|
48
|
-
- - ">="
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: 0.3.1
|
19
|
+
version: 1.0.0.beta
|
51
20
|
type: :runtime
|
52
21
|
prerelease: false
|
53
22
|
version_requirements: !ruby/object:Gem::Requirement
|
54
23
|
requirements:
|
55
24
|
- - "~>"
|
56
25
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 0.3.1
|
26
|
+
version: 1.0.0.beta
|
61
27
|
- !ruby/object:Gem::Dependency
|
62
28
|
name: dry-struct
|
63
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,77 +66,22 @@ dependencies:
|
|
100
66
|
- - "~>"
|
101
67
|
- !ruby/object:Gem::Version
|
102
68
|
version: '3.5'
|
103
|
-
description:
|
104
|
-
relations
|
69
|
+
description: Repository abstraction for rom-rb
|
105
70
|
email: piotr.solnica+oss@gmail.com
|
106
71
|
executables: []
|
107
72
|
extensions: []
|
108
73
|
extra_rdoc_files: []
|
109
74
|
files:
|
110
|
-
- ".gitignore"
|
111
|
-
- ".rspec"
|
112
|
-
- ".travis.yml"
|
113
|
-
- ".yardopts"
|
114
75
|
- CHANGELOG.md
|
115
|
-
-
|
116
|
-
- LICENSE.txt
|
76
|
+
- LICENSE
|
117
77
|
- README.md
|
118
|
-
- Rakefile
|
119
78
|
- lib/rom-repository.rb
|
120
|
-
- lib/rom/open_struct.rb
|
121
79
|
- lib/rom/repository.rb
|
122
|
-
- lib/rom/repository/changeset.rb
|
123
|
-
- lib/rom/repository/changeset/associated.rb
|
124
|
-
- lib/rom/repository/changeset/create.rb
|
125
|
-
- lib/rom/repository/changeset/delete.rb
|
126
|
-
- lib/rom/repository/changeset/pipe.rb
|
127
|
-
- lib/rom/repository/changeset/restricted.rb
|
128
|
-
- lib/rom/repository/changeset/stateful.rb
|
129
|
-
- lib/rom/repository/changeset/update.rb
|
130
80
|
- lib/rom/repository/class_interface.rb
|
131
|
-
- lib/rom/repository/
|
132
|
-
- lib/rom/repository/command_proxy.rb
|
133
|
-
- lib/rom/repository/header_builder.rb
|
134
|
-
- lib/rom/repository/mapper_builder.rb
|
135
|
-
- lib/rom/repository/relation_proxy.rb
|
136
|
-
- lib/rom/repository/relation_proxy/combine.rb
|
137
|
-
- lib/rom/repository/relation_proxy/wrap.rb
|
81
|
+
- lib/rom/repository/relation_reader.rb
|
138
82
|
- lib/rom/repository/root.rb
|
139
83
|
- lib/rom/repository/session.rb
|
140
|
-
- lib/rom/repository/struct_builder.rb
|
141
84
|
- lib/rom/repository/version.rb
|
142
|
-
- lib/rom/struct.rb
|
143
|
-
- log/.gitkeep
|
144
|
-
- rom-repository.gemspec
|
145
|
-
- spec/integration/changeset_spec.rb
|
146
|
-
- spec/integration/command_macros_spec.rb
|
147
|
-
- spec/integration/command_spec.rb
|
148
|
-
- spec/integration/multi_adapter_spec.rb
|
149
|
-
- spec/integration/repository/aggregate_spec.rb
|
150
|
-
- spec/integration/repository_spec.rb
|
151
|
-
- spec/integration/root_repository_spec.rb
|
152
|
-
- spec/integration/typed_structs_spec.rb
|
153
|
-
- spec/shared/database.rb
|
154
|
-
- spec/shared/mappers.rb
|
155
|
-
- spec/shared/models.rb
|
156
|
-
- spec/shared/plugins.rb
|
157
|
-
- spec/shared/relations.rb
|
158
|
-
- spec/shared/repo.rb
|
159
|
-
- spec/shared/seeds.rb
|
160
|
-
- spec/shared/structs.rb
|
161
|
-
- spec/spec_helper.rb
|
162
|
-
- spec/support/mapper_registry.rb
|
163
|
-
- spec/support/mutant.rb
|
164
|
-
- spec/unit/changeset/associate_spec.rb
|
165
|
-
- spec/unit/changeset/map_spec.rb
|
166
|
-
- spec/unit/changeset_spec.rb
|
167
|
-
- spec/unit/relation_proxy_spec.rb
|
168
|
-
- spec/unit/repository/changeset_spec.rb
|
169
|
-
- spec/unit/repository/inspect_spec.rb
|
170
|
-
- spec/unit/repository/session_spec.rb
|
171
|
-
- spec/unit/repository/transaction_spec.rb
|
172
|
-
- spec/unit/session_spec.rb
|
173
|
-
- spec/unit/struct_builder_spec.rb
|
174
85
|
homepage: http://rom-rb.org
|
175
86
|
licenses:
|
176
87
|
- MIT
|
@@ -186,9 +97,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
186
97
|
version: '0'
|
187
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
99
|
requirements:
|
189
|
-
- - "
|
100
|
+
- - ">"
|
190
101
|
- !ruby/object:Gem::Version
|
191
|
-
version:
|
102
|
+
version: 1.3.1
|
192
103
|
requirements: []
|
193
104
|
rubyforge_project:
|
194
105
|
rubygems_version: 2.6.12
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
dist: trusty
|
3
|
-
sudo: required
|
4
|
-
cache: bundler
|
5
|
-
bundler_args: --without yard guard benchmarks tools
|
6
|
-
before_script:
|
7
|
-
- psql -c 'create database rom_repository' -U postgres
|
8
|
-
- rvm get master
|
9
|
-
script: "bundle exec rake ci"
|
10
|
-
after_success:
|
11
|
-
- '[ -d coverage ] && bundle exec codeclimate-test-reporter'
|
12
|
-
rvm:
|
13
|
-
- 2.2.7
|
14
|
-
- 2.3.4
|
15
|
-
- 2.4.1
|
16
|
-
- jruby-9.1.8.0
|
17
|
-
env:
|
18
|
-
global:
|
19
|
-
- JRUBY_OPTS='--dev -J-Xmx1024M'
|
20
|
-
- COVERAGE='true'
|
21
|
-
notifications:
|
22
|
-
webhooks:
|
23
|
-
urls:
|
24
|
-
- https://webhooks.gitter.im/e/39e1225f489f38b0bd09
|
25
|
-
on_success: change
|
26
|
-
on_failure: always
|
27
|
-
on_start: false
|
data/.yardopts
DELETED
data/Gemfile
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
gem 'inflecto'
|
6
|
-
|
7
|
-
group :development do
|
8
|
-
gem 'dry-equalizer', '~> 0.2'
|
9
|
-
gem 'sqlite3', platforms: [:mri, :rbx]
|
10
|
-
gem 'jdbc-sqlite3', platforms: :jruby
|
11
|
-
end
|
12
|
-
|
13
|
-
group :test do
|
14
|
-
gem 'rom', git: 'https://github.com/rom-rb/rom.git', branch: 'release-3.0'
|
15
|
-
gem 'rom-sql', git: 'https://github.com/rom-rb/rom-sql.git', branch: 'release-1.0'
|
16
|
-
gem 'rspec'
|
17
|
-
gem 'dry-struct'
|
18
|
-
gem 'byebug', platforms: :mri
|
19
|
-
gem 'pg', platforms: [:mri, :rbx]
|
20
|
-
gem 'jdbc-postgres', platforms: :jruby
|
21
|
-
|
22
|
-
platform :mri do
|
23
|
-
gem 'codeclimate-test-reporter', require: false
|
24
|
-
gem 'simplecov'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
group :benchmarks do
|
29
|
-
gem 'hotch', platforms: :mri
|
30
|
-
gem 'benchmark-ips'
|
31
|
-
gem 'activerecord', '~> 5.0'
|
32
|
-
end
|
33
|
-
|
34
|
-
group :tools do
|
35
|
-
gem 'pry'
|
36
|
-
gem 'mutant'
|
37
|
-
gem 'mutant-rspec'
|
38
|
-
end
|
data/Rakefile
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rspec/core/rake_task"
|
3
|
-
|
4
|
-
RSpec::Core::RakeTask.new(:spec)
|
5
|
-
task default: [:ci]
|
6
|
-
|
7
|
-
desc "Run CI tasks"
|
8
|
-
task ci: [:spec]
|
9
|
-
|
10
|
-
begin
|
11
|
-
require "rubocop/rake_task"
|
12
|
-
|
13
|
-
Rake::Task[:default].enhance [:rubocop]
|
14
|
-
|
15
|
-
RuboCop::RakeTask.new do |task|
|
16
|
-
task.options << "--display-cop-names"
|
17
|
-
end
|
18
|
-
rescue LoadError
|
19
|
-
end
|
data/lib/rom/open_struct.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
module ROM
|
2
|
-
# ROM's open structs are used for relations with empty schemas.
|
3
|
-
# Such relations may exist in cases like using raw SQL strings
|
4
|
-
# where schema was not explicitly defined using `view` DSL.
|
5
|
-
#
|
6
|
-
# @api public
|
7
|
-
class OpenStruct
|
8
|
-
IVAR = -> v { :"@#{v}" }
|
9
|
-
|
10
|
-
# @api private
|
11
|
-
def initialize(attributes)
|
12
|
-
attributes.each do |key, value|
|
13
|
-
instance_variable_set(IVAR[key], value)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# @api private
|
18
|
-
def respond_to_missing?(meth, include_private = false)
|
19
|
-
super || instance_variables.include?(IVAR[meth])
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
# @api private
|
25
|
-
def method_missing(meth, *args, &block)
|
26
|
-
ivar = IVAR[meth]
|
27
|
-
|
28
|
-
if instance_variables.include?(ivar)
|
29
|
-
instance_variable_get(ivar)
|
30
|
-
else
|
31
|
-
super
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,155 +0,0 @@
|
|
1
|
-
require 'dry/core/class_attributes'
|
2
|
-
require 'dry/core/cache'
|
3
|
-
|
4
|
-
require 'rom/initializer'
|
5
|
-
|
6
|
-
module ROM
|
7
|
-
# Abstract Changeset class
|
8
|
-
#
|
9
|
-
# If you inherit from this class you need to configure additional settings
|
10
|
-
#
|
11
|
-
# @example define a custom changeset using :upsert command
|
12
|
-
# class NewTag < ROM::Changeset[:tags]
|
13
|
-
# command_type :upsert
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# @abstract
|
17
|
-
class Changeset
|
18
|
-
DEFAULT_COMMAND_OPTS = { mapper: false }.freeze
|
19
|
-
|
20
|
-
extend Initializer
|
21
|
-
extend Dry::Core::Cache
|
22
|
-
extend Dry::Core::ClassAttributes
|
23
|
-
|
24
|
-
# @!method self.command_type
|
25
|
-
# Get or set changeset command type
|
26
|
-
#
|
27
|
-
# @overload command_type
|
28
|
-
# Return configured command_type
|
29
|
-
# @return [Symbol]
|
30
|
-
#
|
31
|
-
# @overload command_type(identifier)
|
32
|
-
# Set relation identifier for this changeset
|
33
|
-
# @param [Symbol] identifier The command type identifier
|
34
|
-
# @return [Symbol]
|
35
|
-
defines :command_type
|
36
|
-
|
37
|
-
# @!method self.relation
|
38
|
-
# Get or set changeset relation identifier
|
39
|
-
#
|
40
|
-
# @overload relation
|
41
|
-
# Return configured relation identifier for this changeset
|
42
|
-
# @return [Symbol]
|
43
|
-
#
|
44
|
-
# @overload relation(identifier)
|
45
|
-
# Set relation identifier for this changeset
|
46
|
-
# @param [Symbol] identifier The relation identifier from the ROM container
|
47
|
-
# @return [Symbol]
|
48
|
-
defines :relation
|
49
|
-
|
50
|
-
# @!attribute [r] relation
|
51
|
-
# @return [Relation] The changeset relation
|
52
|
-
param :relation
|
53
|
-
|
54
|
-
# @!attribute [r] command_compiler
|
55
|
-
# @return [Proc] a proc that can compile a command (typically provided by a repo)
|
56
|
-
option :command_compiler, optional: true
|
57
|
-
|
58
|
-
# @!attribute [r] command_type
|
59
|
-
# @return [Symbol] a custom command identifier
|
60
|
-
option :command_type, default: -> { self.class.command_type }
|
61
|
-
|
62
|
-
# Create a changeset class preconfigured for a specific relation
|
63
|
-
#
|
64
|
-
# @example
|
65
|
-
# class NewUserChangeset < ROM::Changeset::Create[:users]
|
66
|
-
# end
|
67
|
-
#
|
68
|
-
# user_repo.changeset(NewUserChangeset).data(name: 'Jane')
|
69
|
-
#
|
70
|
-
# @api public
|
71
|
-
def self.[](relation_name)
|
72
|
-
fetch_or_store([relation_name, self]) {
|
73
|
-
Class.new(self) { relation(relation_name) }
|
74
|
-
}
|
75
|
-
end
|
76
|
-
|
77
|
-
# Return a new changeset with updated options
|
78
|
-
#
|
79
|
-
# @example
|
80
|
-
# class NewUser < ROM::Changeset::Create[:users]
|
81
|
-
# option :token_generator
|
82
|
-
# end
|
83
|
-
#
|
84
|
-
# changeset = user_repo.changeset(NewUser).with(token_generator: my_token_gen)
|
85
|
-
#
|
86
|
-
# @param [Hash] new_options The new options
|
87
|
-
#
|
88
|
-
# @return [Changeset]
|
89
|
-
#
|
90
|
-
# @api public
|
91
|
-
def with(new_options)
|
92
|
-
self.class.new(relation, options.merge(new_options))
|
93
|
-
end
|
94
|
-
|
95
|
-
# Return a new changeset with provided relation
|
96
|
-
#
|
97
|
-
# New options can be provided too
|
98
|
-
#
|
99
|
-
# @param [Relation] relation
|
100
|
-
# @param [Hash] options
|
101
|
-
#
|
102
|
-
# @return [Changeset]
|
103
|
-
#
|
104
|
-
# @api public
|
105
|
-
def new(relation, new_options = EMPTY_HASH)
|
106
|
-
self.class.new(relation, new_options.empty? ? options : options.merge(new_options))
|
107
|
-
end
|
108
|
-
|
109
|
-
# Persist changeset
|
110
|
-
#
|
111
|
-
# @example
|
112
|
-
# changeset = user_repo.changeset(name: 'Jane')
|
113
|
-
# changeset.commit
|
114
|
-
# # => { id: 1, name: 'Jane' }
|
115
|
-
#
|
116
|
-
# @return [Hash, Array]
|
117
|
-
#
|
118
|
-
# @api public
|
119
|
-
def commit
|
120
|
-
command.call
|
121
|
-
end
|
122
|
-
|
123
|
-
# Return string representation of the changeset
|
124
|
-
#
|
125
|
-
# @return [String]
|
126
|
-
#
|
127
|
-
# @api public
|
128
|
-
def inspect
|
129
|
-
%(#<#{self.class} relation=#{relation.name.inspect}>)
|
130
|
-
end
|
131
|
-
|
132
|
-
# Return a command for this changeset
|
133
|
-
#
|
134
|
-
# @return [ROM::Command]
|
135
|
-
#
|
136
|
-
# @api private
|
137
|
-
def command
|
138
|
-
command_compiler.(command_type, relation_identifier, DEFAULT_COMMAND_OPTS)
|
139
|
-
end
|
140
|
-
|
141
|
-
private
|
142
|
-
|
143
|
-
# @api private
|
144
|
-
def relation_identifier
|
145
|
-
relation.name.relation
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
require 'rom/repository/changeset/stateful'
|
151
|
-
require 'rom/repository/changeset/associated'
|
152
|
-
|
153
|
-
require 'rom/repository/changeset/create'
|
154
|
-
require 'rom/repository/changeset/update'
|
155
|
-
require 'rom/repository/changeset/delete'
|