Class: Copyable::CopyRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/copyable/copy_registry.rb

Class Method Summary collapse

Class Method Details

.already_copied?(options) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/copyable/copy_registry.rb', line 19

def already_copied?(options)
  fetch_copy(options).present?
end

.clearObject



29
30
31
# File 'lib/copyable/copy_registry.rb', line 29

def clear
  @registry = {}
end

.fetch_copy(options) ⇒ Object



23
24
25
26
27
# 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) ⇒ Object



13
14
15
16
17
# 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