@tateisu @mayaeh こちらの件、
https://mastodon.juggler.jp/@tateisu/101301391429326074
とりあえずそのままプルリク投げました。
https://github.com/tootsuite/mastodon/pull/9625
@tateisu @mayaeh こちらの件、
https://mastodon.juggler.jp/@tateisu/101301391429326074
とりあえずそのままプルリク投げました。
https://github.com/tootsuite/mastodon/pull/9625
@noellabo @tateisu ありがとうございます!
この記法でいいのか私には判断できないためすぐには行動できませんが、疑問などコメントあれば協力したいと思います。
def require_user!
if current_user && !current_user.disabled? && current_user.confirmed?
set_user_activity
elsif current_user && current_user.disabled?
render json: { error: 'Your login is currently disabled' }, status: 403
elsif current_user && !current_user.confirmed?
render json: { error: 'Email confirmation is not completed' }, status: 403
else
render json: { error: 'This method requires an authenticated user' }, status: 422
end
end
@noellabo @tateisu 私はこちらの方が好きです…が、独学の私にはどちらの記法がより良いのか私には判断できません。
@mayaeh @tateisu あっさりマージしてくれましたね。
私は、最初に提案した書き方が、シンプルで重複がなく、ミスが混入しにくい点で優位と考えています。判定を追加するのもシンプルに対応できるし。正常判定のパスは先頭か末尾のいずれかであればどちらでもいいんじゃないかな。
ただ、独学というか、rubyに至ってはまともに文法勉強会してないので(!)ガイドラインなどがあるのかどうか知らなかったり……。
ちゃんと目を通したのはcrystalのリファレンスだけw
@mayaeh @tateisu 正常系のパスをif〜endの外に出した方がわかりやすい、とかはあるかもしれないなぁ。ifで判定するブロックは全部エラー判定(before_action的な)にするとか。
などという、特に結果に寄与しないコード談義も楽しいのであります。戦争が起きる系ですがw
@noellabo ?
ひとつ勉強になりました、ありがとうございます!
Crystal 、リレーのカスタマイズですね。
@mayaeh 私はアセンブリ言語とかCの時代が長かったので、同じチェックが何度も書かれているの見ると避けたくなるんですよねぇ。
最近の言語は、タブかスペースか、などの不毛な議論が起きないようにフォーマッタがついてたり(crystal tool format とか go fmt)するので、良い時代だなと思います。
ruby、railsの流儀は、すごーくなんとなくやってるので、もう少しマジメに勉強します……。
senooken JP Social is a social network, courtesy of senooken. It runs on GNU social, version 2.0.2-beta0, available under the GNU Affero General Public License.
All senooken JP Social content and data are available under the Creative Commons Attribution 3.0 license.