enum_column3 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of enum_column3 might be problematic. Click here for more details.
- data/lib/enum/active_record_helper.rb +4 -4
- data/lib/enum/enum_adapter.rb +10 -3
- metadata +19 -38
@@ -25,16 +25,16 @@ if defined?(ActionView::Base)
|
|
25
25
|
end
|
26
26
|
|
27
27
|
class InstanceTag
|
28
|
-
def to_enum_select_tag(options, html_options={})
|
28
|
+
def to_enum_select_tag(options, html_options={})
|
29
29
|
if self.object.respond_to?(method_name.to_sym)
|
30
|
-
|
30
|
+
column = self.object.column_for_attribute(method_name)
|
31
31
|
if (value = self.object.__send__(method_name.to_sym))
|
32
32
|
options[:selected] ||= value.to_s
|
33
33
|
else
|
34
|
-
options[:include_blank] =
|
34
|
+
options[:include_blank] = column.null if options[:include_blank].nil?
|
35
35
|
end
|
36
36
|
end
|
37
|
-
to_select_tag(
|
37
|
+
to_select_tag(column.limit, options, html_options)
|
38
38
|
end
|
39
39
|
|
40
40
|
#initialize record_name, method, self
|
data/lib/enum/enum_adapter.rb
CHANGED
@@ -1,11 +1,18 @@
|
|
1
|
-
|
2
1
|
# This module provides all the column helper methods to deal with the
|
3
2
|
# values and adds the common type management code for the adapters.
|
4
3
|
|
4
|
+
|
5
|
+
# try rails 3.1, then rails 3.2+, mysql column adapters
|
5
6
|
column_class = if defined? ActiveRecord::ConnectionAdapters::Mysql2Column
|
6
7
|
ActiveRecord::ConnectionAdapters::Mysql2Column
|
7
|
-
|
8
|
+
elsif defined? ActiveRecord::ConnectionAdapters::MysqlColumn
|
8
9
|
ActiveRecord::ConnectionAdapters::MysqlColumn
|
10
|
+
elsif defined? ActiveRecord::ConnectionAdapters::Mysql2Adapter::Column
|
11
|
+
ActiveRecord::ConnectionAdapters::Mysql2Adapter::Column
|
12
|
+
elsif defined? ActiveRecord::ConnectionAdapters::MysqlAdapter::Column
|
13
|
+
ActiveRecord::ConnectionAdapters::MysqlAdapter::Column
|
14
|
+
else
|
15
|
+
ObviousHint::NoMysqlAdapterFound
|
9
16
|
end
|
10
17
|
|
11
18
|
column_class.module_eval do
|
@@ -68,7 +75,7 @@ private
|
|
68
75
|
alias __extract_limit_enum extract_limit
|
69
76
|
def extract_limit(sql_type)
|
70
77
|
if sql_type =~ /^enum/i
|
71
|
-
sql_type.sub(/^enum\('(
|
78
|
+
sql_type.sub(/^enum\('(.+)'\)/i, '\1').split("','").map { |v| v.intern }
|
72
79
|
else
|
73
80
|
__extract_limit_enum(sql_type)
|
74
81
|
end
|
metadata
CHANGED
@@ -1,32 +1,22 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: enum_column3
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 3
|
10
|
-
version: 0.1.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Nick Pohodnya
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-09-16 00:00:00 Z
|
12
|
+
date: 2012-03-15 00:00:00.000000000Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
14
|
description:
|
22
15
|
email:
|
23
16
|
executables: []
|
24
|
-
|
25
17
|
extensions: []
|
26
|
-
|
27
18
|
extra_rdoc_files: []
|
28
|
-
|
29
|
-
files:
|
19
|
+
files:
|
30
20
|
- README.txt
|
31
21
|
- LICENSE
|
32
22
|
- init.rb
|
@@ -47,38 +37,29 @@ files:
|
|
47
37
|
- test/enum_mysql_test.rb
|
48
38
|
homepage: http://github.com/electronick/enum_column
|
49
39
|
licenses: []
|
50
|
-
|
51
40
|
post_install_message:
|
52
41
|
rdoc_options: []
|
53
|
-
|
54
|
-
require_paths:
|
42
|
+
require_paths:
|
55
43
|
- lib
|
56
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
45
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
63
|
-
- 0
|
64
|
-
version: "0"
|
65
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
51
|
none: false
|
67
|
-
requirements:
|
68
|
-
- -
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
|
71
|
-
segments:
|
72
|
-
- 0
|
73
|
-
version: "0"
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
74
56
|
requirements: []
|
75
|
-
|
76
57
|
rubyforge_project:
|
77
|
-
rubygems_version: 1.8.
|
58
|
+
rubygems_version: 1.8.10
|
78
59
|
signing_key:
|
79
60
|
specification_version: 3
|
80
61
|
summary: Enable enum type for MySQL db.
|
81
|
-
test_files:
|
62
|
+
test_files:
|
82
63
|
- test/test_helper.rb
|
83
64
|
- test/db/schema.rb
|
84
65
|
- test/fixtures/enumeration.rb
|