Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
これら 3 つの「もの」すべてが同様の構文を使用していることに気付きました。つまり、「name1」の後に記号が続きます。
例 1:
attr_reader :methodname
例 2:
before_create :dothisthing
例 3:
content_type :json
この構文パターンを参照するために使用できる特定の専門用語はありますか?
これらは、特に Rails のコンテキストでは「クラス マクロ」と呼ばれていると聞いたことがありますが、それらはすべて、本質的に他のクラスまたはインスタンス メソッド (つまり、メタプログラミング) を記述するクラス メソッドです。
それらすべてに共通しているのは、:symbols を使用していることです。しかし、これら 3 つのうち、attr_reader だけがコア言語の一部だと思います。