Created
June 12, 2018 13:41
-
-
Save somethvictory/81e4709d1ecee4bbc6407522f7f75ae8 to your computer and use it in GitHub Desktop.
Data Transfer Object example in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is the difference between a Value object and a this DTO?