diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-10 22:33:13 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-10 22:33:13 +0200 |
commit | 35e2ab44bd633702a363fea3752affb31f2094e3 (patch) | |
tree | ac95621d5cbeb7a3d57f9bb7955a5ebe15e7e138 /lib | |
parent | 5e21e89bf467e212cd783752bb50c00143a52cb1 (diff) | |
download | edoors-ruby-35e2ab44bd633702a363fea3752affb31f2094e3.zip edoors-ruby-35e2ab44bd633702a363fea3752affb31f2094e3.tar.gz |
Door: implement #to_json and #self.json_create
Diffstat (limited to 'lib')
-rw-r--r-- | lib/evendoors/door.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/evendoors/door.rb b/lib/evendoors/door.rb index 7cff0b9..ba8bde6 100644 --- a/lib/evendoors/door.rb +++ b/lib/evendoors/door.rb @@ -12,6 +12,18 @@ module EvenDoors @parent.add_spot self if @parent end # + def to_json *a + { + 'kls' => self.class.name, + 'name' => @name + }.to_json *a + end + # + def self.json_create o + raise EvenDoors::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name + self.new o['name'] + end + # def require_p p_kls p = EvenDoors::Spin.require_p p_kls p.src = self |