schema_plus_core 0.2.1 → 0.3.0
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 +4 -4
- data/README.md +18 -1
- data/lib/schema_plus/core/active_record/base.rb +28 -0
- data/lib/schema_plus/core/middleware.rb +5 -0
- data/lib/schema_plus/core/version.rb +1 -1
- data/spec/middleware_spec.rb +10 -0
- data/spec/support/test_reporter.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4b3d7025a34fb4913c6ec1bac138771edf66ef7
|
4
|
+
data.tar.gz: dc72bc7e1db359648b55957127946402f625c3ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e585ae20a489a633f49635467122452c215e5aba2c5e35a3a49fc616ef62cb7b539b52df9b25bb6cebbafa7c0e89d00ced22e11728810acaa30498d0750fc5d6
|
7
|
+
data.tar.gz: 003aaf743a991da00c00f4ba57c78ff544c9acdc3967c2356dc1f38324530a11dc75f6c9ea5023753f3df42bdcb614e2aead18fcbab2b736e88c76da8d0c6d06
|
data/README.md
CHANGED
@@ -162,6 +162,21 @@ Stacks for class methods on ActiveRecord models.
|
|
162
162
|
|
163
163
|
The base implementation performs the reset.
|
164
164
|
|
165
|
+
* `Model::Association::Declaration`
|
166
|
+
|
167
|
+
Wrapper around the `Model.has_many`, `Model.has_and_belongs_to_many`, `Model.has_one`, and
|
168
|
+
`Model.belongs_to` methods
|
169
|
+
|
170
|
+
Env Field | Description | Initialized
|
171
|
+
--- | --- | ---
|
172
|
+
`:model` | The model Class being defined | *context*
|
173
|
+
`:name` | The name of the association being defined. | *arg*
|
174
|
+
`:scope` | The scope lambda associated with the association | *arg*
|
175
|
+
`:options` | Options associated with the association. | *arg*
|
176
|
+
`:extension` | Extensions to the association to be made. | *arg*
|
177
|
+
|
178
|
+
The base implementation creates the association.
|
179
|
+
|
165
180
|
### Migration
|
166
181
|
|
167
182
|
Stacks for operations that change the schema. In some cases the operation immediately modifies the database schema, in others the operation defines ActiveRecord objects (e.g., column definitions in a create_table definition) and the actual modification of the database schema will happen some time later.
|
@@ -418,9 +433,11 @@ SchemaPlus::Core provides a state object and of callbacks to various phases of t
|
|
418
433
|
|
419
434
|
The base method appends the collection of SchemaDump::Table::Index objects to `env.table.indexes`
|
420
435
|
|
421
|
-
|
422
436
|
## History
|
423
437
|
|
438
|
+
* 0.3.0 Added `Model::Association::Declaration`
|
439
|
+
* 0.2.1 Added `Migration::CreateTable` and `Schema::Define`; removed dependency on (defunct) `schema_monkey_rails` gem. [Oops, this should have been a minor version bump]
|
440
|
+
* 0.2.0 Added `Migration::DropTable`
|
424
441
|
* 0.1.0 Initial release
|
425
442
|
|
426
443
|
## Development & Testing
|
@@ -15,6 +15,34 @@ module SchemaPlus
|
|
15
15
|
super
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
19
|
+
def has_many(name, scope = nil, options = {}, &extension)
|
20
|
+
SchemaMonkey::Middleware::Model::Association::Declaration.start(model: self, name: name, scope: scope, options: options, extension: extension) do
|
21
|
+
|env|
|
22
|
+
super(env.name, env.scope, env.options, &env.extension)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def has_one(name, scope = nil, options = {}, &extension)
|
27
|
+
SchemaMonkey::Middleware::Model::Association::Declaration.start(model: self, name: name, scope: scope, options: options, extension: extension) do
|
28
|
+
|env|
|
29
|
+
super(env.name, env.scope, env.options, &env.extension)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def has_and_belongs_to_many(name, scope = nil, options = {}, &extension)
|
34
|
+
SchemaMonkey::Middleware::Model::Association::Declaration.start(model: self, name: name, scope: scope, options: options, extension: extension) do
|
35
|
+
|env|
|
36
|
+
super(env.name, env.scope, env.options, &env.extension)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def belongs_to(name, scope = nil, options = {}, &extension)
|
41
|
+
SchemaMonkey::Middleware::Model::Association::Declaration.start(model: self, name: name, scope: scope, options: options, extension: extension) do
|
42
|
+
|env|
|
43
|
+
super(env.name, env.scope, env.options, &env.extension)
|
44
|
+
end
|
45
|
+
end
|
18
46
|
end
|
19
47
|
end
|
20
48
|
end
|
data/spec/middleware_spec.rb
CHANGED
@@ -104,6 +104,16 @@ describe SchemaMonkey::Middleware do
|
|
104
104
|
Then { expect_middleware { Thing.reset_column_information } }
|
105
105
|
end
|
106
106
|
|
107
|
+
context TestReporter::Middleware::Model::Association::Declaration do
|
108
|
+
Then do
|
109
|
+
class Thingamajig < ActiveRecord::Base; end
|
110
|
+
expect_middleware { Thingamajig.has_many :things, class_name: Thing.name }
|
111
|
+
expect_middleware { Thingamajig.has_one :thing, class_name: Thing.name }
|
112
|
+
expect_middleware { Thingamajig.belongs_to :another_thing, class_name: Thing.name }
|
113
|
+
expect_middleware { Thingamajig.has_and_belongs_to_many :other_things, class_name: Thing.name }
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
107
117
|
end
|
108
118
|
|
109
119
|
context SchemaMonkey::Middleware::Dumper do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_plus_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ronen barzel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|