T
trans. (T. Onoma)
I find Ruby's various means of accessing class "domain" a bit clunky. Between
class << self, extend self, module_function, def AClass.foo, def self.foo,
and so forth. So I muse on what might be more uniform and easily
comprehensible.
class Example
metaclass
def foo
puts "Class Method"
end
instance
def foo
puts "Instance Method"
end
extended
def bar
puts "Class Method && Instance Method"
end
end
And with variations:
class Example
instance private
def foo
puts "Instance Method"
end
extended instance private # just like module_function
def bar
puts "Class Method && Instance Method"
end
end
T.
class << self, extend self, module_function, def AClass.foo, def self.foo,
and so forth. So I muse on what might be more uniform and easily
comprehensible.
class Example
metaclass
def foo
puts "Class Method"
end
instance
def foo
puts "Instance Method"
end
extended
def bar
puts "Class Method && Instance Method"
end
end
And with variations:
class Example
instance private
def foo
puts "Instance Method"
end
extended instance private # just like module_function
def bar
puts "Class Method && Instance Method"
end
end
T.