pg_serializable 1.4.0 → 2.0.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
  SHA256:
3
- metadata.gz: a4a5cdf3d08ff52acb34ee418e7288b830154d98c572f85cb83d07cd6c8e9d28
4
- data.tar.gz: 075d6e05706f868bb0871201a40594c5bb85bbe80dd5fc8663308fb0a5d32f60
3
+ metadata.gz: 63d160c9c9813d6cd0cfb694af1d3f3b16f542cad5d0ced046d6b12ba52f4857
4
+ data.tar.gz: 1d1d71c4935b37e899f2e13514df90aa468f9d29c69b398cf4fe710cf94a3c68
5
5
  SHA512:
6
- metadata.gz: ad13d0f61c3d611ec91ebc0074adcf3a49be8ca3f9ce3c5d73e8557f0b2928a3fb74c3f1ae3c9fbe17e75ec30db92af539add503189efac7dcf40bbeb32a31a9
7
- data.tar.gz: 3f7c59fd5f2a376a4155bf4028ec82daaacfa4d2ff9f3115f39b5a6980f883955a1716a4606aa686830a509d3c7d141922f2b9041b47f55de32b31cd7c411800
6
+ metadata.gz: 1b8307eecd420d164389ca4e04556c131e2e13d478023b0d38e70ae68498306559659a8370ea59234719d9e931c3a19a95c6ace42f2c686c99bcf5535b298bbf
7
+ data.tar.gz: 75d931172e41d8fb860744d4582df3b18f1aa6c868bcd5d8167ff38c720b814533e92824dc28ae7b25d493df19e5a378ce730a16cec5270f0fe6bb7cd8c2ccd3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pg_serializable (1.4.0)
4
+ pg_serializable (2.0.0)
5
5
  activerecord (~> 5.2)
6
6
  activesupport (~> 5.2)
7
7
  oj (~> 3.6)
data/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # PgSerializable
2
2
  [![codecov](https://codecov.io/gh/matthewjf/pg_serializable/branch/master/graph/badge.svg)](https://codecov.io/gh/matthewjf/pg_serializable)
3
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/f3450fdd21d38e2a2fe6/maintainability)](https://codeclimate.com/github/matthewjf/pg_serializable/maintainability)
4
+ [![Gem Version](https://badge.fury.io/rb/pg_serializable.svg)](https://badge.fury.io/rb/pg_serializable)
4
5
 
5
6
  ## Description
6
7
 
7
8
  Serialize json directly from postgres (9.4+).
8
9
 
9
- ## Why?
10
+ ## Motivation
10
11
  Models:
11
12
  ```ruby
12
13
  class Product < ApplicationRecord
@@ -103,6 +104,18 @@ Or install it yourself as:
103
104
 
104
105
  $ gem install pg_serializable
105
106
 
107
+ ## Configuration
108
+
109
+ To ensure traits are valid during rails initialization instead of when accessed:
110
+ ```ruby
111
+ # config/initializers/pg_serializable.rb
112
+ PgSerializable.validate_traits!
113
+ ```
114
+
115
+ ## Migrating from version 1 to 2
116
+
117
+ Trait validations were occasionally running before the class's traits were loaded when there are complex dependencies. These were moved out of the class definition. To maintain existing behavior, add `PgSerializable.validate_traits!` to an initializer. See [configuration](#Configuration).
118
+
106
119
  ## Usage
107
120
 
108
121
  In your model:
@@ -1,3 +1,3 @@
1
1
  module PgSerializable
2
- VERSION = "1.4.0"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -21,6 +21,15 @@ end
21
21
  module PgSerializable
22
22
  extend ActiveSupport::Concern
23
23
 
24
+ def self.validate_traits!
25
+ ActiveRecord::Base.descendants.each do |klass|
26
+ begin
27
+ klass.validate_traits!
28
+ rescue NoMethodError, ActiveRecord::NoDatabaseError
29
+ end
30
+ end
31
+ end
32
+
24
33
  included do
25
34
  include Visitable
26
35
 
@@ -36,10 +45,6 @@ module PgSerializable
36
45
 
37
46
  def serializable(&blk)
38
47
  trait_manager.instance_eval &blk
39
- begin
40
- validate_traits!
41
- rescue ActiveRecord::NoDatabaseError
42
- end
43
48
  end
44
49
 
45
50
  def trait_manager
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_serializable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - matthewjf
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-04 00:00:00.000000000 Z
11
+ date: 2019-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler