Sha256: de718684166d583ad4e93d8a209ad352cbd885cdb8b3154bc30a39477a2ee53b
Contents?: true
Size: 710 Bytes
Versions: 4
Compression:
Stored size: 710 Bytes
Contents
module Happy module Utils # SMELL: this should be a controller, spawning another controller. class AppSpawner attr_reader :options def initialize(options = {}) @app = nil @options = { :scripts => './app/*.rb' }.merge(options) end def call(env) app.call(env) end def app @app = reload_app? ? load_app : @app end def load_app Happy::Controller.build.tap do |klass| Dir[options[:scripts]].each do |file| klass.instance_eval File.read(file) end end end def reload_app? !Happy.env.production? || @app.nil? end end end end
Version data entries
4 entries across 4 versions & 1 rubygems