| 1 | package Chef::Recipe; | ||
| 2 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Moose; | ||
| 7 | use JSON; | ||
| 8 | use Data::Dumper; | ||
| 9 | |||
| 10 | has 'resource_collection' => | ||
| 11 | ( is => 'rw', isa => 'ArrayRef', default => sub { [] } ); | ||
| 12 | |||
| 13 | sub add_resource { | ||
| 14 | my $self = shift; | ||
| 15 | |||
| 16 | foreach my $resource (@_) { | ||
| 17 | push( @{ $self->{'resource_collection'} }, $resource ); | ||
| 18 | } | ||
| 19 | |||
| 20 | 1; | ||
| 21 | } | ||
| 22 | |||
| 23 | sub prepare_json { | ||
| 24 | my $self = shift; | ||
| 25 | my @resource_collection; | ||
| 26 | foreach my $resource ( @{ $self->resource_collection } ) { | ||
| 27 | push( @resource_collection, $resource->prepare_json ); | ||
| 28 | } | ||
| 29 | return \@resource_collection; | ||
| 30 | } | ||
| 31 | |||
| 32 | =head1 COPYRIGHT & LICENSE | ||
| 33 | |||
| 34 | Copyright 2009 Opscode, Inc., all rights reserved. | ||
| 35 | |||
| 36 | This program is free software; you can redistribute it and/or modify it | ||
| 37 | under the same terms as Perl itself. | ||
| 38 | |||
| 39 | |||
| 40 | =cut | ||
| 41 | |||
| 42 | 1; |