class Copyable::CopyRegistry
Public Class Methods
already_copied?(options)
click to toggle source
# File lib/copyable/copy_registry.rb, line 19 def already_copied?(options) fetch_copy(options).present? end
clear()
click to toggle source
# File lib/copyable/copy_registry.rb, line 29 def clear @registry = {} end
fetch_copy(options)
click to toggle source
# File lib/copyable/copy_registry.rb, line 23 def fetch_copy(options) @registry ||= {} key = make_hash(options) @registry[key] end
register(original_record, new_record)
click to toggle source
# File lib/copyable/copy_registry.rb, line 13 def register(original_record, new_record) @registry ||= {} key = make_hash(record: original_record) @registry[key] = new_record end
Private Class Methods
make_hash(options)
click to toggle source
# File lib/copyable/copy_registry.rb, line 35 def make_hash(options) if options[:record] id = options[:record].id klass = options[:record].class else id = options[:id] klass = options[:class] end raise "Record has no id" if id.nil? "#{klass.name}-#{id}" end