diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2013-09-20 07:29:38 -0700 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2013-09-20 07:29:38 -0700 |
commit | 218c089ae7fd997fda23cc604f18df95c58d31b0 (patch) | |
tree | 4a118590a374e5a490e9c4cdfded617250afa50b /activesupport | |
parent | 76d36458eadcb32c233f44065fccfbbef9a58119 (diff) | |
parent | 1afe1aeba528249fc6be8bda4dad6a4dd243646d (diff) | |
download | rails-218c089ae7fd997fda23cc604f18df95c58d31b0.tar.gz rails-218c089ae7fd997fda23cc604f18df95c58d31b0.tar.bz2 rails-218c089ae7fd997fda23cc604f18df95c58d31b0.zip |
Merge pull request #12299 from hitendrasingh/code_refactor
DRYing up method_missing code; Initializing Codepoint object with default values
Diffstat (limited to 'activesupport')
-rwxr-xr-x | activesupport/bin/generate_tables | 6 | ||||
-rw-r--r-- | activesupport/lib/active_support/multibyte/chars.rb | 3 | ||||
-rw-r--r-- | activesupport/lib/active_support/multibyte/unicode.rb | 7 |
3 files changed, 8 insertions, 8 deletions
diff --git a/activesupport/bin/generate_tables b/activesupport/bin/generate_tables index 5fefa429df..f39e89b7d0 100755 --- a/activesupport/bin/generate_tables +++ b/activesupport/bin/generate_tables @@ -28,12 +28,6 @@ module ActiveSupport def initialize @ucd = Unicode::UnicodeDatabase.new - - default = Codepoint.new - default.combining_class = 0 - default.uppercase_mapping = 0 - default.lowercase_mapping = 0 - @ucd.codepoints = Hash.new(default) end def parse_codepoints(line) diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb index a42e7f6542..3c0cf9f137 100644 --- a/activesupport/lib/active_support/multibyte/chars.rb +++ b/activesupport/lib/active_support/multibyte/chars.rb @@ -56,11 +56,10 @@ module ActiveSupport #:nodoc: # Forward all undefined methods to the wrapped string. def method_missing(method, *args, &block) + result = @wrapped_string.__send__(method, *args, &block) if method.to_s =~ /!$/ - result = @wrapped_string.__send__(method, *args, &block) self if result else - result = @wrapped_string.__send__(method, *args, &block) result.kind_of?(String) ? chars(result) : result end end diff --git a/activesupport/lib/active_support/multibyte/unicode.rb b/activesupport/lib/active_support/multibyte/unicode.rb index 04e6b71580..1845c6ae38 100644 --- a/activesupport/lib/active_support/multibyte/unicode.rb +++ b/activesupport/lib/active_support/multibyte/unicode.rb @@ -287,6 +287,13 @@ module ActiveSupport class Codepoint attr_accessor :code, :combining_class, :decomp_type, :decomp_mapping, :uppercase_mapping, :lowercase_mapping + # Initializing Codepoint object with default values + def initialize + @combining_class = 0 + @uppercase_mapping = 0 + @lowercase_mapping = 0 + end + def swapcase_mapping uppercase_mapping > 0 ? uppercase_mapping : lowercase_mapping end |