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
19 20 21 22 23 |
# File 'lib/presto_api.rb', line 19 def from_json! string JSON.load(string).each do |var, val| self.instance_variable_set var, val end end |
#to_json ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/presto_api.rb', line 9 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 |