making types private in space
turned out to be unnecessary, but still better
This commit is contained in:
@ -42,6 +42,8 @@ module Parfait
|
||||
message = @first_message
|
||||
end
|
||||
@classes.each do |name , cl|
|
||||
raise "upps #{cl.instance_type.hash}" unless cl.instance_type.hash.is_a?(Fixnum)
|
||||
|
||||
@types[cl.instance_type.hash] = cl.instance_type
|
||||
end
|
||||
end
|
||||
@ -50,7 +52,7 @@ module Parfait
|
||||
[:classes , :types, :first_message]
|
||||
end
|
||||
|
||||
attr_reader :types , :classes , :first_message
|
||||
attr_reader :classes , :first_message
|
||||
|
||||
def each_type
|
||||
@types.values.each do |type|
|
||||
@ -58,6 +60,18 @@ module Parfait
|
||||
end
|
||||
end
|
||||
|
||||
def add_type(type)
|
||||
hash = type.hash
|
||||
raise "upps #{hash}" unless hash.is_a?(Fixnum)
|
||||
was = @types[hash]
|
||||
return was if was
|
||||
@types[hash] = type
|
||||
end
|
||||
|
||||
def get_type_for( hash )
|
||||
@types[hash]
|
||||
end
|
||||
|
||||
# all methods form all types
|
||||
def collect_methods
|
||||
methods = []
|
||||
|
@ -42,9 +42,7 @@ module Parfait
|
||||
def self.for_hash( object_class , hash)
|
||||
hash = {type: object_class.name }.merge(hash) unless hash[:type]
|
||||
new_type = Type.new( object_class , hash)
|
||||
code = hash_code_for_hash( hash )
|
||||
Parfait.object_space.types[code] = new_type
|
||||
new_type
|
||||
Parfait.object_space.add_type(new_type)
|
||||
end
|
||||
|
||||
def self.hash_code_for_hash( dict )
|
||||
@ -152,9 +150,6 @@ module Parfait
|
||||
raise "No nil type" unless type
|
||||
hash = to_hash
|
||||
hash[name] = type
|
||||
code = Type.hash_code_for_hash( hash )
|
||||
existing = Parfait.object_space.types[code]
|
||||
return existing if existing
|
||||
return Type.for_hash( @object_class , hash)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user