[Jifty-commit] r2123 - in jifty/trunk: lib/Jifty lib/Jifty/Web/Form
lib/Jifty/Web/Form/Field
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Nov 9 12:32:46 EST 2006
Author: schwern
Date: Thu Nov 9 12:32:45 2006
New Revision: 2123
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Request.pm
jifty/trunk/lib/Jifty/Result.pm
jifty/trunk/lib/Jifty/Web/Form/Element.pm
jifty/trunk/lib/Jifty/Web/Form/Field.pm
jifty/trunk/lib/Jifty/Web/Form/Field/Combobox.pm
Log:
r25452 at windhund: schwern | 2006-11-09 12:32:15 -0500
Change the accessor generation for overriden accessors to use _foo_accessor()
rather than declare _foo and wrap it with foo(). This is the preferred
way to override Class::Accessor accessors and avoids having to special case
each overriden accessor.
Take the list of properties in the Jifty::Web::Form::Field POD and make them
real accessors. I'm not 100% sure they should all be declared, but some
are documented yet undeclared. constructor is declared and documented in
Jifty::Param so maybe it should be removed from Field. Anyhow, better to
have a maintained list of accessors than an unmaintained comment.
Modified: jifty/trunk/lib/Jifty/Request.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Request.pm (original)
+++ jifty/trunk/lib/Jifty/Request.pm Thu Nov 9 12:32:45 2006
@@ -4,7 +4,7 @@
package Jifty::Request;
use base qw/Jifty::Object Class::Accessor::Fast/;
-__PACKAGE__->mk_accessors(qw(_top_request arguments just_validating path continuation_id continuation_type continuation_path));
+__PACKAGE__->mk_accessors(qw(top_request arguments just_validating path continuation_id continuation_type continuation_path));
use Jifty::JSON;
use Jifty::YAML;
@@ -837,7 +837,7 @@
sub is_subrequest {
my $self = shift;
- return $self->_top_request ? 1 : undef;
+ return $self->_top_request_accessor ? 1 : undef;
}
=head2 top_request
@@ -850,8 +850,8 @@
sub top_request {
my $self = shift;
- $self->_top_request(@_) if @_;
- return $self->_top_request || $self;
+ $self->_top_request_accessor(@_) if @_;
+ return $self->_top_request_accessor || $self;
}
package Jifty::Request::Action;
Modified: jifty/trunk/lib/Jifty/Result.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Result.pm (original)
+++ jifty/trunk/lib/Jifty/Result.pm Thu Nov 9 12:32:45 2006
@@ -19,7 +19,7 @@
use base qw/Jifty::Object Class::Accessor::Fast/;
-__PACKAGE__->mk_accessors(qw(failure action_class message _content));
+__PACKAGE__->mk_accessors(qw(failure action_class message content));
=head2 new
@@ -35,7 +35,7 @@
my $self = bless {}, $class;
$self->failure(0);
- $self->_content({});
+ $self->_content_accessor({});
return $self;
}
@@ -146,11 +146,11 @@
sub content {
my $self = shift;
- return $self->_content unless @_;
+ return $self->_content_accessor unless @_;
my $key = shift;
- $self->_content->{$key} = shift if @_;
- return $self->_content->{$key};
+ $self->_content_accessor->{$key} = shift if @_;
+ return $self->_content_accessor->{$key};
}
1;
Modified: jifty/trunk/lib/Jifty/Web/Form/Element.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Element.pm (original)
+++ jifty/trunk/lib/Jifty/Web/Form/Element.pm Thu Nov 9 12:32:45 2006
@@ -145,7 +145,7 @@
=cut
sub accessors { shift->handlers, qw(class key_binding id label tooltip) }
-__PACKAGE__->mk_accessors(qw(_onclick class key_binding id label tooltip));
+__PACKAGE__->mk_accessors(qw(onclick class key_binding id label tooltip));
=head2 new PARAMHASH OVERRIDE
@@ -179,7 +179,7 @@
sub onclick {
my $self = shift;
- return $self->_onclick unless @_;
+ return $self->_onclick_accessor unless @_;
my ($arg) = @_;
@@ -213,7 +213,7 @@
}
- $self->_onclick($arg);
+ $self->_onclick_accessor($arg);
}
=head2 javascript
Modified: jifty/trunk/lib/Jifty/Web/Form/Field.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Field.pm (original)
+++ jifty/trunk/lib/Jifty/Web/Form/Field.pm Thu Nov 9 12:32:45 2006
@@ -1,25 +1,3 @@
-=begin properties
-
-constructor
-canonicalizer
-available_values
-ajax_validates
-autocompleter
-
-default_value
-valid_values
-validator
-render_as
-label
-hints
-placeholder
-length
-mandatory
-
-=end properties
-
-=cut
-
use warnings;
use strict;
@@ -104,8 +82,44 @@
=cut
-sub accessors { shift->SUPER::accessors(), qw(name label input_name type sticky sticky_value default_value action mandatory ajax_validates ajax_canonicalizes autocompleter preamble hints placeholder focus render_mode length _element_id); }
-__PACKAGE__->mk_accessors(qw(name _label _input_name type sticky sticky_value default_value _action mandatory ajax_validates ajax_canonicalizes autocompleter preamble hints placeholder focus render_mode length _element_id));
+use constant ACCESSORS => qw(
+ ajax_canonicalizes
+ ajax_validates
+
+ constructor
+ canonicalizer
+ validator
+ autocompleter
+
+ available_values
+ default_value
+ valid_values
+
+ render_as
+ render_mode
+
+ name
+ input_name
+ label
+
+ type
+
+ sticky
+ sticky_value
+
+ hints
+ placeholder
+ length
+ mandatory
+ action
+ preamble
+ focus
+ element_id
+);
+
+
+sub accessors { shift->SUPER::accessors(), ACCESSORS }
+__PACKAGE__->mk_accessors(ACCESSORS);
=head2 name [VALUE]
@@ -191,7 +205,7 @@
# Otherwise, we should ask our action, how to turn our "name"
# into a form input name.
- my $ret = $self->_input_name(@_);
+ my $ret = $self->_input_name_accessor(@_);
return $ret if $ret;
my $action = $self->action;
@@ -235,7 +249,7 @@
sub label {
my $self = shift;
- my $val = $self->_label(@_);
+ my $val = $self->_label_accessor(@_);
defined $val ? $val : $self->name;
}
@@ -251,7 +265,7 @@
sub element_id {
my $self = shift;
- return $self->_element_id || $self->_element_id( $self->input_name ."-".Jifty->web->serial);
+ return $self->_element_id_accessor || $self->_element_id_accessor( $self->input_name ."-".Jifty->web->serial);
}
=head2 action [VALUE]
@@ -265,11 +279,11 @@
sub action {
my $self = shift;
- my $action = $self->_action(@_);
+ my $action = $self->_action_accessor(@_);
# If we're setting the action, we need to weaken
# the reference to not get caught in a loop
- Scalar::Util::weaken( $self->{_action} ) if @_;
+ Scalar::Util::weaken( $self->{action} ) if @_;
return $action;
}
Modified: jifty/trunk/lib/Jifty/Web/Form/Field/Combobox.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Field/Combobox.pm (original)
+++ jifty/trunk/lib/Jifty/Web/Form/Field/Combobox.pm Thu Nov 9 12:32:45 2006
@@ -27,7 +27,7 @@
@{[ $self->_widget_class('combo-button')]}
></span></span><span style="display: none"></span><select
name="@{[ $self->input_name ]}"
- id="@{[ $self->_element_id ]}_List"
+ id="@{[ $self->_element_id_accessor ]}_List"
@{[ $self->_widget_class('combo-list')]}
onchange="ComboBox_SimpleAttach(this, this.form['@{[ $self->element_id ]}']); "
>
More information about the Jifty-commit
mailing list