Class: Gridspace::JSONable
- Inherits:
-
Object
- Object
- Gridspace::JSONable
- Defined in:
- lib/gridspace/commands.rb
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#from_json!(string) ⇒ Object
12 13 14 15 16 |
# File 'lib/gridspace/commands.rb', line 12 def from_json! string JSON.load(string).each do |var, val| self.instance_variable_set var, val end end |
#to_json(options = nil) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/gridspace/commands.rb', line 3 def to_json = nil hash = {} self.instance_variables.each do |var| # remove @ base = var[1..-1] hash[base] = self.instance_variable_get(var) end hash.to_json end |