transient_record 2.0.0.rc1 → 2.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/transient_record.rb +17 -5
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf204f3cad36d8d1e2f81a174b617293491fd05a05c0db723ba65fc8bf2dbb9e
|
4
|
+
data.tar.gz: b9beca98152782d6946e531418497d68e1cf94f590e7437ffcc3e98d3cefb3b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37c95fe8e6f9ed85a0d64ae11f17e66d241dbcb728574215315b545085cbeba1d37097554cf6bf178b047cce9864aff07cc0681dfec8249363dcbd2f71e7bfed
|
7
|
+
data.tar.gz: 9eced5b248a14742aca7ae9f06b08df15962eb36ee023112b7e63755c7533a186165e8293d90e0fba19aac3ebcb23854483d99a14b46befb5912054b85077c18
|
data/README.md
CHANGED
@@ -133,7 +133,7 @@ Models are automatically assigned to constants. In the example above, the user
|
|
133
133
|
model is assigned to `Primary::User` via code roughly equivalent to:
|
134
134
|
|
135
135
|
```ruby
|
136
|
-
class
|
136
|
+
class Primary::User < ActiveRecord::Base
|
137
137
|
validates :email, presence: true
|
138
138
|
end
|
139
139
|
```
|
data/lib/transient_record.rb
CHANGED
@@ -72,7 +72,7 @@
|
|
72
72
|
# event = Analytics::Event.new
|
73
73
|
class TransientRecord
|
74
74
|
# Transient Record version number.
|
75
|
-
VERSION = "2.0.0.
|
75
|
+
VERSION = "2.0.0.rc2"
|
76
76
|
|
77
77
|
# A class representing Transient Record errors.
|
78
78
|
class Error < RuntimeError; end
|
@@ -162,6 +162,9 @@ class TransientRecord
|
|
162
162
|
# from the class the context corresponds to and with class body defined by
|
163
163
|
# the block passed to the method.
|
164
164
|
#
|
165
|
+
# The base class can be customized by passing in a second argument, but it
|
166
|
+
# **must** be a subclass of the context's base class.
|
167
|
+
#
|
165
168
|
# Transient models must be removed explicitly by calling {.cleanup} or
|
166
169
|
# {#cleanup}.
|
167
170
|
#
|
@@ -180,12 +183,21 @@ class TransientRecord
|
|
180
183
|
#
|
181
184
|
#
|
182
185
|
# @param model_name [String, Symbol] name of model to define.
|
186
|
+
# @param base_class [Class] base class the model should inherit from
|
183
187
|
#
|
184
188
|
# @yield class definition
|
185
189
|
#
|
186
190
|
# @return [nil]
|
187
|
-
def define_model model_name, &block
|
188
|
-
|
191
|
+
def define_model model_name, base_class = nil, &block
|
192
|
+
base_class ||= @base_class
|
193
|
+
|
194
|
+
if base_class > @base_class
|
195
|
+
raise Error.new(<<~ERROR)
|
196
|
+
#{model_name} base class is #{base_class.name} but it must be a descendant of #{@base_class.name}
|
197
|
+
ERROR
|
198
|
+
end
|
199
|
+
|
200
|
+
klass = Class.new base_class
|
189
201
|
const_set model_name, klass
|
190
202
|
|
191
203
|
klass.class_eval(&block) if block_given?
|
@@ -248,8 +260,8 @@ class TransientRecord
|
|
248
260
|
@table_name = table_name
|
249
261
|
end
|
250
262
|
|
251
|
-
def define_model &block
|
252
|
-
@context.define_model @table_name.to_s.classify, &block
|
263
|
+
def define_model *args, &block
|
264
|
+
@context.define_model @table_name.to_s.classify, *args, &block
|
253
265
|
end
|
254
266
|
end
|
255
267
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transient_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Navis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.9.28
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webrick
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.8.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.8.1
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rubocop
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|