Sha256: 23261210abaaecf873d4608d878c2538fd966fb78e9ab6220237f58e51510784
Contents?: true
Size: 550 Bytes
Versions: 2
Compression:
Stored size: 550 Bytes
Contents
module Toy module Reloadable extend ActiveSupport::Concern def reload if attrs = adapter.read(persisted_id) attrs['id'] = persisted_id instance_variables.each { |ivar| instance_variable_set(ivar, nil) } initialize_attributes send(:attributes=, attrs, new_record?) self.class.lists.each_key { |name| send(name).reset } self.class.references.each_key { |name| send("reset_#{name}") } else raise NotFound.new(persisted_id) end self end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
toystore-0.13.2 | lib/toy/reloadable.rb |
toystore-0.13.1 | lib/toy/reloadable.rb |