The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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() (Str)

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() (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(Str | 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() (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(Str | CodeRef $code, Any @args) (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")