Skip to content

Instantly share code, notes, and snippets.

@somethvictory
Created June 12, 2018 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somethvictory/81e4709d1ecee4bbc6407522f7f75ae8 to your computer and use it in GitHub Desktop.
Save somethvictory/81e4709d1ecee4bbc6407522f7f75ae8 to your computer and use it in GitHub Desktop.
Data Transfer Object example in Ruby
class DTO::Domain
attr_reader :type, :name, :price, :status
def initialize(data)
@type = data['body']['type']
@name = data['body']['name']
@price = data['body']['price']
@status = data['body']['status']
end
def available?
status == 'Available' && price < 15
end
def taken?
status == 'Taken'
end
end
@0legovich
Copy link

What is the difference between a Value object and a this DTO?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment