Using double splat operator (#5859)

remotes/1727458204337373841/tmp_refs/heads/signup-info-prompt
Yamagishi Kazutoshi 2017-12-06 19:41:57 +09:00 committed by Eugen Rochko
parent 42bcbd36b7
commit b21db9bbde
25 changed files with 32 additions and 32 deletions

View File

@ -51,7 +51,7 @@ class Api::V1::AccountsController < Api::BaseController
@account = Account.find(params[:id]) @account = Account.find(params[:id])
end end
def relationships(options = {}) def relationships(**options)
AccountRelationshipsPresenter.new([@account.id], current_user.account_id, options) AccountRelationshipsPresenter.new([@account.id], current_user.account_id, options)
end end
end end

View File

@ -13,7 +13,7 @@ module Admin::FilterHelper
link_to text, new_url, class: filter_link_class(new_class) link_to text, new_url, class: filter_link_class(new_class)
end end
def table_link_to(icon, text, path, options = {}) def table_link_to(icon, text, path, **options)
link_to safe_join([fa_icon(icon), text]), path, options.merge(class: 'table-action-link') link_to safe_join([fa_icon(icon), text]), path, options.merge(class: 'table-action-link')
end end

View File

@ -5,7 +5,7 @@ module ApplicationHelper
current_page?(path) ? 'active' : '' current_page?(path) ? 'active' : ''
end end
def active_link_to(label, path, options = {}) def active_link_to(label, path, **options)
link_to label, path, options.merge(class: active_nav_class(path)) link_to label, path, options.merge(class: active_nav_class(path))
end end

View File

@ -11,7 +11,7 @@ module RoutingHelper
end end
end end
def full_asset_url(source, options = {}) def full_asset_url(source, **options)
source = ActionController::Base.helpers.asset_url(source, options) unless use_storage? source = ActionController::Base.helpers.asset_url(source, options) unless use_storage?
URI.join(root_url, source).to_s URI.join(root_url, source).to_s

View File

@ -3,7 +3,7 @@
class ActivityPub::Activity class ActivityPub::Activity
include JsonLdHelper include JsonLdHelper
def initialize(json, account, options = {}) def initialize(json, account, **options)
@json = json @json = json
@account = account @account = account
@object = @json['object'] @object = @json['object']
@ -15,7 +15,7 @@ class ActivityPub::Activity
end end
class << self class << self
def factory(json, account, options = {}) def factory(json, account, **options)
@json = json @json = json
klass&.new(json, account, options) klass&.new(json, account, options)
end end

View File

@ -32,7 +32,7 @@ module Extractor
possible_entries possible_entries
end end
def extract_hashtags_with_indices(text, _options = {}) def extract_hashtags_with_indices(text, **)
return [] unless text =~ /#/ return [] unless text =~ /#/
tags = [] tags = []

View File

@ -9,7 +9,7 @@ class Formatter
include ActionView::Helpers::TextHelper include ActionView::Helpers::TextHelper
def format(status, options = {}) def format(status, **options)
if status.reblog? if status.reblog?
prepend_reblog = status.reblog.account.acct prepend_reblog = status.reblog.account.acct
status = status.proper status = status.proper

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class OStatus::Activity::Base class OStatus::Activity::Base
def initialize(xml, account = nil, options = {}) def initialize(xml, account = nil, **options)
@xml = xml @xml = xml
@account = account @account = account
@options = options @options = options

View File

@ -319,7 +319,7 @@ class OStatus::AtomSerializer
private private
def append_element(parent, name, content = nil, attributes = {}) def append_element(parent, name, content = nil, **attributes)
element = Ox::Element.new(name) element = Ox::Element.new(name)
attributes.each { |k, v| element[k] = sanitize_str(v) } attributes.each { |k, v| element[k] = sanitize_str(v) }
element << sanitize_str(content) unless content.nil? element << sanitize_str(content) unless content.nil?

View File

@ -2,7 +2,7 @@
class ProviderDiscovery < OEmbed::ProviderDiscovery class ProviderDiscovery < OEmbed::ProviderDiscovery
class << self class << self
def discover_provider(url, options = {}) def discover_provider(url, **options)
res = Request.new(:get, url).perform res = Request.new(:get, url).perform
format = options[:format] format = options[:format]

View File

@ -5,7 +5,7 @@ class Request
include RoutingHelper include RoutingHelper
def initialize(verb, url, options = {}) def initialize(verb, url, **options)
@verb = verb @verb = verb
@url = Addressable::URI.parse(url).normalize @url = Addressable::URI.parse(url).normalize
@options = options @options = options

View File

@ -63,7 +63,7 @@ class NotificationMailer < ApplicationMailer
end end
end end
def digest(recipient, opts = {}) def digest(recipient, **opts)
@me = recipient @me = recipient
@since = opts[:since] || @me.user.last_emailed_at || @me.user.current_sign_in_at @since = opts[:since] || @me.user.last_emailed_at || @me.user.current_sign_in_at
@notifications = Notification.where(account: @me, activity_type: 'Mention').where('created_at > ?', @since) @notifications = Notification.where(account: @me, activity_type: 'Mention').where('created_at > ?', @since)

View File

@ -5,7 +5,7 @@ class UserMailer < Devise::Mailer
helper :instance helper :instance
def confirmation_instructions(user, token, _opts = {}) def confirmation_instructions(user, token, **)
@resource = user @resource = user
@token = token @token = token
@instance = Rails.configuration.x.local_domain @instance = Rails.configuration.x.local_domain
@ -17,7 +17,7 @@ class UserMailer < Devise::Mailer
end end
end end
def reset_password_instructions(user, token, _opts = {}) def reset_password_instructions(user, token, **)
@resource = user @resource = user
@token = token @token = token
@instance = Rails.configuration.x.local_domain @instance = Rails.configuration.x.local_domain
@ -29,7 +29,7 @@ class UserMailer < Devise::Mailer
end end
end end
def password_change(user, _opts = {}) def password_change(user, **)
@resource = user @resource = user
@instance = Rails.configuration.x.local_domain @instance = Rails.configuration.x.local_domain

View File

@ -7,8 +7,8 @@ class RemoteFollow
validates :acct, presence: true validates :acct, presence: true
def initialize(attrs = {}) def initialize(attrs = nil)
@acct = attrs[:acct].gsub(/\A@/, '').strip unless attrs[:acct].nil? @acct = attrs[:acct].gsub(/\A@/, '').strip if !attrs.nil? && !attrs[:acct].nil?
end end
def valid? def valid?

View File

@ -53,7 +53,7 @@ class SessionActivation < ApplicationRecord
id && where(session_id: id).exists? id && where(session_id: id).exists?
end end
def activate(options = {}) def activate(**options)
activation = create!(options) activation = create!(options)
purge_old purge_old
activation activation

View File

@ -4,7 +4,7 @@ class AccountRelationshipsPresenter
attr_reader :following, :followed_by, :blocking, attr_reader :following, :followed_by, :blocking,
:muting, :requested, :domain_blocking :muting, :requested, :domain_blocking
def initialize(account_ids, current_account_id, options = {}) def initialize(account_ids, current_account_id, **options)
@following = Account.following_map(account_ids, current_account_id).merge(options[:following_map] || {}) @following = Account.following_map(account_ids, current_account_id).merge(options[:following_map] || {})
@followed_by = Account.followed_by_map(account_ids, current_account_id).merge(options[:followed_by_map] || {}) @followed_by = Account.followed_by_map(account_ids, current_account_id).merge(options[:followed_by_map] || {})
@blocking = Account.blocking_map(account_ids, current_account_id).merge(options[:blocking_map] || {}) @blocking = Account.blocking_map(account_ids, current_account_id).merge(options[:blocking_map] || {})

View File

@ -3,7 +3,7 @@
class StatusRelationshipsPresenter class StatusRelationshipsPresenter
attr_reader :reblogs_map, :favourites_map, :mutes_map, :pins_map attr_reader :reblogs_map, :favourites_map, :mutes_map, :pins_map
def initialize(statuses, current_account_id = nil, options = {}) def initialize(statuses, current_account_id = nil, **options)
if current_account_id.nil? if current_account_id.nil?
@reblogs_map = {} @reblogs_map = {}
@favourites_map = {} @favourites_map = {}

View File

@ -3,7 +3,7 @@
class ActivityPub::ProcessCollectionService < BaseService class ActivityPub::ProcessCollectionService < BaseService
include JsonLdHelper include JsonLdHelper
def call(body, account, options = {}) def call(body, account, **options)
@account = account @account = account
@json = Oj.load(body, mode: :strict) @json = Oj.load(body, mode: :strict)
@options = options @options = options

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class AuthorizeFollowService < BaseService class AuthorizeFollowService < BaseService
def call(source_account, target_account, options = {}) def call(source_account, target_account, **options)
if options[:skip_follow_request] if options[:skip_follow_request]
follow_request = FollowRequest.new(account: source_account, target_account: target_account) follow_request = FollowRequest.new(account: source_account, target_account: target_account)
else else

View File

@ -13,7 +13,7 @@ class PostStatusService < BaseService
# @option [Doorkeeper::Application] :application # @option [Doorkeeper::Application] :application
# @option [String] :idempotency Optional idempotency key # @option [String] :idempotency Optional idempotency key
# @return [Status] # @return [Status]
def call(account, text, in_reply_to = nil, options = {}) def call(account, text, in_reply_to = nil, **options)
if options[:idempotency].present? if options[:idempotency].present?
existing_id = redis.get("idempotency:status:#{account.id}:#{options[:idempotency]}") existing_id = redis.get("idempotency:status:#{account.id}:#{options[:idempotency]}")
return Status.find(existing_id) if existing_id return Status.find(existing_id) if existing_id

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class ProcessFeedService < BaseService class ProcessFeedService < BaseService
def call(body, account, options = {}) def call(body, account, **options)
@options = options @options = options
xml = Nokogiri::XML(body) xml = Nokogiri::XML(body)

View File

@ -3,7 +3,7 @@
class RemoveStatusService < BaseService class RemoveStatusService < BaseService
include StreamEntryRenderer include StreamEntryRenderer
def call(status, options = {}) def call(status, **options)
@payload = Oj.dump(event: :delete, payload: status.id.to_s) @payload = Oj.dump(event: :delete, payload: status.id.to_s)
@status = status @status = status
@account = status.account @account = status.account

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class SuspendAccountService < BaseService class SuspendAccountService < BaseService
def call(account, options = {}) def call(account, **options)
@account = account @account = account
@options = options @options = options

View File

@ -99,7 +99,7 @@ module Mastodon
# default - The default value for the column. # default - The default value for the column.
# null - When set to `true` the column will allow NULL values. # null - When set to `true` the column will allow NULL values.
# The default is to not allow NULL values. # The default is to not allow NULL values.
def add_timestamps_with_timezone(table_name, options = {}) def add_timestamps_with_timezone(table_name, **options)
options[:null] = false if options[:null].nil? options[:null] = false if options[:null].nil?
[:created_at, :updated_at].each do |column_name| [:created_at, :updated_at].each do |column_name|
@ -134,7 +134,7 @@ module Mastodon
# add_concurrent_index :users, :some_column # add_concurrent_index :users, :some_column
# #
# See Rails' `add_index` for more info on the available arguments. # See Rails' `add_index` for more info on the available arguments.
def add_concurrent_index(table_name, column_name, options = {}) def add_concurrent_index(table_name, column_name, **options)
if transaction_open? if transaction_open?
raise 'add_concurrent_index can not be run inside a transaction, ' \ raise 'add_concurrent_index can not be run inside a transaction, ' \
'you can disable transactions by calling disable_ddl_transaction! ' \ 'you can disable transactions by calling disable_ddl_transaction! ' \
@ -158,7 +158,7 @@ module Mastodon
# remove_concurrent_index :users, :some_column # remove_concurrent_index :users, :some_column
# #
# See Rails' `remove_index` for more info on the available arguments. # See Rails' `remove_index` for more info on the available arguments.
def remove_concurrent_index(table_name, column_name, options = {}) def remove_concurrent_index(table_name, column_name, **options)
if transaction_open? if transaction_open?
raise 'remove_concurrent_index can not be run inside a transaction, ' \ raise 'remove_concurrent_index can not be run inside a transaction, ' \
'you can disable transactions by calling disable_ddl_transaction! ' \ 'you can disable transactions by calling disable_ddl_transaction! ' \
@ -182,7 +182,7 @@ module Mastodon
# remove_concurrent_index :users, "index_X_by_Y" # remove_concurrent_index :users, "index_X_by_Y"
# #
# See Rails' `remove_index` for more info on the available arguments. # See Rails' `remove_index` for more info on the available arguments.
def remove_concurrent_index_by_name(table_name, index_name, options = {}) def remove_concurrent_index_by_name(table_name, index_name, **options)
if transaction_open? if transaction_open?
raise 'remove_concurrent_index_by_name can not be run inside a transaction, ' \ raise 'remove_concurrent_index_by_name can not be run inside a transaction, ' \
'you can disable transactions by calling disable_ddl_transaction! ' \ 'you can disable transactions by calling disable_ddl_transaction! ' \

View File

@ -182,7 +182,7 @@ RSpec.describe PostStatusService do
expect(status2.id).to eq status1.id expect(status2.id).to eq status1.id
end end
def create_status_with_options(options = {}) def create_status_with_options(**options)
subject.call(Fabricate(:account), 'test', nil, options) subject.call(Fabricate(:account), 'test', nil, options)
end end
end end