start on to_json and json_create
This commit is contained in:
parent
99493865c1
commit
657d6319ad
@ -10,8 +10,24 @@
|
||||
module Ast
|
||||
class Expression
|
||||
def attributes
|
||||
[]
|
||||
raise "abstract called for #{self}"
|
||||
end
|
||||
def to_json(*a)
|
||||
data = {}
|
||||
attributes.each do |name|
|
||||
data[name] = instance_variable_get(name)
|
||||
end
|
||||
puts data
|
||||
{
|
||||
"json_class" => self.class.name,
|
||||
"data" => data
|
||||
}.to_json(*a)
|
||||
end
|
||||
|
||||
def self.json_create(o)
|
||||
new(*o["data"].values)
|
||||
end
|
||||
|
||||
def inspect
|
||||
self.class.name + ".new()"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user