Module: Nark::ClassMethods

Defined in:
lib/nark.rb

Instance Method Summary collapse

Instance Method Details

#collection_name(value = nil) ⇒ Object



29
30
31
32
# File 'lib/nark.rb', line 29

def collection_name(value = nil)
  @collection_name = value if value
  @collection_name
end

#emit(narks = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/nark.rb', line 34

def emit(narks = {})
  return if narks.empty?

  nark_hash =
    narks.each_with_object(Hash.new { |h, k| h[k] = [] }) do |nark, hash|
      hash[nark.collection_name] << nark.serializable_hash
    end

  Nark.emitter.emit_bulk(nark_hash)
end