I made a class with these methods:
def promotion_available?
promotion.present?
end
def promotion
@promotion ||= PromotionUser.user(@user.id).available.first
end
Then, a colleague removed the promotion
method, and changed the predicate promotion_available?
in this way:
def promotion_available?
@promotion ||= PromotionUser.user(@user.id).available.first
end
- Can I set an instance variable directly on a predicate method?
- Can a predicate method return an entire object instead of
true
/false
(I think no, but my colleague says the opposite)?