From 2f5ed4307378892ecea5fec3f6d8c9b15ccff7ae Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 14 Aug 2014 20:04:15 +0300 Subject: [PATCH] move from known attributes to volotile (white to blacklist) --- lib/sof/all.rb | 7 +------ lib/sof/known.rb | 13 ------------- lib/sof/util.rb | 7 ++----- lib/sof/volotile.rb | 10 ++++++++++ 4 files changed, 13 insertions(+), 24 deletions(-) delete mode 100644 lib/sof/known.rb create mode 100644 lib/sof/volotile.rb diff --git a/lib/sof/all.rb b/lib/sof/all.rb index 2071b35a..35a92570 100644 --- a/lib/sof/all.rb +++ b/lib/sof/all.rb @@ -1,6 +1,6 @@ require_relative "util" require_relative "members" -require_relative "known" +require_relative "volotile" require_relative "writer" require_relative "array" require_relative "occurence" @@ -10,11 +10,6 @@ Symbol.class_eval do io.write ":#{to_s}" end end -NilClass.class_eval do - def to_sof(io,members) - io.write "nil" - end -end TrueClass.class_eval do def to_sof(io , members) io.write "true" diff --git a/lib/sof/known.rb b/lib/sof/known.rb deleted file mode 100644 index 5e9289fe..00000000 --- a/lib/sof/known.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Sof - class Known - @@mapping = { - Virtual::MethodDefinition => [:name , :args , :receiver , :return_type , :blocks] - } - def self.is clazz - @@mapping.has_key? clazz - end - def self.attributes clazz - @@mapping[clazz] - end - end -end diff --git a/lib/sof/util.rb b/lib/sof/util.rb index 4e1eb6be..4451c429 100644 --- a/lib/sof/util.rb +++ b/lib/sof/util.rb @@ -15,11 +15,8 @@ module Sof end def attributes_for object - if( Known.is( object.class )) - Known.attributes(object.class) - else - object.instance_variables.collect{|i| i.to_s[1..-1].to_sym } # chop of @ - end + attributes = object.instance_variables.collect{|i| i.to_s[1..-1].to_sym } # chop of @ + attributes - Volotile.attributes(object.class) end end diff --git a/lib/sof/volotile.rb b/lib/sof/volotile.rb new file mode 100644 index 00000000..406851fb --- /dev/null +++ b/lib/sof/volotile.rb @@ -0,0 +1,10 @@ +module Sof + class Volotile + @@mapping = { + Virtual::MethodDefinition => [] + } + def self.attributes clazz + @@mapping[clazz] || [] + end + end +end