Sha256: ec7e615c35eba6650e00e8593406bd7d165bb6bf799131ecfc50eb10248b4182

Contents?: true

Size: 633 Bytes

Versions: 10

Compression:

Stored size: 633 Bytes

Contents

module Happy
  module Extras
    class CodeReloader < Happy::Controller
      class << self
        def reload_app_code
          Dir[config[:directory]].each do |f|
            load f
          end
          @app_code_loaded = true
        end

        def reload_app_code?
          Happy.env.development? || !@app_code_loaded
        end
      end

      def route
        raise "no directory specified" unless config[:directory]
        raise "no controller specified" unless config[:controller]

        self.class.reload_app_code if self.class.reload_app_code?
        run eval(config[:controller])
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
happy-0.1.0 lib/happy/extras/code_reloader.rb
happy-0.1.0.pre28 lib/happy/extras/code_reloader.rb
happy-0.1.0.pre27 lib/happy/extras/code_reloader.rb
happy-0.1.0.pre25 lib/happy/extras/code_reloader.rb
happy-0.1.0.pre24 lib/happy/extras/code_reloader.rb
happy-0.1.0.pre23 lib/happy/extras/code_reloader.rb
happy-0.1.0.pre22 lib/happy/extras/code_reloader.rb
happy-0.1.0.pre21 lib/happy/extras/code_reloader.rb
happy-0.1.0.pre20 lib/happy/extras/code_reloader.rb
happy-0.1.0.pre19 lib/happy/extras/code_reloader.rb