Class: NetSystem::Database

Inherits:
Liza::Controller show all
Defined in:
lib/net_system/subsystems/database/database.rb

Direct Known Subclasses

MongoDb, MysqlDb, PgsqlDb, RedisDb, SqliteDb

Instance Attribute Summary collapse

Attributes inherited from Liza::Controller

#menv

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Liza::Controller

`, #`, attr_accessor, attr_reader, attr_writer, #attrs, #box, box, color, division, division!, division?, menv_accessor, menv_reader, menv_writer, on_connected, panel, #panel, plural, require, requirements, #sh, sh, singular, subsystem, subsystem!, subsystem?, subsystem_token, token

Methods inherited from Liza::Unit

_erbs_for, #add, add, cl, #cl, class_methods_defined, const_added, const_missing, constants_defined, define_error, descendants_select, division, erbs_available, erbs_defined, erbs_for, errors, #fetch, fetch, get, #get, instance_methods_defined, log, #log, log?, #log?, #log_array, log_array, log_hash, #log_hash, #log_level, log_level, #log_level?, log_level?, log_levels, #log_levels, #log_render_convert, #log_render_format, #log_render_in, #log_render_out, method_added, methods_defined, namespace, part, raise_error, #raise_error, reload!, #reload!, #render, #render!, #render_stack, renderable_formats_for, renderable_names, section, sections, #set, set, #settings, settings, singleton_method_added, sleep, #sleep, stick, #stick, sticks, #sticks, subclasses_select, subunits, system, #system, system?, test_class, time_diff, #time_diff

Constructor Details

#initialize(client: get(:client).new) ⇒ Database

Returns a new instance of Database.



13
14
15
# File 'lib/net_system/subsystems/database/database.rb', line 13

def initialize client: get(:client).new
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



11
12
13
# File 'lib/net_system/subsystems/database/database.rb', line 11

def client
  @client
end

Class Method Details

.callObject



28
# File 'lib/net_system/subsystems/database/database.rb', line 28

def self.call(...); current.call(...); end

.currentObject



21
22
23
24
25
26
# File 'lib/net_system/subsystems/database/database.rb', line 21

def self.current
  Thread.current[last_namespace] ||= begin
    log "Connecting to #{last_namespace}"
    new
  end
end

.inherited(sub) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/net_system/subsystems/database/database.rb', line 3

def self.inherited sub
  super

  return if sub.name.nil?
  return if sub.name.end_with? "Db"
  raise "please rename #{sub.name} to #{sub.name}Db"
end

.set_client(client_id) ⇒ Object



17
18
19
# File 'lib/net_system/subsystems/database/database.rb', line 17

def self.set_client client_id
  set :client, Liza.const("#{client_id}_client")
end

Instance Method Details

#callObject



29
# File 'lib/net_system/subsystems/database/database.rb', line 29

def call(...); @client.call(...); end