mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 19:46:55 +08:00
584424594e
This patch replaces the parameters provided to a service through `params` by the contract object. That way, it allows better consistency when accessing input params. For example, if you have a service without a contract, to access a parameter, you need to use `params[:my_parameter]`. But with a contract, you do this through `contract.my_parameter`. Now, with this patch, you’ll be able to access it through `params.my_parameter` or `params[:my_parameter]`. Some methods have been added to the contract object to better mimic a Hash. That way, when accessing/using `params`, you don’t have to think too much about it: - `params.my_key` is also accessible through `params[:my_key]`. - `params.my_key = value` can also be done through `params[:my_key] = value`. - `#slice` and `#merge` are available. - `#to_hash` has been implemented, so the contract object will be automatically cast as a hash by Ruby depending on the context. For example, with an AR model, you can do this: `user.update(**params)`. |
||
---|---|---|
.. | ||
config | ||
admin_controller.rb | ||
admin_notices_controller.rb | ||
api_controller.rb | ||
backups_controller.rb | ||
badges_controller.rb | ||
color_schemes_controller.rb | ||
dashboard_controller.rb | ||
email_controller.rb | ||
email_styles_controller.rb | ||
email_templates_controller.rb | ||
embeddable_hosts_controller.rb | ||
embedding_controller.rb | ||
emojis_controller.rb | ||
form_templates_controller.rb | ||
groups_controller.rb | ||
impersonate_controller.rb | ||
permalinks_controller.rb | ||
plugins_controller.rb | ||
reports_controller.rb | ||
robots_txt_controller.rb | ||
screened_emails_controller.rb | ||
screened_ip_addresses_controller.rb | ||
screened_urls_controller.rb | ||
search_logs_controller.rb | ||
section_controller.rb | ||
site_settings_controller.rb | ||
site_texts_controller.rb | ||
staff_action_logs_controller.rb | ||
staff_controller.rb | ||
themes_controller.rb | ||
user_fields_controller.rb | ||
users_controller.rb | ||
versions_controller.rb | ||
watched_words_controller.rb | ||
web_hooks_controller.rb |