Last active
March 18, 2019 12:21
-
-
Save a-suenami/3b69fff0715977eb27eeea267ee6fb6e to your computer and use it in GitHub Desktop.
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 Person # エンティティ | |
attr_reader :name, :yakiniku_treatment_type | |
def initialize(name, yakiniku_treatment_type, credit_card_number, cash_amount) | |
@name = Person::Name.new(name) | |
@yakiniku_treatment_type = Person::YakinikuTreatmentType.new(yakiniku_treatment_type) | |
end | |
def 焼肉を奢る | |
@yakiniku_treatment_type.奢る | |
end | |
end |
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 Person::Name # バリューオブジェクト | |
def initialize(name) | |
@name = name | |
end | |
def to_s | |
@name | |
end | |
end |
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 Person::Wallet | |
def initialize(amount, credit_card) | |
end | |
end |
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 Person::YakinikuTreatmentType # バリューオブジェクト(JavaとかだったらEnumにすれば楽) | |
CASH_ONLY = 1 # 現金のみ、現金が足りなければ奢らない | |
CREDIT_CARD_ONLY = 2 # クレジットカードのみ、限度額に達した場合は奢らない | |
CASH_FIRST = 3 # 財布の中に現金が足りれば現金、そうでなければクレジットカード | |
def initialize(value) | |
@value = value | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment