diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-10 22:29:31 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-10 22:29:31 +0200 |
commit | c56306657ba69e2bd896df4fc92162d038358b27 (patch) | |
tree | 9a745c6fb795cb4910334fc8e002d4590d9fe215 | |
parent | 3a6b898f8e8d103b3858948e2bc1a187d97cbcc5 (diff) | |
download | edoors-ruby-c56306657ba69e2bd896df4fc92162d038358b27.zip edoors-ruby-c56306657ba69e2bd896df4fc92162d038358b27.tar.gz |
Link: implement #to_json and #self.json_create
-rw-r--r-- | lib/evendoors/link.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/evendoors/link.rb b/lib/evendoors/link.rb index d871f1c..148f2f8 100644 --- a/lib/evendoors/link.rb +++ b/lib/evendoors/link.rb @@ -15,6 +15,22 @@ module EvenDoors @door = nil # pointer to the source end # + def to_json *a + { + 'kls' => self.class.name, + 'src' => @src, + 'dsts' => @dsts, + 'fields' => @fields, + 'cond_fields' => @cond_fields, + 'cond_value' => @cond_value + }.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['src'], o['dsts'], o['fields'], o['cond_fields'], o['cond_value'] + end + # def self.from_particle_data p EvenDoors::Link.new(p.get_data(EvenDoors::LNK_SRC), p.get_data(EvenDoors::LNK_DSTS), p.get_data(EvenDoors::LNK_FIELDS), p.get_data(EvenDoors::LNK_CONDF), |