Skip to content

Commit

Permalink
handles NoMethodError: undefined method `include?' for :@__weak_backr…
Browse files Browse the repository at this point in the history
…eferences__:Symbol
  • Loading branch information
codeinvain committed Sep 2, 2013
1 parent f82cb3b commit e82fdbd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions lib/libphonenumber-execjs/libphonenumber.rb
Expand Up @@ -67,11 +67,15 @@ def get_e164_phone_number(str, cc=nil, ndc=nil)

def get_e164_with_region(str, cc=nil, ndc=nil)
result = {}
phone_with_meta = @context.call "getE164PhoneNumberWithMeta", str, cc, ndc
phone_with_meta = ["",""] if phone_with_meta.empty?
result[:e164] = phone_with_meta[0]
result[:region] = @context.eval "i18n.phonenumbers.PhoneNumberUtil.getInstance().getRegionCodeForCountryCode(#{make_param(phone_with_meta[1])})"
result[:region].downcase! unless result[:region].nil?
begin
phone_with_meta = @context.call "getE164PhoneNumberWithMeta", str, cc, ndc
phone_with_meta = ["",""] if phone_with_meta.empty?
result[:e164] = phone_with_meta[0]
result[:region] = @context.eval "i18n.phonenumbers.PhoneNumberUtil.getInstance().getRegionCodeForCountryCode(#{make_param(phone_with_meta[1])})"
result[:region].downcase! unless result[:region].nil?
rescue
result={:e164=>"",:region=>""}
end
result
end

Expand Down
2 changes: 1 addition & 1 deletion lib/libphonenumber-execjs/version.rb
@@ -1,3 +1,3 @@
class Libphonenumber
VERSION = "0.0.4"
VERSION = "0.0.5"
end

0 comments on commit e82fdbd

Please sign in to comment.