Sha256: 51e66c7e838e83fb3b35d13a942b7f6608e901adfe03fe1d9927db678446c0b0

Contents?: true

Size: 633 Bytes

Versions: 2

Compression:

Stored size: 633 Bytes

Contents

require 'rails'
module LoopDance

  class Railtie < Rails::Railtie

    def self.load_dancers
      require 'dancers'
    rescue LoadError => err
      puts "LoopDance: file 'lib/dancers.rb' doesn't exist."
    end

    initializer 'loop_dance.initialize' do
      self.class.load_dancers
      # Do not start dancers if rake or other tasks
      LoopDance.start_all if server_startup?
    end


    # FIX: Is there more cute solution?
    def server_startup?
      caller.to_s=~/config\.ru/
    end

    rake_tasks do
      load_dancers
      load File.expand_path('../../../tasks/loop_dance.rake', __FILE__)
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
loop_dance-0.3.1 lib/loop_dance/railtie.rb
loop_dance-0.2.5 lib/loop_dance/railtie.rb