| 1 | package Net::Google::DocumentsList::Revision; | ||
| 2 | use Any::Moose; | ||
| 3 | use Net::Google::DocumentsList::Types; | ||
| 4 | use Net::Google::DataAPI; | ||
| 5 | use XML::Atom::Util qw(first); | ||
| 6 | use String::CamelCase qw(camelize); | ||
| 7 | with 'Net::Google::DocumentsList::Role::EntryWithoutEtag'; | ||
| 8 | |||
| 9 | entry_has 'updated' => ( | ||
| 10 | is => 'ro', | ||
| 11 | isa => 'Net::Google::DocumentsList::Types::DateTime', | ||
| 12 | tagname => 'updated', | ||
| 13 | coerce => 1, | ||
| 14 | ); | ||
| 15 | |||
| 16 | feedurl item => ( | ||
| 17 | is => 'ro', | ||
| 18 | as_content_src => 1, | ||
| 19 | entry_class => 'Net::Google::DocumentsList::Item', | ||
| 20 | ); | ||
| 21 | |||
| 22 | has 'kind' => (is => 'ro', isa => 'Str', default => 'revision'); | ||
| 23 | |||
| 24 | for my $attr (qw(publish publish_auto publish_outside_domain)) { | ||
| 25 | my $tag = lcfirst camelize($attr); | ||
| 26 | entry_has $attr => ( | ||
| 27 | is => 'rw', | ||
| 28 | isa => 'Bool', | ||
| 29 | default => sub {0}, | ||
| 30 | from_atom => sub { | ||
| 31 | my ($self, $atom) = @_; | ||
| 32 | my $elem = first($atom->elem, $self->ns('docs')->{uri}, $tag) or return 0; | ||
| 33 | return $elem->getAttribute('value') eq "true" ? 1 : 0; | ||
| 34 | }, | ||
| 35 | to_atom => sub { | ||
| 36 | my ($self, $atom) = @_; | ||
| 37 | $atom->set($self->ns('docs'),$tag, '', {value => $self->$attr ? "true" : "false"}); | ||
| 38 | } | ||
| 39 | ); | ||
| 40 | } | ||
| 41 | |||
| 42 | entry_has publish_url => ( | ||
| 43 | is => 'ro', | ||
| 44 | from_atom => sub { | ||
| 45 | my ($self, $atom) = @_; | ||
| 46 | warn $atom->as_xml; | ||
| 47 | warn $_->href for $atom->link; | ||
| 48 | my ($url) = grep { | ||
| 49 | $_->rel eq 'http://schemas.google.com/docs/2007#publish' | ||
| 50 | } $atom->link or return; | ||
| 51 | return $url->href; | ||
| 52 | } | ||
| 53 | ); | ||
| 54 | |||
| 55 | with 'Net::Google::DocumentsList::Role::Exportable'; | ||
| 56 | |||
| 57 | __PACKAGE__->meta->make_immutable; | ||
| 58 | |||
| 59 | no Any::Moose; | ||
| 60 | |||
| 61 | 1; | ||
| 62 | __END__ |