Skip to content

Conversation

@beauby
Copy link
Contributor

@beauby beauby commented Oct 30, 2015

This PR is half of #1262, introducing the block syntax for overriding associations (and removing the legacy method defining syntax).

Currently 2 tests fail, I believe those tests are ill (they seem to expect an association to be treated as an attribute).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this a try before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the self._reflections was not initialized in the constructor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so any class that inherits Associations must have a _reflections accessor?
can you document that, please?
I know it's outside the scope of a refactor, but since we have next to none of this type of documentation, I think it will be good to do it as we go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, including Associations does declare a _reflections accessor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ok, so you're setting base._reflections just to an empty array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depending if the parent class has some reflections already or not

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. Sorry. Can you summarize?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Module Associations defines (on the class that includes it) a class attribute _reflections that is initialized to [] and is inherited.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, those changes are mainly (if not only) cosmetic, in order to be consistent with how we deal with inheritance of class attributes all around, they're not necessary for this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is a reflection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh. ha. didn't see there was more. thanks

@beauby
Copy link
Contributor Author

beauby commented Nov 13, 2015

Should be green.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want this to be instance readable/writable? Do we want these to be inheritable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re: inhertiable, yes, oops

-          base._reflections = self._reflections.try(:dup) || []
+          super
+          base._reflections = _reflections.dup

@bf4
Copy link
Member

bf4 commented Dec 14, 2015

Closed by #1356

@bf4 bf4 closed this Dec 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants