Module: Diametric::Persistence::PeerFunction

Defined in:
lib/diametric/persistence/peer_function.rb

Instance Method Summary collapse

Instance Method Details

#create_function(function_map, conn = nil) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/diametric/persistence/peer_function.rb', line 4

def create_function(function_map, conn=nil)
  conn ||= Diametric::Persistence::Peer.connection
  map = function_map.dup
  name = map.delete(:name)
  doc = map.delete(:doc)
  function =  Diametric::Persistence::Peer.function(map)
  schema = {:"db/id" => Diametric::Persistence::Peer.tempid(:"db.part/user"),
            :"db/ident" => name.to_sym,
            :"db/fn" => function}
  if doc
    schema.merge!({:"db/doc" => doc})
  end
  result = conn.transact([schema]).get
end