Sha256: 7fdecbe44ed109ff53206cb10c0a390a1891e05bab47b52ee21bc1c97ae252ca

Contents?: true

Size: 375 Bytes

Versions: 72

Compression:

Stored size: 375 Bytes

Contents

require 'json'

module SmartyStreets
  class JSONAble
    def to_json(options={})
      hash = {}
      instance_variables.each do |var|
        hash[var.to_s.delete('@')] = instance_variable_get var
      end
      hash.to_json
    end

    def from_json!(string)
      JSON.load(string).each do |var, val|
        instance_variable_set var, val
      end
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
smartystreets_ruby_sdk-5.20.6 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.20.4 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.20.3 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.20.2 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.19.0 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.18.1 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.18.0 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.17.2 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.17.1 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.17.0 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.16.2 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.16.1 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.16.0 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.15.4 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.15.3 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.15.2 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.15.1 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.15.0 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.14.22 lib/smartystreets_ruby_sdk/json_able.rb
smartystreets_ruby_sdk-5.14.19 lib/smartystreets_ruby_sdk/json_able.rb