Class: Rack::MultiTenant::GetCurrentTenant::Builder
- Inherits:
-
Object
- Object
- Rack::MultiTenant::GetCurrentTenant::Builder
- Defined in:
- lib/rack/multitenant/get_current_tenant.rb
Instance Method Summary collapse
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #to_proc ⇒ Object
- #use(name, *args, &blk) ⇒ Object (also: #with)
Constructor Details
#initialize ⇒ Builder
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_proc ⇒ Object
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 |