Class: Rack::MultiTenant::GetCurrentTenant::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/multitenant/get_current_tenant.rb

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



63
64
65
# File 'lib/rack/multitenant/get_current_tenant.rb', line 63

def initialize
  @stack = []
end

Instance Method Details

#to_procObject



77
78
79
80
81
82
83
84
# File 'lib/rack/multitenant/get_current_tenant.rb', line 77

def to_proc
  _stack = @stack.compact
  lambda {|request|
    tenant = nil
    _stack.find {|strategy| tenant = strategy.call(request)}
    tenant
  }
end

#use(name, *args, &blk) ⇒ Object Also known as: with



67
68
69
70
71
72
73
74
# File 'lib/rack/multitenant/get_current_tenant.rb', line 67

def use(name, *args, &blk)
  @stack << case strategy = resolve(name)
  when Class
    strategy.new(*args, &blk)
  else
    strategy
  end
end