Sha256: 8bba59999ce2ad9626face420b6e818e1071bc68fc065d72e23733030d11de59

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 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/frameworks"
  require "hanami/container"
  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=(app)
    @_mutex.synchronize do
      raise "Hanami application already configured" if defined?(@_application)

      @_application = app unless app.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.root
    Container.root
  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
    Container[:logger]
  end

  def self.boot
    @_mutex.synchronize do
      raise "Hanami application already booted" if defined?(@_booted)

      @_booted = true
    end

    Container.finalize!
    self.app = application.new
  end

  def self.bundler_groups
    [:plugins]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hanami-2.0.0.alpha1 lib/hanami.rb