package Reaction::InterfaceModel::Reflector::DBIC;
use aliased 'Reaction::InterfaceModel::Action::DBIC::ResultSet::Create';
+use aliased 'Reaction::InterfaceModel::Action::DBIC::ResultSet::DeleteAll';
use aliased 'Reaction::InterfaceModel::Action::DBIC::Result::Update';
use aliased 'Reaction::InterfaceModel::Action::DBIC::Result::Delete';
class DBIC, which {
+ has make_classes_immutable => (isa => "Bool", is => "rw", required => 1, default => sub{ 1 });
+
#user defined actions and prototypes
has object_actions => (isa => "HashRef", is => "rw", lazy_build => 1);
has collection_actions => (isa => "HashRef", is => "rw", lazy_build => 1);
implements build_builtin_object_actions => as {
{
- Update => { base => Update },
- Delete => { base => Delete, attributes => [] },
+ Update => { name => 'Update', base => Update },
+ Delete => { name => 'Delete', base => Delete, attributes => [] },
};
};
implements build_builtin_collection_actions => as {
- { Create => {base => Create } };
+ {
+ Create => {name => 'Create', base => Create },
+ DeleteAll => {name => 'DeleteAll', base => DeleteAll }
+ };
};
implements _all_object_actions => as {
my $sources = $self->parse_reflect_rules($rules, $haystack);
- my $make_immutable = $meta->is_immutable;
+ my $make_immutable = $meta->is_immutable || $self->make_classes_immutable;
$meta->make_mutable if $meta->is_immutable;
$meta->add_domain_model
unless( $reader ){
$reader = $source;
$reader =~ s/([a-z0-9])([A-Z])/${1}_${2}/g ;
- $reader = lc($reader) . "_collection";
+ $reader = lc($reader) . "_collection"; #XXX change to not use _collection ?
}
unless( $dm_name ){
my @haystack = $meta->domain_models;
my $meta = eval { Class::MOP::load_class($class) } ?
$class->meta : $base->meta->create( $class, superclasses => [ $base ]);
- my $make_immutable = $meta->is_immutable;
+ my $make_immutable = $meta->is_immutable || $self->make_classes_immutable;;
$meta->make_mutable if $meta->is_immutable;
$meta->add_method(_build_im_class => sub{ $object } );
#XXX as a default pass the domain model as a target_model until i come up with something
for my $action (keys %$actions){
my $action_opts = $self->merge_hashes
($all_actions->{$action} || {}, $actions->{$action} || {});
+
+ #NOTE: If the name of the action is not specified in the prototype then use it's
+ #hash key as the name. I think this is sane beahvior, but I've actually been thinking
+ #of making Action prototypes their own separate objects
$self->reflect_source_action(
name => $action,
object_class => $object,
$dm_opts->{is} ||= 'rw';
$dm_opts->{required} ||= 1;
- my $make_immutable = $meta->is_immutable;
+ my $make_immutable = $meta->is_immutable || $self->make_classes_immutable;;
$meta->make_mutable if $meta->is_immutable;
my $dm_attr = $meta->add_domain_model($dm_name, %$dm_opts);
for my $action (keys %$actions){
my $action_opts = $self->merge_hashes
($all_actions->{$action} || {}, $actions->{$action} || {});
+
+ #NOTE: If the name of the action is not specified in the prototype then use it's
+ #hash key as the name. I think this is sane beahvior, but I've actually been thinking
+ #of making Action prototypes their own separate objects
$self->reflect_source_action(
name => $action,
object_class => $class,
#create the class
my $meta = eval { Class::MOP::load_class($class) } ?
$class->meta : $base->meta->create($class, superclasses => [$base]);
- my $make_immutable = $meta->is_immutable;
+ my $make_immutable = $meta->is_immutable || $self->make_classes_immutable;
$meta->make_mutable if $meta->is_immutable;
for my $attr_name (keys %$attributes){