declare_schema 0.13.0.pre.1 → 0.13.0.pre.2

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: fef97a705f29e37659ade688c2c64b30f0df1eabc76ab47ceb1272f2eec10845
4
- data.tar.gz: 3602d932b5bae67c6cfd367750e399d44ab65afa4fd19c4923ff5e447b79ca40
3
+ metadata.gz: 6a0a46f7400412223cb7e7bab356450fa5d0a58cf05ee2c70c1bc6b5d9c91ed1
4
+ data.tar.gz: a3f0ce02021eab5d27dc338634d07d6ac942eae493f868c0ba68850bbb5c0ff9
5
5
  SHA512:
6
- metadata.gz: 770d10d283e399d3ca37537e7ed4c68d0dde1a6ba28e033148ed7ed86d0e0833256d0b2446688538ef34f39cac9c1fe535914824d4bf7e6de17d11554b876ec2
7
- data.tar.gz: 134add2558ab3374d741e04839913257eb48e8b98d4b80a3bc3c35927369032fd9549d9a1dd2768c702386f44b4265c0379475cd01f8097288cad53b479a4ee9
6
+ metadata.gz: d9cc9136bcadb5bd2426ada4419e08e772a6976e98a0c96a6fe2129d79da4917819f4126966c4b1d0056b2b94e948433cfbc4370c7f6b85cab3f0ab9fd0b3c82
7
+ data.tar.gz: e5b96f7e05837c4a142651282381dbc7ad7647b8122946b221befcf858992a755ce0a15bf4f893f6d920353393145b305774f6fb38cab922641fc4f8ebda0f75
data/CHANGELOG.md CHANGED
@@ -6,7 +6,7 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
6
6
 
7
7
  ## [0.13.0] - Unreleased
8
8
  ### Added
9
- - Added support for `default_schema =` to apply a default schema to every model, unless disabld for that model with `declare_schema: false`.
9
+ - Added support for `default_schema` block to apply a default schema to every model, unless disabled for that model with `default_schema: false`.
10
10
 
11
11
  ## [0.12.1] - 2021-05-10
12
12
  ### Fixed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- declare_schema (0.13.0.pre.1)
4
+ declare_schema (0.13.0.pre.2)
5
5
  rails (>= 4.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -72,10 +72,10 @@ end
72
72
 
73
73
  ### default_schema
74
74
  If there are default columns you would like in the schema for every model, you can define them in a block that is registered with
75
- `DeclareSchema.default_schema =`. For example:
75
+ `DeclareSchema.default_schema`. For example:
76
76
 
77
77
  ```ruby
78
- DeclareSchema.default_schema = -> do
78
+ DeclareSchema.default_schema do
79
79
  timestamps
80
80
  optimistic_lock
81
81
  end
@@ -90,6 +90,12 @@ class User < ActiveRecord::Base
90
90
  end
91
91
  ```
92
92
 
93
+ ### clear_default_schema
94
+ This method clears out any previously declared `default_schema`.
95
+ ```ruby
96
+ DeclareSchema.clear_default_schema
97
+ ```
98
+
93
99
  ### Global Configuration
94
100
  Configurations can be set at the global level to customize default declaration for the following values:
95
101
 
@@ -37,7 +37,7 @@ module DeclareSchema
37
37
 
38
38
  class << self
39
39
  attr_reader :default_charset, :default_collation, :default_text_limit, :default_string_limit, :default_null,
40
- :default_generate_foreign_keys, :default_generate_indexing, :default_schema, :db_migrate_command
40
+ :default_generate_foreign_keys, :default_generate_indexing, :db_migrate_command
41
41
 
42
42
  def to_class(type)
43
43
  case type
@@ -85,9 +85,17 @@ module DeclareSchema
85
85
  @default_generate_indexing = generate_indexing
86
86
  end
87
87
 
88
- def default_schema=(default_schema)
89
- default_schema.nil? || default_schema.respond_to?(:call) or raise "default_schema must be nil or a block that responds to call"
90
- @default_schema = default_schema
88
+ def default_schema(&block)
89
+ if block.nil?
90
+ @default_schema # equivalent to attr_reader :default_schema
91
+ else
92
+ block.respond_to?(:call) or raise "default_schema must be passed a block that responds to call"
93
+ @default_schema = block
94
+ end
95
+ end
96
+
97
+ def clear_default_schema
98
+ @default_schema = nil
91
99
  end
92
100
 
93
101
  def db_migrate_command=(db_migrate_command)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeclareSchema
4
- VERSION = "0.13.0.pre.1"
4
+ VERSION = "0.13.0.pre.2"
5
5
  end
@@ -2507,11 +2507,11 @@ RSpec.describe 'DeclareSchema Migration Generator' do
2507
2507
  end
2508
2508
 
2509
2509
  before do
2510
- DeclareSchema.default_schema = default_schema_block
2510
+ DeclareSchema.default_schema(&default_schema_block)
2511
2511
  end
2512
2512
 
2513
2513
  after do
2514
- DeclareSchema.default_schema = nil
2514
+ DeclareSchema.clear_default_schema
2515
2515
  end
2516
2516
 
2517
2517
  context 'when unset' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: declare_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0.pre.1
4
+ version: 0.13.0.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca Development adapted from hobo_fields by Tom Locke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-06 00:00:00.000000000 Z
11
+ date: 2021-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails