Module: Arc::DataStores::ArelCompatibility

Included in:
AbstractDataStore
Defined in:
lib/arc/data_stores/abstract/arel_compatibility.rb

Instance Method Summary collapse

Instance Method Details

#columns_hashObject

the interface for each of these methods is already implemented by the existing class just return self



33
34
35
# File 'lib/arc/data_stores/abstract/arel_compatibility.rb', line 33

def columns_hash
  self
end

#connectionObject



36
37
38
# File 'lib/arc/data_stores/abstract/arel_compatibility.rb', line 36

def connection
  self
end

#connection_poolObject



39
40
41
# File 'lib/arc/data_stores/abstract/arel_compatibility.rb', line 39

def connection_pool
  self
end

#primary_key(table) ⇒ Object

provide a method for getting at the primary key of a given table



26
27
28
29
30
# File 'lib/arc/data_stores/abstract/arel_compatibility.rb', line 26

def primary_key table
  return nil unless table
  table = self[table]
  pk = table.column_names.find{ |c| table[c].primary_key? }
end

#quote_hash(h) ⇒ Object

hashes, imo, have no business in a sql database add ability to quote a hash here to keep arel tests passing



22
23
24
# File 'lib/arc/data_stores/abstract/arel_compatibility.rb', line 22

def quote_hash h
  quote_string h.to_yaml
end

#specObject



42
43
44
# File 'lib/arc/data_stores/abstract/arel_compatibility.rb', line 42

def spec
  self
end

#table_exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/arc/data_stores/abstract/arel_compatibility.rb', line 17

def table_exists? name
  !self[name.to_sym].nil?
end

#visitorObject

tell arel how we’ll be using it today



14
15
16
# File 'lib/arc/data_stores/abstract/arel_compatibility.rb', line 14

def visitor
  Arel::Visitors.for self
end

#with_connection {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



45
46
47
# File 'lib/arc/data_stores/abstract/arel_compatibility.rb', line 45

def with_connection
  yield self
end