Что такое лучший способ защитить атрибут? См. Пункт ниже:Защитить атрибут объекта ruby от доступа
class Document
# no method outside this class can access this directly. If they call document.data, error should be thrown. including in any rendering
field sensitive_data
# but this method can be accessed by anyone
def get_sensitive_data
# where I apply the right protection
end
end
Я думаю, что ключевое слово 'protected' делает то, что вам нужно. –