Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # File: ruby-serialization-3.rb
- #
- require 'json'
- class Customer
- attr_accessor :name, :email
- def initialize(name, email)
- @name = name
- @email = email
- end
- def to_json
- {name: name, email: email}.to_json
- end
- end
- customer = Customer.new('John Smith', 'john_smith@mailinator.com')
- File.write('customers-db.json', customer.to_json)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement