Class: Humble::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/humble/session.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection_factory, mapper_registry) ⇒ Session

Returns a new instance of Session.



3
4
5
6
# File 'lib/humble/session.rb', line 3

def initialize(connection_factory, mapper_registry)
  @connection_factory = connection_factory
  @mapper_registry = mapper_registry
end

Instance Method Details

#begin_transaction(&block) ⇒ Object



8
9
10
11
12
# File 'lib/humble/session.rb', line 8

def begin_transaction(&block)
  create_connection.transaction do
    block.call(self)
  end
end

#delete(entity) ⇒ Object



22
23
24
# File 'lib/humble/session.rb', line 22

def delete(entity)
  mapping_for(entity).delete_using(create_connection, entity)
end

#disposeObject



26
27
# File 'lib/humble/session.rb', line 26

def dispose
end

#find_all(clazz) ⇒ Object



18
19
20
# File 'lib/humble/session.rb', line 18

def find_all(clazz)
  mapping_for(clazz).find_all_using(create_connection)
end

#save(entity) ⇒ Object



14
15
16
# File 'lib/humble/session.rb', line 14

def save(entity)
  mapping_for(entity).save_using(create_connection, entity)
end