Class: Orientea::CreatingCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/orientea/creating_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

action, undo

Class Method Details

.build(record) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/orientea/creating_command.rb', line 7

def self.build(record)
  command = self.new
  command.data = Hash.new
  command.data['changes'] = record.attributes.to_json
  command.data['cls_str'] = record.class.to_s
  # command.save!
  command
end

Instance Method Details

#get_recordObject



16
17
18
19
# File 'lib/orientea/creating_command.rb', line 16

def get_record
  cls = self.data['cls_str'].constantize
  self.done ? cls.find(self.data['cls_id']): cls.new(JSON.load(self.data['changes']), without_protection: true)
end