Skip to content

Move alias lines from before to after where the method they are aliasing... #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion enum_column.gemspec
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
14 changes: 7 additions & 7 deletions lib/enum/enum_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

column_class.module_eval do

alias __klass_enum klass

# The class for enum is Symbol.
def klass
if type == :enum
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -73,15 +73,15 @@ 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 }
else
__extract_limit_enum(sql_type)
end
end

alias __extract_limit_enum extract_limit

end
3 changes: 2 additions & 1 deletion lib/enum/mysql_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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