Class: RubyEventStore::ActiveRecord::DatabaseAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/active_record/generators/database_adapter.rb

Direct Known Subclasses

MySQL, PostgreSQL, SQLite

Defined Under Namespace

Classes: MySQL, PostgreSQL, SQLite

Constant Summary collapse

NONE =
Object.new.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data_type = NONE) ⇒ DatabaseAdapter

Returns a new instance of DatabaseAdapter.

Raises:



43
44
45
46
47
48
49
# File 'lib/ruby_event_store/active_record/generators/database_adapter.rb', line 43

def initialize(data_type = NONE)
  raise UnsupportedAdapter if instance_of?(DatabaseAdapter)

  validate_data_type!(data_type)

  @data_type = data_type
end

Instance Attribute Details

#data_typeObject (readonly)

Returns the value of attribute data_type.



51
52
53
# File 'lib/ruby_event_store/active_record/generators/database_adapter.rb', line 51

def data_type
  @data_type
end

Class Method Details

.from_string(adapter_name, data_type = NONE) ⇒ Object

Raises:

  • (NoMethodError)


70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/ruby_event_store/active_record/generators/database_adapter.rb', line 70

def self.from_string(adapter_name, data_type = NONE)
  raise NoMethodError unless eql?(DatabaseAdapter)

  case adapter_name.to_s.downcase
  when "postgresql", "postgis"
    PostgreSQL.new(data_type)
  when "mysql2", "trilogy"
    MySQL.new(data_type)
  when "sqlite"
    SQLite.new(data_type)
  else
    raise UnsupportedAdapter, "Unsupported adapter: #{adapter_name.inspect}"
  end
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


57
58
59
# File 'lib/ruby_event_store/active_record/generators/database_adapter.rb', line 57

def eql?(other)
  other.is_a?(DatabaseAdapter) && adapter_name.eql?(other.adapter_name)
end

#hashObject



63
64
65
# File 'lib/ruby_event_store/active_record/generators/database_adapter.rb', line 63

def hash
  DatabaseAdapter.hash ^ adapter_name.hash
end

#supported_data_typesObject



53
54
55
# File 'lib/ruby_event_store/active_record/generators/database_adapter.rb', line 53

def supported_data_types
  self.class::SUPPORTED_DATA_TYPES
end

#template_directoryObject



67
68
# File 'lib/ruby_event_store/active_record/generators/database_adapter.rb', line 67

def template_directory
end