Module: ActiveCrypto::AssociationKeyHolder

Includes:
KeyHolder
Defined in:
lib/gems/ezcrypto-0.7/lib/active_crypto.rb

Instance Method Summary collapse

Methods included from KeyHolder

#enter_password, #set_encoded_key

Instance Method Details

#save_session_keyObject



148
149
150
# File 'lib/gems/ezcrypto-0.7/lib/active_crypto.rb', line 148

def save_session_key
  ActiveRecord::Base.session_keys[session_key_id]=@session_key if @session_key
end

#session_keyObject

Returns the session_key



167
168
169
170
171
172
173
# File 'lib/gems/ezcrypto-0.7/lib/active_crypto.rb', line 167

def session_key
  if self.new_record?
    @session_key
  else
    ActiveRecord::Base.session_keys[session_key_id]
  end
end

#session_key_idObject



177
178
179
# File 'lib/gems/ezcrypto-0.7/lib/active_crypto.rb', line 177

def session_key_id
  "#{self.class.to_s}:#{id}"
end

#set_session_key(key) ⇒ Object

Sets a session key for the object. This should be a EzCrypto::Key instance.



154
155
156
157
158
159
160
161
162
# File 'lib/gems/ezcrypto-0.7/lib/active_crypto.rb', line 154

def set_session_key(key)    
  if self.new_record?
    @session_key=key
  else
    ActiveRecord::Base.session_keys[session_key_id]=key
  end
  decrypt_attributes if self.class.include? Encrypted #if respond_to?(:decrypt_attributes)
  
end