lib/phonelib/core.rb in phonelib-0.4.6 vs lib/phonelib/core.rb in phonelib-0.4.7
- old
+ new
@@ -4,19 +4,27 @@
# variable will include hash with data for validation
@@phone_data = nil
# getter for phone data for other modules of gem, can be used outside
def phone_data
- @@phone_data ||= load_data
+ @@phone_data ||= load_data.freeze
end
+ # used to cache frequently-used regular expressions
+ @@phone_regexp_cache = {}
+
+ # getter for phone regexp cache (internal use only)
+ def phone_regexp_cache
+ @@phone_regexp_cache
+ end
+
# variable for storing geo/carrier/timezone data
@@phone_ext_data = nil
# getter for extended phone data
def phone_ext_data
- @@phone_ext_data ||= load_ext_data
+ @@phone_ext_data ||= load_ext_data.freeze
end
# default country for parsing variable setting
@@default_country = nil
@@ -74,9 +82,11 @@
VALID_PATTERN = :national_number_pattern
# Possible regex pattern key
POSSIBLE_PATTERN = :possible_number_pattern
# National prefix key
NATIONAL_PREFIX = :national_prefix
+ # National prefix for parsing key
+ NATIONAL_PREFIX_FOR_PARSING = :national_prefix_for_parsing
# National prefix rule key
NATIONAL_PREFIX_RULE = :national_prefix_formatting_rule
# Country code key
COUNTRY_CODE = :country_code
# Leading digits key