NAME

JMAP::Tester::Response::Paragraph - a group of sentences in a JMAP response

VERSION

version 0.103

OVERVIEW

These objects represent paragraphs in the JMAP response. That is, if your response is:

[
  [ "messages", { ... }, "a" ],      # 1
  [ "smellUpdates", { ... }, "b" ],  # 2
  [ "smells",       { ... }, "b" ],  # 3
]

...then #1 forms one paragraph and #2 and #3 together form another. It goes by matching client ids.

PERL VERSION

This library should run on perls released even a long time ago. It should work on any version of perl released in the last five years.

Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.

METHODS

sentences

The sentences method returns a list of Sentence objects, one for each sentence in the paragraph.

sentence

my $sentence = $para->sentence($n);

This method returns the nth sentence of the paragraph.

single

my $sentence = $para->single;
my $sentence = $para->single($name);

This method throws an exception if there is more than one sentence in the paragraph. If a $name argument is given and the paragraph's single sentence doesn't have that name, an exception is raised.

Otherwise, this method returns the sentence.

assert_n_sentences

my ($s1, $s2, ...) = $paragraph->assert_n_sentences($n);

This method returns all the sentences in the paragarph, as long as there are exactly $n. Otherwise, it aborts.

sentence_named

my $sentence = $paragraph->sentence_named($name);

This method returns the sentence with the given name. If no such sentence exists, or if two sentences with the name exist, the tester will abort.

as_triples

as_stripped_triples

as_triples returns an arrayref containing the result of calling as_triple on each sentence in the paragraph. as_stripped_triples removes JSON types.

as_pairs

as_pairs returns an arrayref containing the result of calling as_pair on each sentence in the paragraph. as_stripped_pairs removes JSON types.

AUTHOR

Ricardo SIGNES <cpan@semiotic.systems>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Fastmail Pty. Ltd.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.