From 4375d98c462c64931073669223a992b368db88ba Mon Sep 17 00:00:00 2001 From: Ryan VanMaele Date: Fri, 10 Apr 2015 15:32:18 -0500 Subject: [PATCH 1/2] Move alias lines from before to after where the method they are aliasing is defined. Allows gem to work in with Rails 4.2 on Ruby 2.2.0. -Lambenttelos --- lib/enum/enum_adapter.rb | 14 +++++++------- lib/enum/mysql_adapter.rb | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/enum/enum_adapter.rb b/lib/enum/enum_adapter.rb index a58b4c4..5818eba 100644 --- a/lib/enum/enum_adapter.rb +++ b/lib/enum/enum_adapter.rb @@ -17,7 +17,7 @@ column_class.module_eval do - alias __klass_enum klass + # The class for enum is Symbol. def klass if type == :enum @@ -26,8 +26,8 @@ def klass __klass_enum end end + alias __klass_enum klass - alias __type_cast_enum type_cast # Convert to a symbol. def type_cast(value) if type == :enum @@ -36,9 +36,9 @@ def type_cast(value) __type_cast_enum(value) end end + alias __type_cast_enum type_cast if respond_to?(:type_cast_code) - alias __type_cast_code_enum type_cast_code # Code to convert to a symbol. def type_cast_code(var_name) if type == :enum @@ -47,6 +47,7 @@ def type_cast_code(var_name) __type_cast_code_enum(var_name) end end + alias __type_cast_code_enum type_cast_code end class << self @@ -64,7 +65,6 @@ def value_to_symbol(value) end private - alias __simplified_type_enum simplified_type # The enum simple type. def simplified_type(field_type) if field_type =~ /enum/i @@ -73,8 +73,8 @@ def simplified_type(field_type) __simplified_type_enum(field_type) end end - - alias __extract_limit_enum extract_limit + alias __simplified_type_enum simplified_type + def extract_limit(sql_type) if sql_type =~ /^enum/i sql_type.sub(/^enum\('(.+)'\)/i, '\1').split("','").map { |v| v.intern } @@ -82,6 +82,6 @@ def extract_limit(sql_type) __extract_limit_enum(sql_type) end end - + alias __extract_limit_enum extract_limit end diff --git a/lib/enum/mysql_adapter.rb b/lib/enum/mysql_adapter.rb index 7ce64d5..ee1619d 100644 --- a/lib/enum/mysql_adapter.rb +++ b/lib/enum/mysql_adapter.rb @@ -7,11 +7,12 @@ end adapter_class.module_eval do - alias __native_database_types_enum native_database_types def native_database_types #:nodoc types = __native_database_types_enum types[:enum] = { :name => "enum" } types end + alias __native_database_types_enum native_database_types + end \ No newline at end of file From 64a01ef507d4150e508769dd33faf8b01ebcea72 Mon Sep 17 00:00:00 2001 From: Ryan VanMaele Date: Fri, 10 Apr 2015 15:58:38 -0500 Subject: [PATCH 2/2] Minor version bump. -Lambenttelos --- enum_column.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enum_column.gemspec b/enum_column.gemspec index ec33446..4a3ddf6 100644 --- a/enum_column.gemspec +++ b/enum_column.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = %q{enum_column3} - s.version = "0.1.4" + s.version = "0.1.5" s.authors = ['Nick Pohodnya'] s.files = [