Sha256: 77f27460923e47331ab6cc9406e25b2ebf5148b39b51853922e9f8e41d4b3aa9
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
module ActiveData module Model module Persistence extend ActiveSupport::Concern module ClassMethods def instantiate data data = data.stringify_keys instance = allocate instance.instance_variable_set(:@initial_attributes, data.slice(*attribute_names)) instance.send(:mark_persisted!) instance end def instantiate_collection data collection = Array.wrap(data).map { |attrs| instantiate attrs } collection = scope(collection, true) if respond_to?(:scope) collection end end def persisted? !!@persisted end def destroyed? !!@destroyed end def marked_for_destruction? @marked_for_destruction end def mark_for_destruction @marked_for_destruction = true end def _destroy marked_for_destruction? end private def mark_persisted! @persisted = true @destroyed = false end def mark_destroyed! @persisted = false @destroyed = true end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_data-1.0.0 | lib/active_data/model/persistence.rb |