Sha256: 688f5788c7376a504ac50f9e16d56d60a0fc74a72920a694c1cc931d4e52d294

Contents?: true

Size: 773 Bytes

Versions: 2

Compression:

Stored size: 773 Bytes

Contents

# frozen_string_literal: true

module Logux
  class BaseController
    class << self
      def verify_authorized!
        Logux.configuration.verify_authorized = true
      end

      def unverify_authorized!
        Logux.configuration.verify_authorized = false
      end
    end

    attr_reader :action, :meta

    def initialize(action:, meta: {})
      @action = action
      @meta = meta
    end

    def respond(status, action: @action, meta: @meta, custom_data: nil)
      Logux::Response.new(status,
                          action: action,
                          meta: meta,
                          custom_data: custom_data)
    end

    def user_id
      @user_id ||= meta.user_id
    end

    def node_id
      @node_id ||= meta.node_id
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
logux-rack-0.1.0 lib/logux/base_controller.rb
logux_rails-0.1.0 lib/logux/base_controller.rb