モジュール変数について

モジュールの内部でクラス変数のようなモジュール変数を定義できるらしい。 require "active_support/all" module Test mattr_accessor :var @@var = 1 end Test.var #=> 1 Test::var #=> 1 ちなみにmattr_accessorを使うにはrequire "active_support/all"し…

includeとextendの違いについて

ふとActionController::TestCaseを読んでいたときに以下のような書き方を見つけた。 class TestCase < ActiveSupport::TestCase module Behavior extend ActiveSupport::Concern include ActionDispatch::TestProcess : 勉強不足だ。。とりあえず調べてみる…