The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Venus::Role::Reflectable - Reflectable Role

ABSTRACT

Reflectable Role for Perl 5

SYNOPSIS

package Example;

use Venus::Class;

with 'Venus::Role::Reflectable';

sub test {
  true
}

package main;

my $example = Example->new;

# $example->space;

DESCRIPTION

This package modifies the consuming package and provides methods for introspecting the object and its underlying package.

METHODS

This package provides the following methods:

class

class() (string)

The class method returns the class name for the given class or object.

Since 0.01

class example 1
# given: synopsis;

my $class = $example->class;

# "Example"

meta

meta() (Venus::Meta)

The meta method returns a Venus::Meta object for the given object.

Since 1.23

meta example 1
# given: synopsis;

my $meta = $example->meta;

# bless({name => "Example"}, "Venus::Meta")

reify

reify(string | coderef $code, any @args) (object)

The reify method dispatches the method call or executes the callback and returns the result as a value object.

Since 1.23

reify example 1
# given: synopsis

package main;

my $reify = $example->reify;

# bless({}, "Example")
reify example 2
# given: synopsis

package main;

my $reify = $example->reify('class');

# bless({value => "Example"}, "Venus::String")
reify example 3
# given: synopsis

package main;

my $reify = $example->reify('test');

# bless({value => 1}, "Venus::Boolean")

space

space() (Venus::Space)

The space method returns a Venus::Space object for the given object.

Since 0.01

space example 1
# given: synopsis;

my $space = $example->space;

# bless({ value => "Example" }, "Venus::Space")

type

type(string | coderef $code, any @args) (Venus::Type)

The type method dispatches the method call or executes the callback and returns the result as a Venus::Type object.

Since 0.01

type example 1
# given: synopsis;

my $type = $example->type;

# bless({ value => bless({}, "Example") }, "Venus::Type")
type example 2
# given: synopsis;

my $type = $example->type('class');

# bless({ value => "Example" }, "Venus::Type")

AUTHORS

Awncorp, awncorp@cpan.org

LICENSE

Copyright (C) 2022, Awncorp, awncorp@cpan.org.

This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.