class Stud::Secret
Public Class Methods
Source
# File lib/stud/secret.rb, line 13 def initialize(secret_value) # Redefine the 'value' method on this instance. This exposes no instance # variables to be accidentally leaked by things like awesome_print, etc. # This makes any #value call return the secret value. (class << self; self; end).class_eval do define_method(:value) { secret_value } end end
Initialize a new secret with a given value.
value - anything you want to keep secret from loggers, etc.
Public Instance Methods
Source
# File lib/stud/secret.rb, line 23 def to_s return "<secret>" end
Emit simply “<secret>” when printed or logged.
Also aliased as: inspect
Source
# File lib/stud/secret.rb, line 30 def value # Nothing, this will be filled in by Secret.new # But we'll still document this so rdoc/yard know the method exists. end
Get the secret value.