#!/usr/bin/perl
#use Mooix::Thing;
#use Mooix::Root;
run sub {
	my $this=shift;

	# Note that we might sometimes be given data separated by
	# newlines, while sometimes it will be a list of lines.
	if (@_ == 1) {
		@_=split("\n", shift);
	}
	
	# Empty data is ok. So is data identical to the current data
	# (which lets the edit_verb, which writes to test before editing,
	# work).
	return @_ unless grep length, @_;
	my $current=join("\n", $this->data);
	my $new=join("\n", @_);
	if ($current eq $new) {
		return @_;
	}

	$this->objects('');
	
	my @err = $this->check($this->parse(map { (line => $_) } @_));
	if (@err) {
		# Don't lose their carefully entered data.
		$this->data(@_);
		fail @err;
	}
	
	return @_;
}
