dg-enum_column4 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/enum/enum_adapter.rb +7 -5
- data/lib/enum_column.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f29b2d49a85690941bbf4b773794b71600a0df9
|
4
|
+
data.tar.gz: b595fd448840ea9eaff02dc6e4e6e4ebe69007e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cada23dcb44ee462e35dc1815c24187db4f5160e812c408818e1fc78d6a83be777621504a7f6ea19e7671fa5bb28dda667105f42543957a79d5dcc27a0921fe
|
7
|
+
data.tar.gz: 3d2b0c9a9a57e7cf68d1eeec7af650de4aace16d1fc1198396b211562523ac1bc7291a3ec3cfb1b2727857fd70ed54c417ff69c70ba50fb7bad880ff9392e3f9
|
data/lib/enum/enum_adapter.rb
CHANGED
@@ -16,6 +16,8 @@ else
|
|
16
16
|
end
|
17
17
|
|
18
18
|
column_class.module_eval do
|
19
|
+
|
20
|
+
alias __klass_enum klass
|
19
21
|
# The class for enum is Symbol.
|
20
22
|
def klass
|
21
23
|
if type == :enum
|
@@ -24,8 +26,8 @@ column_class.module_eval do
|
|
24
26
|
__klass_enum
|
25
27
|
end
|
26
28
|
end
|
27
|
-
alias __klass_enum klass
|
28
29
|
|
30
|
+
alias __type_cast_enum type_cast
|
29
31
|
# Convert to a symbol.
|
30
32
|
def type_cast(value)
|
31
33
|
if type == :enum
|
@@ -34,9 +36,9 @@ column_class.module_eval do
|
|
34
36
|
__type_cast_enum(value)
|
35
37
|
end
|
36
38
|
end
|
37
|
-
alias __type_cast_enum type_cast
|
38
39
|
|
39
40
|
if respond_to?(:type_cast_code)
|
41
|
+
alias __type_cast_code_enum type_cast_code
|
40
42
|
# Code to convert to a symbol.
|
41
43
|
def type_cast_code(var_name)
|
42
44
|
if type == :enum
|
@@ -45,7 +47,6 @@ column_class.module_eval do
|
|
45
47
|
__type_cast_code_enum(var_name)
|
46
48
|
end
|
47
49
|
end
|
48
|
-
alias __type_cast_code_enum type_cast_code
|
49
50
|
end
|
50
51
|
|
51
52
|
class << self
|
@@ -63,6 +64,7 @@ column_class.module_eval do
|
|
63
64
|
end
|
64
65
|
|
65
66
|
private
|
67
|
+
alias __simplified_type_enum simplified_type
|
66
68
|
# The enum simple type.
|
67
69
|
def simplified_type(field_type)
|
68
70
|
if field_type =~ /enum/i
|
@@ -71,8 +73,8 @@ private
|
|
71
73
|
__simplified_type_enum(field_type)
|
72
74
|
end
|
73
75
|
end
|
74
|
-
alias __simplified_type_enum simplified_type
|
75
76
|
|
77
|
+
alias __extract_limit_enum extract_limit
|
76
78
|
def extract_limit(sql_type)
|
77
79
|
if sql_type =~ /^enum/i
|
78
80
|
sql_type.sub(/^enum\('(.+)'\)/i, '\1').split("','").map { |v| v.intern }
|
@@ -80,6 +82,6 @@ private
|
|
80
82
|
__extract_limit_enum(sql_type)
|
81
83
|
end
|
82
84
|
end
|
83
|
-
|
85
|
+
|
84
86
|
|
85
87
|
end
|
data/lib/enum_column.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
if defined?(::Rails::Railtie)
|
2
2
|
class EnumColumnRailtie < Rails::Railtie
|
3
|
-
initializer 'enum_column.initialize', :after => 'active_record.initialize_database' do |app|
|
3
|
+
# initializer 'enum_column.initialize', :after => 'active_record.initialize_database' do |app|
|
4
4
|
ActiveSupport.on_load :active_record do
|
5
5
|
require 'enum/mysql_adapter'
|
6
6
|
require 'enum/enum_adapter'
|
@@ -13,6 +13,6 @@ if defined?(::Rails::Railtie)
|
|
13
13
|
ActiveSupport.on_load :action_view do
|
14
14
|
require 'enum/active_record_helper'
|
15
15
|
end
|
16
|
-
end
|
16
|
+
# end
|
17
17
|
end
|
18
18
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dg-enum_column4
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Pohodnya
|
@@ -9,9 +9,9 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-05-
|
12
|
+
date: 2015-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: Enum column support for Rails 4
|
14
|
+
description: Enum column support for Rails 4.1
|
15
15
|
email:
|
16
16
|
- chalofa@gmail.com
|
17
17
|
executables: []
|