mirror of
https://github.com/discourse/discourse.git
synced 2025-01-23 01:43:59 +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)`. |
||
---|---|---|
.. | ||
admin_notices | ||
experiments | ||
flags | ||
notifications | ||
problem_check | ||
site_setting | ||
spam_rule | ||
user | ||
anonymous_shadow_creator.rb | ||
badge_granter.rb | ||
base_bookmarkable.rb | ||
category_hashtag_data_source.rb | ||
color_scheme_revisor.rb | ||
destroy_task.rb | ||
email_settings_exception_handler.rb | ||
email_settings_validator.rb | ||
email_style_updater.rb | ||
external_upload_manager.rb | ||
group_action_logger.rb | ||
group_mentions_updater.rb | ||
group_message.rb | ||
handle_chunk_upload.rb | ||
hashtag_autocomplete_service.rb | ||
heat_settings_updater.rb | ||
inline_uploads.rb | ||
notification_emailer.rb | ||
post_action_notifier.rb | ||
post_alerter.rb | ||
post_bookmarkable.rb | ||
post_owner_changer.rb | ||
push_notification_pusher.rb | ||
random_topic_selector.rb | ||
registered_bookmarkable.rb | ||
search_indexer.rb | ||
sidebar_section_links_updater.rb | ||
sidebar_site_settings_backfiller.rb | ||
site_setting_update_existing_users.rb | ||
site_settings_task.rb | ||
staff_action_logger.rb | ||
tag_hashtag_data_source.rb | ||
theme_settings_migrations_runner.rb | ||
themes_install_task.rb | ||
topic_bookmarkable.rb | ||
topic_status_updater.rb | ||
topic_timestamp_changer.rb | ||
tracked_topics_updater.rb | ||
trust_level_granter.rb | ||
user_action_manager.rb | ||
user_activator.rb | ||
user_anonymizer.rb | ||
user_authenticator.rb | ||
user_destroyer.rb | ||
user_merger.rb | ||
user_notification_renderer.rb | ||
user_notification_schedule_processor.rb | ||
user_password_expirer.rb | ||
user_silencer.rb | ||
user_stat_count_updater.rb | ||
user_suspender.rb | ||
user_updater.rb | ||
username_changer.rb | ||
username_checker_service.rb | ||
web_hook_emitter.rb | ||
wildcard_domain_checker.rb | ||
wildcard_url_checker.rb | ||
word_watcher.rb |