Derive Class and MetaClass from Behaviour

Finally! If i remember the module was from before i had any non Object superclasses
unified code, unified bugs :-) just makes sense
This commit is contained in:
2019-09-21 18:50:33 +03:00
parent 3b7248df4e
commit a496ea7e4b
15 changed files with 42 additions and 70 deletions

View File

@ -3,11 +3,14 @@
# instance_methods is the attribute in the including class that has the methods
module Parfait
module Behaviour
class Behaviour < Object
def initialize
attr_reader :instance_type , :instance_methods
def initialize(type)
super()
@instance_methods = List.new
@instance_type = type
end
def methods
@ -24,9 +27,14 @@ module Parfait
names
end
def add_instance_method_for(name , type , frame , body )
method = Parfait::VoolMethod.new(name , type , frame , body )
add_instance_method( method )
end
def add_instance_method( method )
raise "not implemented #{method.class} #{method.inspect}" unless method.is_a? VoolMethod
raise "HMM"
@instance_methods.push(method)
method
end
@ -52,5 +60,10 @@ module Parfait
method
end
# adding an instance changes the instance_type to include that variable
def add_instance_variable( name , type)
@instance_type = @instance_type.add_instance_variable( name , type )
end
end
end