Sha256: 8a260f85698e7e5465271b8f5531a8dfba5f65ffddc09f4757be341e09c267e9
Contents?: true
Size: 861 Bytes
Versions: 35
Compression:
Stored size: 861 Bytes
Contents
module Renalware class RememberedPreferences def initialize(session) @session = session end def persist(model) return unless model self.class::ATTRIBUTES_TO_REMEMBER.each do |attribute| remembered_attributes[attribute] = model.public_send(attribute) end session[self.class::SESSION_KEY] = remembered_attributes end def apply_to(model) return unless model self.class::ATTRIBUTES_TO_REMEMBER.each do |attribute| unless model.public_send(:"#{attribute}?") model.public_send(:"#{attribute}=", remembered_attributes[attribute]) end end end protected attr_accessor :session def remembered_attributes @remembered_attributes ||= begin session.fetch(self.class::SESSION_KEY, {}).with_indifferent_access end end end end
Version data entries
35 entries across 35 versions & 1 rubygems