10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/snappier/take.rb', line 10
def self.for(entity)
action = "update"
action = "create" if entity.previously_new_record?
action = "destroy" if entity.destroyed?
snapper = Registry.for_entity(entity)
state = snapper ? snapper.snap(entity) : entity.attributes
Job.perform_async(
"at" => Time.now.strftime("%s%L"),
"action" => action,
"id" => entity.id,
"type" => entity.class.name,
"state" => state.to_json,
"who" => Who.current,
)
entity
end
|