Class: Humble::Session
- Inherits:
-
Object
- Object
- Humble::Session
- Defined in:
- lib/humble/session.rb
Instance Method Summary collapse
- #begin_transaction(&block) ⇒ Object
- #delete(entity) ⇒ Object
- #dispose ⇒ Object
- #find_all(clazz) ⇒ Object
-
#initialize(connection_factory, mapper_registry) ⇒ Session
constructor
A new instance of Session.
- #save(entity) ⇒ Object
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 |
#dispose ⇒ Object
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 |