Skip to content
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
Closed

Allow lvalue attributes in roles #1

doherty opened this issue Aug 17, 2013 · 7 comments

Comments

@doherty
Copy link

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
Copy link
Collaborator

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
Copy link
Collaborator

dams commented Aug 21, 2013

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

@dams dams closed this as completed Aug 21, 2013
@doherty
Copy link
Author

doherty commented Aug 21, 2013

Sweet, thanks!

@dams
Copy link
Collaborator

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 pushed a commit that referenced this issue Aug 27, 2013
dams pushed a commit that referenced this issue Aug 27, 2013
@doherty
Copy link
Author

doherty commented Sep 27, 2013

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

@dams
Copy link
Collaborator

dams commented Sep 27, 2013

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

@dams dams closed this as completed Sep 27, 2013
@doherty
Copy link
Author

doherty commented Sep 28, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants