Sha256: 6124f9835c0ea02217dc3377b7a2aeea147c238cfc4f9dd96643ca1304ddfc2a

Contents?: true

Size: 616 Bytes

Versions: 6

Compression:

Stored size: 616 Bytes

Contents

class NetSystem::Database < Liza::Controller

  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

  attr_reader :client

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

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

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

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

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lizarb-1.0.8 lib/net_system/subsystems/database/database.rb
lizarb-1.0.7 lib/net_system/subsystems/database/database.rb
lizarb-1.0.6 lib/net_system/subsystems/database/database.rb
lizarb-1.0.5 lib/net_system/sub/database/database.rb
lizarb-1.0.4 lib/net_system/net/controllers/database.rb
lizarb-1.0.3 lib/net_system/net/controllers/database.rb