Fuse::Template::Root - Root filesystem object


Fuse-Template documentation Contained in the Fuse-Template distribution.

Index


Code Index:

NAME

Top

Fuse::Template::Root - Root filesystem object

SYNOPSIS

Top

    package Class;
    # will import RootObject typeconstraint
    use Fuse::Template::Root qw/RootObject/;
    has foo => ( isa => RootObject, coerce => 1 );
    ...

    package main;

    # same result:
    my $obj = Class->new( foo => { path => $some_root } );
    my $obj = Class->new( foo => $some_root );
    my $obj = Class->new(
                  foo => Fuse::Template::Root->new({
                      path => $some_root
                  }),
              );

DESCRIPTION

Top

The RootObject can coerce either Str and HashRef into a Fuse::Template::Root object. The HashRef will be used as object constructor, while the Str will be set as path attribute.

ATTRIBUTES

Top

path

Holds a string representing the path to where the template files exist. This attribute is required.

mode

Holds the file mode for the target mount directory. Default value is 0775. (octal value)

uid

The user id of who owns the target mount path. Defaults to the $REAL_USER_ID

gid

The group id of who owns the target mount path. Defaults to the first integer from $REAL_GROUP_ID.

ctime

Last change time of the target mount path. Defaults to time when the object got created.

mtime

Last modify time of the target mount path. Defaults to time when the object got created.

atime

Last access time of the target mount path. Defaults to time when the object got created.

block_size

Preferred block size for file system I/O. Defaults to 1024. (The default value might change)

AUTHOR

Top

See Fuse::Template


Fuse-Template documentation Contained in the Fuse-Template distribution.
package Fuse::Template::Root;

use Moose;
use MooseX::Types -declare => [qw/RootObject/];
use MooseX::Types::Moose qw(:all);
use overload q("") => sub { shift->path }, fallback => 1;

subtype RootObject, as Object;
coerce RootObject, (
    from Str,     via { Fuse::Template::Root->new(path => $_) },
    from HashRef, via { Fuse::Template::Root->new($_) },
);

has path => (
    is => 'ro',
    isa => 'Str',
    required => 1,
);

has mode => (
    is => 'ro',
    isa => 'Int',
    default => 0775,
);

around mode => sub {
    my $next = shift;
    my $self = shift;

    return @_ ? $self->$next((0040 << 9) + $_[0]) : $self->$next;
};

has uid => (
    is => 'ro',
    isa => 'Int',
    default => $<,
);

has gid => (
    is => 'ro',
    isa => 'Int',
    default => sub { $( =~ /(\d+)/ },
);

has ctime => (
    is => 'ro',
    isa => 'Int',
    default => time,
);

has mtime => (
    is => 'ro',
    isa => 'Int',
    default => time,
);

has atime => (
    is => 'ro',
    isa => 'Int',
    default => time,
);

has block_size => (
    is => 'ro',
    isa => 'Int',
    default => 1024,
);

1;