NAME

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

VERSION

version 0.100

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.

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 <rjbs@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by FastMail, 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.