Rails.initialized? can be called at any time without raising an exception [Closes #2507] #2528

Merged
merged 1 commit into from Mar 28, 2012

Conversation

Projects
None yet
3 participants
Contributor

franckverrot commented Aug 14, 2011

Rails.initialized? can be called at any time without raising an exception [Closes #2507]

Member

josevalim commented Aug 14, 2011

This looks good. Maybe, instead of adding a new test file, let's add simply a test case to railties/test/application/initializion_test that asserts that initialized? starts with false and ends up with true?

Contributor

franckverrot commented Aug 15, 2011

After digging a bit more I did some cleanup too. I say this in the commit message:

Rails.initialized? can be called at any time without raising an exception [Closes #2507]

Changes:

  • Rails.initialized= has been removed
  • Rails.initialized? and Rails.application.initialized? are now
  • delegating to MyApp::Application.initialized?

Is it what you had in mind?

@cesario hey, I guess it's better to check for assert !... and assert ... for instance, instead of using assert_equal in this case, perhaps you could change that :)

@josevalim I think this still apply, right? initialized= seems to not be used anywhere.

Contributor

franckverrot commented Mar 27, 2012

@carlosantoniodasilva thanks for taking a look at this PR, if it's stlill relevant I'll push my changes ASAP.

Member

josevalim commented Mar 27, 2012

@cesario please push your new changes, this is relevant. :)

Sorry for not replying back 8 months ago. It seems I missed it somehow.

Contributor

franckverrot commented Mar 27, 2012

No problem, I'll send a PR in a couple of hours.

@carlosantoniodasilva carlosantoniodasilva and 1 other commented on an outdated diff Mar 27, 2012

railties/lib/rails/application.rb
@@ -134,6 +134,10 @@ def initialize!(group=:default) #:nodoc:
self
end
+ def initialized?
+ @initialized ||= false
+ end
@carlosantoniodasilva

carlosantoniodasilva Mar 27, 2012

Owner

Ahm, I wonder if we need the ||= false clause here. The variable is initialized to false and changed later to true on initialize!, so it should never be nil. And if it's false, ||= doesn't make sense. Wdyt?

@franckverrot

franckverrot Mar 27, 2012

Contributor

||= ensured calling Rais.initialized? wouldn't throw an exception because the class variable @@initialized was uninitialized. Now that I refactored and use an instance variable the problem goes away. So I'm pushing a new commit now. Thanks!

@carlosantoniodasilva

carlosantoniodasilva Mar 27, 2012

Owner

Ah yeah, it was using a class variable before.. great, thanks :)

@franckverrot franckverrot Rails.initialized? can be called at any time without raising an excep…
…tion [Closes #2507]

Changes:

* `Rails.initialized=` has been removed
* `Rails.initialized?` and `Rails.application.initialized?` are now
* delegating to `MyApp::Application.initialized?`
4882271

@josevalim josevalim added a commit that referenced this pull request Mar 28, 2012

@josevalim josevalim Merge pull request #2528 from cesario/fix_2507
Rails.initialized? can be called at any time without raising an exception [Closes #2507]
0560ce0

@josevalim josevalim merged commit 0560ce0 into rails:master Mar 28, 2012

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