Sha256: b7a0efe0b63968214280ad6df41a34ac846a74db869e92e9b8f74480bbc53e9e

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

# encoding: UTF-8
require 'rack'
require 'extlib'

module Mojito
	require 'mojito/request_extensions'
	require 'mojito/helpers'
	require 'mojito/base'
	require 'mojito/utils/status_codes'
	require 'mojito/rendering'
	require 'mojito/matchers'
	
	R = Rendering
	M = Matchers
	H = Helpers
	
	def self.included(type)
		type.instance_exec do
			ALL_HELPERS.reverse.each do |mod|
				include mod
			end
		end
	end
	
	def self.base_application(*helpers, &block)
		Class.new.tap do |cl|
			cl.instance_exec do
				include Mojito::Base
				helpers.reverse.each do |helper|
					include helper
				end
			end
			cl.routes &block if block
		end		
	end
	
	def self.application(*helpers, &block)
		Class.new.tap do |cl|
			cl.instance_exec do
				include Mojito
				helpers.reverse.each do |helper|
					include helper
				end
			end
			cl.routes &block if block
		end
	end
	
	def self.mode
		(ENV['RACK_ENV'] || :development).to_sym
	end

	
	ALL_HELPERS = [Mojito::Matchers, Mojito::Rendering, Mojito::Helpers::ExceptionHandling, Mojito::Helpers::Shortcuts, Mojito::Base]

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mojito-0.1.1 lib/mojito.rb