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

Deprecate Alchemy::Element.available #2309

Merged
merged 2 commits into from
Apr 26, 2022

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Apr 22, 2022

What is this pull request for?

This removes a scope that is a synonym for another scope. I believe we should be using the Enumerable module much more often rather than using scopes, as that will make preloading easier.

I could have also removed the published scope, but I like that it is close to the instance method public.

Notable changes (remove if none)

Alchemy will issue a deprecation warning when Alchemy::Element.available is called.

Checklist

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have added tests to cover this change

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

Thanks. We should split this into two PRs.

app/models/alchemy/element.rb Outdated Show resolved Hide resolved
app/helpers/alchemy/elements_helper.rb Show resolved Hide resolved
lib/alchemy/elements_finder.rb Outdated Show resolved Hide resolved
lib/alchemy/elements_finder.rb Outdated Show resolved Hide resolved
app/models/alchemy/page_version.rb Outdated Show resolved Hide resolved
mamhoff added 2 commits April 26, 2022 15:46
This is just an alias to "published", which in turn is an alias for
`where(public: true)`. In most circumstances, using this in production
code will break preloading.
There were some usages in relations that I replaced with the synonym
`published`. In the `ElementsFinder` I used `select(&:public?)` for
performance reasons (it's extremely unlikely a page has so many elements
that we need the database to help us).
@mamhoff mamhoff force-pushed the deprecate-element-available branch from 9978fa9 to 94f46c2 Compare April 26, 2022 13:53
@tvdeyen tvdeyen merged commit 4773be5 into AlchemyCMS:main Apr 26, 2022
tvdeyen added a commit that referenced this pull request Apr 26, 2022
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

Successfully merging this pull request may close these issues.

2 participants