| 1 | package WiX3::XML::Property; | ||
| 2 | |||
| 3 | use 5.008003; | ||
| 4 | |||
| 5 | # Must be done before Moose, or it won't get picked up. | ||
| 6 | use metaclass ( | ||
| 7 | metaclass => 'Moose::Meta::Class', | ||
| 8 | error_class => 'WiX3::Util::Error', | ||
| 9 | ); | ||
| 10 | use Moose 2; | ||
| 11 | use Params::Util qw( _STRING ); | ||
| 12 | use MooseX::Types::Moose qw( Maybe Str Undef ); | ||
| 13 | use WiX3::Util::StrictConstructor; | ||
| 14 | use WiX3::Types qw( YesNoType ); | ||
| 15 | |||
| 16 | our $VERSION = '0.011'; | ||
| 17 | |||
| 18 | ## This needs changed later, but no children for now. | ||
| 19 | with 'WiX3::XML::Role::Tag', 'WiX3::XML::Role::InnerText'; | ||
| 20 | |||
| 21 | # http://wix.sourceforge.net/manual-wix3/wix_xsd_property.htm | ||
| 22 | |||
| 23 | ##################################################################### | ||
| 24 | # Accessors | ||
| 25 | |||
| 26 | has id => ( | ||
| 27 | is => 'ro', | ||
| 28 | isa => Str, | ||
| 29 | reader => 'get_id', | ||
| 30 | required => 1, | ||
| 31 | ); | ||
| 32 | |||
| 33 | has admin => ( | ||
| 34 | is => 'ro', | ||
| 35 | isa => YesNoType | Undef, | ||
| 36 | reader => '_get_admin', | ||
| 37 | default => undef, | ||
| 38 | coerce => 1, | ||
| 39 | ); | ||
| 40 | |||
| 41 | has compliance_check => ( | ||
| 42 | is => 'ro', | ||
| 43 | isa => YesNoType | Undef, | ||
| 44 | reader => '_get_compliance_check', | ||
| 45 | default => undef, | ||
| 46 | coerce => 1, | ||
| 47 | ); | ||
| 48 | |||
| 49 | has hidden => ( | ||
| 50 | is => 'ro', | ||
| 51 | isa => YesNoType | Undef, | ||
| 52 | reader => '_get_hidden', | ||
| 53 | default => undef, | ||
| 54 | coerce => 1, | ||
| 55 | ); | ||
| 56 | |||
| 57 | has secure => ( | ||
| 58 | is => 'ro', | ||
| 59 | isa => YesNoType | Undef, | ||
| 60 | reader => '_get_secure', | ||
| 61 | default => undef, | ||
| 62 | coerce => 1, | ||
| 63 | ); | ||
| 64 | |||
| 65 | has suppress_modularization => ( | ||
| 66 | is => 'ro', | ||
| 67 | isa => YesNoType | Undef, | ||
| 68 | reader => '_get_suppress_modularization', | ||
| 69 | default => undef, | ||
| 70 | coerce => 1, | ||
| 71 | ); | ||
| 72 | |||
| 73 | has value => ( | ||
| 74 | is => 'ro', | ||
| 75 | isa => Maybe [Str], | ||
| 76 | reader => '_get_value', | ||
| 77 | default => undef, | ||
| 78 | ); | ||
| 79 | |||
| 80 | ##################################################################### | ||
| 81 | # Methods to implement the Tag role. | ||
| 82 | |||
| 83 | sub as_string { | ||
| 84 | my $self = shift; | ||
| 85 | |||
| 86 | # Print tag. | ||
| 87 | my $string = '<Property'; | ||
| 88 | |||
| 89 | my @attribute = ( | ||
| 90 | [ 'Id' => $self->get_id(), ], | ||
| 91 | [ 'Admin' => $self->_get_admin(), ], | ||
| 92 | [ 'ComplianceCheck' => $self->_get_compliance_check(), ], | ||
| 93 | [ 'Hidden' => $self->_get_hidden(), ], | ||
| 94 | [ 'Secure' => $self->_get_secure(), ], | ||
| 95 | [ 'Type' => $self->_get_suppress_modularization(), ], | ||
| 96 | [ 'Value' => $self->_get_value(), ], | ||
| 97 | ); | ||
| 98 | |||
| 99 | my ( $k, $v ); | ||
| 100 | |||
| 101 | foreach my $ref (@attribute) { | ||
| 102 | ( $k, $v ) = @{$ref}; | ||
| 103 | $string .= $self->print_attribute( $k, $v ); | ||
| 104 | } | ||
| 105 | |||
| 106 | $string .= $self->inner_text_as_string('Property'); | ||
| 107 | |||
| 108 | return $string; | ||
| 109 | } ## end sub as_string | ||
| 110 | |||
| 111 | sub get_namespace { | ||
| 112 | return q{xmlns='http://schemas.microsoft.com/wix/2006/wi'}; | ||
| 113 | } | ||
| 114 | |||
| 115 | no Moose; | ||
| 116 | __PACKAGE__->meta->make_immutable; | ||
| 117 | |||
| 118 | 1; | ||
| 119 | |||
| 120 | __END__ |