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

Add Kernel#{yes,on} and Kernel#{no,off} #11962

Closed
wants to merge 1 commit into from

Conversation

gsamokovarov
Copy link
Contributor

Introduce true and false aliases in the spirit of YAML and CoffeeScript.

While it may sounds silly at first, those are actually looking pretty neat, especially in configs. For example, here is the default development config with the aliases:

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = no

  # Do not eager load code on boot.
  config.eager_load = no

  # Show full error reports and disable caching.
  config.consider_all_requests_local       = yes
  config.action_controller.perform_caching = yes

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = no

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = on
end

It's just a little bit of sugar, but it makes me smile everytime I look at it.

Introduce true and false aliases in the spirit of YAML and CoffeeScript.

While it may sounds silly at first, those are actually looking pretty
neat, especially in configs.

For example, here is the default development config with the aliases:

```ruby
Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = no

  # Do not eager load code on boot.
  config.eager_load = no

  # Show full error reports and disable caching.
  config.consider_all_requests_local       = yes
  config.action_controller.perform_caching = yes

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = no

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = on
end
```

It's just a little bit of sugar, but it makes me smile every time I look
at it.
@rafaelfranca
Copy link
Member

Thank you for the pull request. We should be very cautious when adding something to the core extensions and we prefer to not add if it will not give a really good improvement in the way you write your code.

true/false is a common idiom in the Ruby community and I don't think we need to change it.

I'd recommend to you suggest this change to Ruby core instead. I don't think it belongs to Rails.

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.

None yet

2 participants