1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

remove warning from railtie

This removes the following warnings.

```ruby
rails/railties/lib/rails/railtie.rb:186: warning: instance variable @rake_tasks not initialized
rails/railties/lib/rails/railtie.rb:186: warning: instance variable @rake_tasks not initialized
rails/railties/lib/rails/railtie.rb:186: warning: instance variable @load_console not initialized
rails/railties/lib/rails/railtie.rb:186: warning: instance variable @rake_tasks not initialized
```
This commit is contained in:
yuuji.yaginuma 2016-11-02 10:17:22 +09:00
parent 9ebb3558f4
commit 34530f5bd5

View file

@ -194,7 +194,7 @@ module Rails
# `#each_registered_block(type, &block)`
def register_block_for(type, &blk)
var_name = "@#{type}"
blocks = instance_variable_get(var_name) || instance_variable_set(var_name, [])
blocks = instance_variable_defined?(var_name) ? instance_variable_get(var_name) : instance_variable_set(var_name, [])
blocks << blk if blk
blocks
end