Class: SmartyStreets::JSONAble
- Inherits:
-
Object
- Object
- SmartyStreets::JSONAble
show all
- Defined in:
- lib/smartystreets_ruby_sdk/json_able.rb
Instance Method Summary
collapse
Instance Method Details
#from_json!(string) ⇒ Object
13
14
15
16
17
|
# File 'lib/smartystreets_ruby_sdk/json_able.rb', line 13
def from_json!(string)
JSON.load(string).each do |var, val|
instance_variable_set var, val
end
end
|
#to_json(options = {}) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/smartystreets_ruby_sdk/json_able.rb', line 5
def to_json(options={})
hash = {}
instance_variables.each do |var|
hash[var.to_s.delete('@')] = instance_variable_get var
end
hash.to_json
end
|