2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/operations/core_ext.rb', line 2
def to_operations
real_size = self.blank? ? 0 : self.strip.size
return [] if real_size == 0
by_uuid = Operations.from_uuid(self)
return by_uuid unless by_uuid.nil?
operations_list = []
begin
json_operations = JSON.parse(self)
rescue JSON::ParserError
raise Operations::Errors::InvalidOperationError.new('Could not parsel this String into a Operations::Operation object')
end
if json_operations.class == Array
json_operations.each do |json_value|
operations_list.append(json_value.to_s.to_operations)
end
elsif json_operations.class == Hash
json_operations.deep_symbolize_keys!
operations_list = Operations::Operation.new(**json_operations)
end
operations_list
end
|