Class: Foobara::Persistence::EntityAttributesCrudDriver

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

Direct Known Subclasses

CrudDrivers::InMemoryMinimal

Defined Under Namespace

Classes: Table

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection_or_credentials = nil) ⇒ EntityAttributesCrudDriver

Returns a new instance of EntityAttributesCrudDriver.



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

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.1.7/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.1.7/projects/persistence/src/entity_attributes_crud_driver.rb', line 5

def tables
  @tables
end

Class Method Details

.has_real_transactions?Boolean

Returns:

  • (Boolean)


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

def has_real_transactions?
  false
end

Instance Method Details

#commit_transaction(_raw_tx) ⇒ Object



40
41
# File 'foobara-0.1.7/projects/persistence/src/entity_attributes_crud_driver.rb', line 40

def commit_transaction(_raw_tx)
end

#flush_transaction(_raw_tx) ⇒ Object



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

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



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

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



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

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



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

def revert_transaction(_raw_tx)
end

#rollback_transaction(_raw_tx) ⇒ Object



37
38
# File 'foobara-0.1.7/projects/persistence/src/entity_attributes_crud_driver.rb', line 37

def rollback_transaction(_raw_tx)
end

#table_for(entity_class) ⇒ Object



43
44
45
46
47
# File 'foobara-0.1.7/projects/persistence/src/entity_attributes_crud_driver.rb', line 43

def table_for(entity_class)
  key = entity_class.full_entity_name

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