class AttrSecure::Secret
Attributes
env[R]
secret[R]
Public Class Methods
new(options)
click to toggle source
# File lib/attr_secure/secret.rb, line 4 def initialize(options) @secret, @env = options.values_at(:secret, :env) end
Public Instance Methods
call(object=nil)
click to toggle source
# File lib/attr_secure/secret.rb, line 8 def call(object=nil) if secret.respond_to?(:call) secret.call(object) else secret || env!('ATTR_SECURE_SECRET') end end
Private Instance Methods
env!(key)
click to toggle source
# File lib/attr_secure/secret.rb, line 19 def env!(key) env.fetch(key) { raise("Missing ENV(#{key})") } end