New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow lvalue attributes in roles #1

Closed
doherty opened this Issue Aug 17, 2013 · 7 comments

Comments

Projects
None yet
2 participants
@doherty

doherty commented Aug 17, 2013

It's not clear why lvalue attributes are only allowed in classes. I'd like to give the consumers of my role an lvalue attribute, which I think makes sense. It'd be nice to have that supported, if possible.

@dams

This comment has been minimized.

Show comment
Hide comment
@dams

dams Aug 17, 2013

Owner

I had some troubles making it work in roles, but I'll try to fix it. As soon as I get back from holiday, that is :)

Owner

dams commented Aug 17, 2013

I had some troubles making it work in roles, but I'll try to fix it. As soon as I get back from holiday, that is :)

@dams

This comment has been minimized.

Show comment
Hide comment
@dams

dams Aug 21, 2013

Owner

fixed. Let me know if it doesn't work for you.

Owner

dams commented Aug 21, 2013

fixed. Let me know if it doesn't work for you.

@dams dams closed this Aug 21, 2013

@doherty

This comment has been minimized.

Show comment
Hide comment
@doherty

doherty Aug 21, 2013

Sweet, thanks!

doherty commented Aug 21, 2013

Sweet, thanks!

@dams

This comment has been minimized.

Show comment
Hide comment
@dams

dams Aug 27, 2013

Owner

hi @doherty ,

@haarg pointed out to me that maybe what you had in mind with " I'd like to give the consumers of my role an lvalue attribute" was: "I should be able to define an lvalue attribute in the role", instead of what I originally understood: "when using MooX::LvalueAttribute in a Role, any class consuming it will get the MooX::LvalueAttribute behaviour".

In other words, in this code:

    package MyRole;
    use Moo::Role;
    use MooX::LvalueAttribute;

    has a1 => ( is => 'rw', lvalue => 1);

    package MyClass;
    use Moo;
    with ('MyRole');

    has a2 => ( is => 'rw', lvalue => 1);

    sub do_stuff { shift->a1 = 15 }
    sub doesnt_work { shift->a2 = 15 }

the attribute a1 will be lvalue, the attribute a2 won't. and do_stuff() will work.

I hope that's what you originally thought. Let me know :)

Owner

dams commented Aug 27, 2013

hi @doherty ,

@haarg pointed out to me that maybe what you had in mind with " I'd like to give the consumers of my role an lvalue attribute" was: "I should be able to define an lvalue attribute in the role", instead of what I originally understood: "when using MooX::LvalueAttribute in a Role, any class consuming it will get the MooX::LvalueAttribute behaviour".

In other words, in this code:

    package MyRole;
    use Moo::Role;
    use MooX::LvalueAttribute;

    has a1 => ( is => 'rw', lvalue => 1);

    package MyClass;
    use Moo;
    with ('MyRole');

    has a2 => ( is => 'rw', lvalue => 1);

    sub do_stuff { shift->a1 = 15 }
    sub doesnt_work { shift->a2 = 15 }

the attribute a1 will be lvalue, the attribute a2 won't. and do_stuff() will work.

I hope that's what you originally thought. Let me know :)

@dams dams reopened this Aug 27, 2013

dams added a commit that referenced this issue Aug 27, 2013

dams added a commit that referenced this issue Aug 27, 2013

@doherty

This comment has been minimized.

Show comment
Hide comment
@doherty

doherty Sep 27, 2013

@dams: Yes, the code example you provided illustrates what I meant more clearly.

doherty commented Sep 27, 2013

@dams: Yes, the code example you provided illustrates what I meant more clearly.

@dams

This comment has been minimized.

Show comment
Hide comment
@dams

dams Sep 27, 2013

Owner

@doherty Cool, then that's what's in the code now. Enjoy :)

Owner

dams commented Sep 27, 2013

@doherty Cool, then that's what's in the code now. Enjoy :)

@dams dams closed this Sep 27, 2013

@doherty

This comment has been minimized.

Show comment
Hide comment
@doherty

doherty Sep 28, 2013

Attributes of this sort exhibit a rather odd bug that I demonstrated here: doherty/MooX-LvalueAttribute@6ca819e

doherty commented Sep 28, 2013

Attributes of this sort exhibit a rather odd bug that I demonstrated here: doherty/MooX-LvalueAttribute@6ca819e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment