Ruby の多重継承はモジュールを含めることでシミュレートされますが、(クラスではない) モジュールから直接プロパティを継承することはできません。私が思いついた解決策は、モジュールの初期化でプロパティを定義することでした (以下のコード)。以下のコード(メソッドとプロパティを継承)と比較して、複数の継承を実現するより良い方法はありますか?
module MyCustomMixin
attr_accessor :a
def initialize
self.a = 1
end
def b
"something"
end
end
class MyCreateView < CreateView
include MyCustomMixin
end
class MyReadView < ReadView
include MyCustomMixin
end
class MyUpdateView < UpdateView
include MyCustomMixin
end
class MyDeleteView < DeleteView
include MyCustomMixin
end