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

Templates have one format #35406

Merged
merged 1 commit into from Feb 25, 2019

Conversation

Projects
None yet
3 participants
@tenderlove
Copy link
Member

commented Feb 25, 2019

Templates only have one format. Before this commit, templates would be
constructed with a single element array that contained the format. This
commit eliminates the single element array and just implements a
format method. This saves one array allocation per template.

Templates have one format
Templates only have one format.  Before this commit, templates would be
constructed with a single element array that contained the format.  This
commit eliminates the single element array and just implements a
`format` method.  This saves one array allocation per template.

@tenderlove tenderlove merged commit 56b0306 into master Feb 25, 2019

3 of 4 checks passed

continuous-integration/travis-ci/push The Travis CI build is in progress
Details
buildkite/rails Build #59077 passed (18 minutes, 31 seconds)
Details
codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@tenderlove tenderlove deleted the template-has-one-format branch Feb 25, 2019

end

def formats; Array(format); end
deprecate :formats

This comment has been minimized.

Copy link
@kaspth

kaspth Feb 25, 2019

Member

Why should we do deprecation here in HTML and in Text? They’re both marked nodoc.

This comment has been minimized.

Copy link
@tenderlove

tenderlove Feb 25, 2019

Author Member

tbh, I think we can remove them. The problem is that these are supposed to quack the same as instances of Template. I really don't think people are calling formats on anything but instances of Template, but I figured I'd add the deprecation warning since these are "duck typing buddies" with Template.

Actually I think these should probably share inheritance hierarchy with Template, but that's a later patch.

This comment has been minimized.

Copy link
@tenderlove

tenderlove Feb 25, 2019

Author Member

(we were definitely calling formats on Text / HTML instances, and the deprecation warning helped me track / fix them)

@kaspth

This comment has been minimized.

Copy link
Member

commented Feb 25, 2019

❤️

@@ -4,7 +4,7 @@

class TextTest < ActiveSupport::TestCase
test "formats always return :text" do

This comment has been minimized.

Copy link
@abhaynikam

abhaynikam Feb 26, 2019

Contributor

@tenderlove Method formats was renamed to format. Can I update the test description here to format?

This comment has been minimized.

Copy link
@abhaynikam

abhaynikam Feb 26, 2019

Contributor

Changed here #35406.

abhaynikam added a commit to abhaynikam/rails that referenced this pull request Feb 26, 2019

rafaelfranca added a commit that referenced this pull request Feb 26, 2019

Merge pull request #35414 from abhaynikam/35406-followup-rename-templ…
…ate-format

[ci skip] Renamed formats -> format in test after #35406

prathamesh-sonpatki added a commit to prathamesh-sonpatki/rails that referenced this pull request Apr 4, 2019

Fix deprecation warning about variants and formats
- After rails#35408 and
  rails#35406, the `formats` and
  `variants` methods are deprecated in favor of `format` and `variant`.

pingortle added a commit to pingortle/rails that referenced this pull request Apr 9, 2019

Fix deprecation warning about variants and formats
- After rails#35408 and
  rails#35406, the `formats` and
  `variants` methods are deprecated in favor of `format` and `variant`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.