Browse files

Added practical stringification of Language (locale) and Location (co…

…untry_code)
  • Loading branch information...
1 parent bf46432 commit 7ed02ae005161c7306354a3c4285fdda4b1d836e @Getty Getty committed Jan 13, 2013
Showing with 10 additions and 0 deletions.
  1. +5 −0 lib/DDG/Language.pm
  2. +5 −0 lib/DDG/Location.pm
View
5 lib/DDG/Language.pm
@@ -30,4 +30,9 @@ has $_ => (
default => sub { '' }
) for (@language_attributes);
+use overload '""' => sub {
+ my $self = shift;
+ return $self->locale;
+}, fallback => 1;
+
1;
View
5 lib/DDG/Location.pm
@@ -33,4 +33,9 @@ has geo_ip_record => (
predicate => 'has_geo_ip_record',
);
+use overload '""' => sub {
+ my $self = shift;
+ return $self->country_code;
+}, fallback => 1;
+
1;

0 comments on commit 7ed02ae

Please sign in to comment.