Sha256: 8efcca61a168d321f5aae34a3a52e9a2094a5bd9cf56ce479fee80bf5f3c48d0

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

# A complete web framework for Ruby
#
# @since 0.1.0
#
# @see http://hanamirb.org
module Hanami
  require "hanami/version"
  require "hanami/application"

  @_mutex = Mutex.new

  def self.application
    @_mutex.synchronize do
      raise "Hanami.application not configured" unless defined?(@_application)

      @_application
    end
  end

  def self.application?
    defined?(@_application)
  end

  def self.application=(klass)
    @_mutex.synchronize do
      raise "Hanami.application already configured" if defined?(@_application)

      @_application = klass unless klass.name.nil?
    end
  end

  def self.app
    @_mutex.synchronize do
      raise "Hanami.app not configured" unless defined?(@_app)

      @_app
    end
  end

  def self.app=(app)
    @_mutex.synchronize do
      raise "Hanami.app already configured" if defined?(@_app)

      @_app = app
    end
  end

  def self.env
    (ENV["HANAMI_ENV"] || "development").to_sym
  end

  def self.env?(*names)
    names.map(&:to_sym).include?(env)
  end

  def self.logger
    application[:logger]
  end

  def self.init
    application.init
  end

  def self.boot(web: true)
    if defined?(@_app)
      @_app
    else
      application.boot

      @_app = application.new if web
    end
  end

  def self.shutdown
    application.shutdown
  end

  def self.bundler_groups
    [:plugins]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hanami-2.0.0.alpha4 lib/hanami.rb
hanami-2.0.0.alpha3 lib/hanami.rb