Class: PrestoAPI::Base
- Inherits:
-
Object
- Object
- PrestoAPI::Base
- Defined in:
- lib/presto_api.rb
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#from_json!(string) ⇒ Object
16 17 18 19 20 |
# File 'lib/presto_api.rb', line 16 def from_json! string JSON.load(string).each do |var, val| self.instance_variable_set var, val end end |
#to_json ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/presto_api.rb', line 6 def to_json hash = {} self.instance_variables.each do |var| # Remove @ symbol from var name key = var.to_s[1..-1] hash[key] = self.instance_variable_get var end hash.to_json end |