rails_string_enum 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/rails_string_enum/pg_enum_migration.rb +1 -1
- data/lib/rails_string_enum/version.rb +2 -2
- data/rails_string_enum.gemspec +1 -1
- metadata +2 -3
- data/rails_string_enum-0.1.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 986addb093d78bdf5042d43d71cce5150b94a4ad
|
4
|
+
data.tar.gz: 6a3f472c4a55fa02b07e0a0c1569e96723ce365e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11ae83a79b88a6863b2e9c14d9e8b0c5215a1153f5d9a8262cc8de72e1581068ff63adfa8894a6a1c6110ad7bc95b546f2a83e1ebb29d599c43cc8b8499ff94d
|
7
|
+
data.tar.gz: 516c3e01ff5db63fa7cb62ad97f614454a50f1ea043cce11ad289677e4cfb5db24fe59f90ce21c88ed5f302c4e0b2ed7887856bb6a6eefbc901a17ddb2b47488
|
data/README.md
CHANGED
@@ -30,7 +30,7 @@ reorder_enum_values :order_state_enum, %w(black white) # other color will be lat
|
|
30
30
|
|
31
31
|
delete_enum_value :color, 'black'
|
32
32
|
# you should delete record with deleting value
|
33
|
-
# if exists index with condition method raise
|
33
|
+
# if exists index with condition, method raise exception
|
34
34
|
# "ERROR: operator does not exist: order_type_enum <> order_type_enum_new"
|
35
35
|
# you should first remove and then create an index
|
36
36
|
Product.where(color: 'black').delete_all # or Product.where(color: 'black').update_all(state: nil)
|
@@ -41,7 +41,7 @@ delete_enum_value :color, 'black'
|
|
41
41
|
|
42
42
|
###### Convert exist columns (int, string) to postgresql enum
|
43
43
|
```ruby
|
44
|
-
string_to_enums :product, :color, enum_name: 'product_color_enum', definitions: %w(red green blue)
|
44
|
+
string_to_enums :product, :color, enum_name: 'product_color_enum', definitions: %w(red green blue), default: 'green'
|
45
45
|
string_to_enums :product, :color, enum_name: 'product_color_enum', definitions: Product.uniq.pluck(:color)
|
46
46
|
|
47
47
|
int_to_enums :product, :color, enum_name: 'product_color_enum', definitions: { red: 0, green: 1, blue: 2 }
|
@@ -65,7 +65,7 @@ class CreateTables < ActiveRecord::Migration
|
|
65
65
|
end
|
66
66
|
|
67
67
|
class Product < ActiveRecord::Base
|
68
|
-
string_enum :color, %w(red green yellow black white),
|
68
|
+
string_enum :color, %w(red green yellow black white), scopes: true # default false
|
69
69
|
|
70
70
|
def self.colored
|
71
71
|
where.not(color: [COLOR::BLACK, COLOR::WHITE])
|
@@ -87,7 +87,7 @@ Product::COLOR::GREEN # => "green"
|
|
87
87
|
|
88
88
|
Product.color_i18n_for('red') # => 'Красный'
|
89
89
|
Product.colors_i18n # => {green: 'Зеленый', red: 'Красный', yellow: 'Желтый'}
|
90
|
-
Product.red # if
|
90
|
+
Product.red # if scopes: true
|
91
91
|
```
|
92
92
|
|
93
93
|
|
@@ -130,7 +130,7 @@ module PgEnumMigrations
|
|
130
130
|
|
131
131
|
execute "CREATE TYPE #{enum_name(enum_name, schema)} AS ENUM (#{escape_enum_values(keys)})" unless use_exist_enum
|
132
132
|
|
133
|
-
default_sql = ", ALTER COLUMN #{col_name}
|
133
|
+
default_sql = ", ALTER COLUMN #{col_name} SET DEFAULT '#{default}'" if default
|
134
134
|
|
135
135
|
execute <<-SQL
|
136
136
|
ALTER TABLE #{table}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module RailsStringEnum
|
2
|
-
VERSION = "0.1.
|
3
|
-
end
|
2
|
+
VERSION = "0.1.2"
|
3
|
+
end
|
data/rails_string_enum.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'rails_string_enum/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "rails_string_enum"
|
8
8
|
spec.version = RailsStringEnum::VERSION
|
9
|
-
spec.authors = ["
|
9
|
+
spec.authors = ["ermolaev"]
|
10
10
|
spec.email = ["andrey@ermolaev.me"]
|
11
11
|
|
12
12
|
spec.summary = %q{support in rails db enums or string (using as flexible enum)}
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_string_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- ermolaev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
@@ -70,7 +70,6 @@ files:
|
|
70
70
|
- lib/rails_string_enum/simple_form.rb
|
71
71
|
- lib/rails_string_enum/string_enum.rb
|
72
72
|
- lib/rails_string_enum/version.rb
|
73
|
-
- rails_string_enum-0.1.0.gem
|
74
73
|
- rails_string_enum.gemspec
|
75
74
|
homepage: https://github.com/ermolaev/rails_string_enum
|
76
75
|
licenses:
|
data/rails_string_enum-0.1.0.gem
DELETED
Binary file
|