schema_plus_core 0.2.1 → 0.3.0

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
  SHA1:
3
- metadata.gz: 7c429be6c02483276cfb59a812bb4cc5f25b2177
4
- data.tar.gz: 72cc5ab39f8876bf2d334c21f6ea6daa0198ba1f
3
+ metadata.gz: e4b3d7025a34fb4913c6ec1bac138771edf66ef7
4
+ data.tar.gz: dc72bc7e1db359648b55957127946402f625c3ca
5
5
  SHA512:
6
- metadata.gz: f840686e345770edaa13e50ae1aa6eddf6a921020567bb8b0ef5edce4f3006a33cb4975d58ca9350e9772889e31900a18f8981ca3282558a868548d1214b944a
7
- data.tar.gz: 6886022c5232b16f8e6700ff5eee18ac9c09041ef2e28a68a66eed27468811be321d48e0900a23fa2167bad15d3f620cf2d1aa7bbdfeae54a74badef38cea47c
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
@@ -80,6 +80,11 @@ module SchemaPlus
80
80
  module ResetColumnInformation
81
81
  ENV = [:model]
82
82
  end
83
+ module Association
84
+ module Declaration
85
+ ENV = [:model, :name, :scope, :options, :extension]
86
+ end
87
+ end
83
88
  end
84
89
  end
85
90
  end
@@ -1,5 +1,5 @@
1
1
  module SchemaPlus
2
2
  module Core
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -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
@@ -46,6 +46,9 @@ module TestReporter
46
46
  module Model
47
47
  module Columns ; include Notify ; end
48
48
  module ResetColumnInformation ; include Notify ; end
49
+ module Association
50
+ module Declaration ; include Notify ; end
51
+ end
49
52
  end
50
53
 
51
54
  module Dumper
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.2.1
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-02-27 00:00:00.000000000 Z
11
+ date: 2015-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord