Multiple inheritance in Ruby is simulated by including modules, but it's not possible to inherit properties directly from modules (that are not classes). The solution I came up was to define properties on the module initialization (code below). Is there a better way to achieve multiple inheritance compared the code below (inheriting methods AND properties)?
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
bmethod inMyCustomMixinacts as an attribute, because all it does is return a value.b=to make it a writeable "attribute".