Sha256: 2ff1d50bb4b675c4cd33ded52e05333bebd7ef19507aaf775e71b6d639349d3b
Contents?: true
Size: 1.49 KB
Versions: 12
Compression:
Stored size: 1.49 KB
Contents
module Conekta module Operations module Delete def delete self.custom_action(:delete, nil, nil) self end def delete_member(parent, member) self.custom_action(:delete, nil, nil) parent = parent.to_sym member = member.to_sym obj = self.method(parent).call.method(member).call if obj.class.class_name == "ConektaObject" self.method(parent).call.method(member).call.each do |(k, v)| if v.id == self.id self.method(parent).call.method(member).call[k] = nil # Shift hash array shift = false self.method(parent).call.method(member).call.each_with_index do |v,i| if shift self.method(parent).call.method(member).call.set_val(i-1,v[1]) self.method(parent).call.method(member).call[i-1] = v[1] end if v[1] == nil shift = true end end n_members = self.method(parent).call.method(member).call.count last_index = n_members - 1 # Remove last member because the hash array was shifted self.method(parent).call.method(member).call.unset_key(last_index) self.method(parent).call.method(member).call.delete(last_index) break end end else self.create_attr(member.to_s, nil) end self end end end end
Version data entries
12 entries across 12 versions & 2 rubygems