Module: MyStuff::MultiDB::CoreExt::Base::ClassMethods

Defined in:
lib/my_stuff/multidb/core_ext/base.rb

Instance Method Summary collapse

Instance Method Details

#abstract_class?Boolean

Returns:

  • (Boolean)


41
# File 'lib/my_stuff/multidb/core_ext/base.rb', line 41

def abstract_class?; true; end

#arel_engineObject



29
30
31
# File 'lib/my_stuff/multidb/core_ext/base.rb', line 29

def arel_engine
  magic_database.arel_engine
end

#base_classObject



20
21
22
# File 'lib/my_stuff/multidb/core_ext/base.rb', line 20

def base_class
  self
end

#connectionObject



33
34
35
# File 'lib/my_stuff/multidb/core_ext/base.rb', line 33

def connection
  magic_database.connection
end

#connection_poolObject



37
38
39
# File 'lib/my_stuff/multidb/core_ext/base.rb', line 37

def connection_pool
  magic_database.connection_pool
end

#inherited(child) ⇒ Object



50
51
52
53
54
# File 'lib/my_stuff/multidb/core_ext/base.rb', line 50

def inherited(child)
  def child.abstract_class?; false; end
  def child.base_class; self; end
  super
end

#magic_databaseObject



24
25
26
27
# File 'lib/my_stuff/multidb/core_ext/base.rb', line 24

def magic_database
  @magic_database ||=
    self.name.split('::')[0..-2].join('::').constantize
end

#model_nameObject



43
44
45
46
47
48
# File 'lib/my_stuff/multidb/core_ext/base.rb', line 43

def model_name
  # Rails form_for wants this
  ActiveModel::Name.new(
    self.name.split('::').last.tap{|s| def s.name; self; end}
  )
end