Commits

Toby Inkster committed 895853b

move from lvalue.pm to LV

  • Participants
  • Parent commits 6a91d6a

Comments (0)

Files changed (1)

 use Carp;
 use JSON qw[from_json];
 use Scalar::Util qw[blessed];
-use lvalue ();
+use LV ();
 
 use Sub::Exporter -setup => {
 	exports => [qw/ jpath jpath1 jpath_map /],
 	] unless ref $path;
 	$path = [ map { /^'(.+)'$/ ? $1 : $_ } @$path ];
 	
-	while (@$path > 1) {
+	while (@$path > 1)
+	{
 		my $chunk = shift @$path;
 		if (JSON::Path::Helper::isObject($obj))
 			{ $obj = $obj->{$chunk} }
 	}
 	
 	my $chunk = shift @$path;
-	lvalue::get {
-		if (JSON::Path::Helper::isObject($obj))
-			{ $obj = $obj->{$chunk} }
-		elsif (JSON::Path::Helper::isArray($obj))
-			{ $obj = $obj->[$chunk] }
-		else
-			{ print "hUh?" }
-	}
-	lvalue::set {
-		if (JSON::Path::Helper::isObject($obj))
-			{ $obj->{$chunk} = shift }
-		elsif (JSON::Path::Helper::isArray($obj))
-			{ $obj->[$chunk] = shift }
-		else
-			{ print "huH?" }
-	}
+	
+	LV::lvalue(
+		get => sub
+		{
+			if (JSON::Path::Helper::isObject($obj))
+				{ $obj = $obj->{$chunk} }
+			elsif (JSON::Path::Helper::isArray($obj))
+				{ $obj = $obj->[$chunk] }
+			else
+				{ print "hUh?" }
+		},
+		set => sub
+		{
+			if (JSON::Path::Helper::isObject($obj))
+				{ $obj->{$chunk} = shift }
+			elsif (JSON::Path::Helper::isArray($obj))
+				{ $obj->[$chunk] = shift }
+			else
+				{ print "huH?" }
+		},
+	);
 }
 
 sub paths
 sub value :lvalue
 {
 	my ($self, $object) = @_;
-	lvalue::get {
-		my ($value) = $self->get($object);
-		return $value;
-	}
-	lvalue::set {
-		my $value = shift;
-		$self->set($object, $value, 1);
-	}
+	LV::lvalue(
+		get => sub
+		{
+			my ($value) = $self->get($object);
+			return $value;
+		},
+		set => sub
+		{
+			my $value = shift;
+			$self->set($object, $value, 1);
+		},
+	);
 }
 
 sub values