Module: Rhoconnect::Condition::ClientRequired

Included in:
Server
Defined in:
lib/rhoconnect/condition/client_required.rb

Overview

Sinatra condition

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



7
8
9
# File 'lib/rhoconnect/condition/client_required.rb', line 7

def self.extended(base)
  base.include_client_required_condition
end

Instance Method Details

#include_client_required_conditionObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rhoconnect/condition/client_required.rb', line 11

def include_client_required_condition
  include ClientRequiredHelpers
  set(:client_required) do |value|
    condition do
      if value
        catch_all do
          client = extract_current_client
          # client should be valid here
          raise ArgumentError.new(UNKNOWN_CLIENT) unless client
          env[CURRENT_CLIENT] = client
        end
      end
    end
  end
end