Sha256: d44abf28127b8756605d63d057fa65c05c477a186cad1b7f2b6ace2fda59fd29

Contents?: true

Size: 857 Bytes

Versions: 1

Compression:

Stored size: 857 Bytes

Contents

require 'nyny/base'
require 'nyny/templates'
require 'better_errors'
require 'ostruct'

module NYNY
  class App < Base
    inheritable :config, OpenStruct.new
    register NYNY::Templates
    use Rack::Chunked

    class << self
      def configure *envs, &block
        if envs.map(&:to_sym).include?(NYNY.env.to_sym) or envs.empty?
          instance_eval(&block)
        end
      end

      def namespace url, &block
        scope  = self.scope_class

        klass = Class.new self.superclass do
          self.scope_class = scope
          class_eval(&block)
        end

        builder.map (url) { use klass }
      end

      def run! port=9292
        use Rack::CommonLogger
        use BetterErrors::Middleware unless NYNY.env.production?
        Rack::Handler.pick(['puma', 'thin', 'webrick']).run new, :Port => port
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nyny-3.4.0 lib/nyny/app.rb