pg_activerecord_enum 0.0.8 → 0.0.9

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: 5c935443cf985dc960c450b36e3dc707be98f39a
4
- data.tar.gz: c1e576ba086da3d7073e59021b9a10d74cb8af46
3
+ metadata.gz: 86899f2fd76d82fd51e37a540b7548211d07d167
4
+ data.tar.gz: 469fb6907906238115839004d2f5c667ddf127dc
5
5
  SHA512:
6
- metadata.gz: 6d7abfc93d1ab1fc90ffb5bdb40c459df8ff8c8d3c85940785f4d87c38f6c88a9773639ad564a5cdaf16e7422b0046023dc43d09294ecf7d1de04cab440b8056
7
- data.tar.gz: 5e008cc8b2490a478b8b879a95c3e72bf01e236fd8877bdb1384193c6c3ed594803b6f221848215b3f5d1a2efdf37f758b860f8d0839f63f9ba5d68effc68fc7
6
+ metadata.gz: cf1b2dfb1b84d758e4a54db7ead10e447e3443364c682e6d46e13fc311b6a96de0c120a1c394a835630aaed883dcd2226a42406cfeb54cbbd1329d3477d69c20
7
+ data.tar.gz: 7572c4c9b29ecb5e86b5172927a9d616e433e869ec130b441e868b4b6409fba97147f3cdee913810d804774b0ed8d1a68b90d675672e5bd11f2b9571911abf86
data/README.md CHANGED
@@ -48,7 +48,7 @@ Or for existing table:
48
48
  ```ruby
49
49
  class CreateFruits < ActiveRecord::Migration[5.1]
50
50
  def change
51
- add_enum :fruits, :color, values: %i[red green yellow], allow_blank: true
51
+ add_enum :fruits, :color, values: %i[red green yellow orange], allow_blank: true
52
52
  end
53
53
  end
54
54
  ```
@@ -62,19 +62,19 @@ Model:
62
62
  ```ruby
63
63
  class Fruit < ApplicationRecord
64
64
  pg_enum :fruit_type
65
- pg_enum :color
65
+ pg_enum :color, _prefix: true
66
66
  end
67
67
  ```
68
68
 
69
69
  ```ruby
70
70
  Fruit.banana.count # 0
71
71
  banana = Fruit.banana.create
72
- banana.yellow!
73
72
  banana.banana? # true
74
- banana.color # "yellow"
75
- banana.grape! #
76
- banana.grape? # true
77
- Fruit.grape.count # 1
73
+ banana.orange! #
74
+ banana.orange? # true
75
+ Fruit.orange.count # 1
76
+ banana.color_orange!
77
+ banana.color # "orange"
78
78
  ```
79
79
 
80
80
  In PostgreSQL DB:
@@ -67,9 +67,9 @@ WHERE t.typname = '#{name}'
67
67
  "'#{values.join("', '")}'"
68
68
  end
69
69
 
70
- def pg_enum(name)
70
+ def pg_enum(name, options = {})
71
71
  enum_values = PgActiveRecordEnum.values_for(name).reject(&:blank?)
72
- enum name => enum_values.zip(enum_values).to_h
72
+ enum({name => enum_values.zip(enum_values).to_h}.merge(options))
73
73
  end
74
74
  end
75
75
 
@@ -1,3 +1,3 @@
1
1
  module PgActiveRecordEnum
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_activerecord_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - inpego
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-20 00:00:00.000000000 Z
11
+ date: 2018-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler