Class: Foobara::Persistence::EntityAttributesCrudDriver

Inherits:
Object
  • Object
show all
Defined in:
foobara-0.0.110/projects/persistence/src/entity_attributes_crud_driver.rb

Direct Known Subclasses

CrudDrivers::InMemoryMinimal

Defined Under Namespace

Classes: Table

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection_or_credentials = nil) ⇒ EntityAttributesCrudDriver

Returns a new instance of EntityAttributesCrudDriver.



7
8
9
10
# File 'foobara-0.0.110/projects/persistence/src/entity_attributes_crud_driver.rb', line 7

def initialize(connection_or_credentials = nil)
  self.raw_connection = open_connection(connection_or_credentials)
  self.tables = {}
end

Instance Attribute Details

#raw_connectionObject

Returns the value of attribute raw_connection.



5
6
7
# File 'foobara-0.0.110/projects/persistence/src/entity_attributes_crud_driver.rb', line 5

def raw_connection
  @raw_connection
end

#tablesObject

Returns the value of attribute tables.



5
6
7
# File 'foobara-0.0.110/projects/persistence/src/entity_attributes_crud_driver.rb', line 5

def tables
  @tables
end

Instance Method Details

#close_transaction(_raw_tx) ⇒ Object



34
35
# File 'foobara-0.0.110/projects/persistence/src/entity_attributes_crud_driver.rb', line 34

def close_transaction(_raw_tx)
end

#flush_transaction(_raw_tx) ⇒ Object



25
26
# File 'foobara-0.0.110/projects/persistence/src/entity_attributes_crud_driver.rb', line 25

def flush_transaction(_raw_tx)
end

#open_connection(_connection_or_credentials) ⇒ Object

Default behavior is for technologies that don’t have a connection concept in a proper sense



14
15
16
# File 'foobara-0.0.110/projects/persistence/src/entity_attributes_crud_driver.rb', line 14

def open_connection(_connection_or_credentials)
  # should we return some kind of Connection object here even if it does nothing interesting?
end

#open_transactionObject

Default behavior is for storage technologies that don’t support proper transaction support



20
21
22
23
# File 'foobara-0.0.110/projects/persistence/src/entity_attributes_crud_driver.rb', line 20

def open_transaction
  # Should we have some kind of fake transaction object that raises errors when used after rolledback/closed?
  Object.new
end

#revert_transaction(_raw_tx) ⇒ Object



28
29
# File 'foobara-0.0.110/projects/persistence/src/entity_attributes_crud_driver.rb', line 28

def revert_transaction(_raw_tx)
end

#rollback_transaction(_raw_tx) ⇒ Object



31
32
# File 'foobara-0.0.110/projects/persistence/src/entity_attributes_crud_driver.rb', line 31

def rollback_transaction(_raw_tx)
end

#table_for(entity_class) ⇒ Object



37
38
39
40
41
# File 'foobara-0.0.110/projects/persistence/src/entity_attributes_crud_driver.rb', line 37

def table_for(entity_class)
  key = entity_class.full_entity_name

  tables[key] ||= self.class::Table.new(entity_class, self)
end