diff options
Diffstat (limited to 'lib/Data/MultiValued/AttributeTrait/Ranges.pm')
-rw-r--r-- | lib/Data/MultiValued/AttributeTrait/Ranges.pm | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Data/MultiValued/AttributeTrait/Ranges.pm b/lib/Data/MultiValued/AttributeTrait/Ranges.pm index 2b9a0ff..a629f11 100644 --- a/lib/Data/MultiValued/AttributeTrait/Ranges.pm +++ b/lib/Data/MultiValued/AttributeTrait/Ranges.pm @@ -39,12 +39,30 @@ Returns C<('from', 'to')>. Returns C<('at')>. +=head2 C<all_ranges> + + my @ranges = $obj->meta->get_attribute('my_attr')->all_ranges($obj); + +Returns a list of 2-element arrayrefs, each arrayref describing the +extremes of a range. Something like: + + [ [undef,10], [10,20], [20,undef] ] + =cut sub multivalue_storage_class { 'Data::MultiValued::Ranges' }; sub opts_to_pass_set { qw(from to) } sub opts_to_pass_get { qw(at) } +sub all_ranges { + my ($self,$instance) = @_; + + my $storage = $self->get_full_storage($instance); + return unless $storage; + + return $storage->_storage->all_ranges; +} + package Moose::Meta::Attribute::Custom::Trait::MultiValued::Ranges;{ sub register_implementation { 'Data::MultiValued::AttributeTrait::Ranges' } } |