Sha256: 33e2a784c358e506682273541c053e6645d1f25af7c64175176227c9b4079642

Contents?: true

Size: 784 Bytes

Versions: 2

Compression:

Stored size: 784 Bytes

Contents

# encoding: utf-8

class Demo
  module Core
    module Handler

      class Authorizer
        extend Handler
        include Substation::Processor::Evaluator::Handler

        def initialize(request)
          @request    = request
          @input      = @request.input
          @db         = @request.env.storage
          @account_id = @request.input.session.fetch('account_id')
          @privilege  = @request.name.to_s
        end

        def call
          authorized? ? success(input) : error(input)
        end

        attr_reader :request
        private     :request

        attr_reader :input
        private     :input

        private

        def authorized?
          !!@db.load_account_privilege(@account_id, @privilege)
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
substation-0.0.11 spec/demo/core/handler/authorizer.rb
substation-0.0.10 spec/demo/core/handler/authorizer.rb