Sha256: d131bd1fce48d07eb875765876815292b0aaf23379bccf0173b7edb8140d593b

Contents?: true

Size: 401 Bytes

Versions: 7

Compression:

Stored size: 401 Bytes

Contents

module SingletonHelper
  def singleton name, *options
    @@singletons ||= {}
    
    begin 
      @@singletons[name].reload
    
    rescue NoMethodError, ActiveRecord::RecordInvalid, ActiveRecord::RecordNotFound => e
      # puts "singleton error (#{e.class}): " << e.message
      @@singletons[name] ||= create name, *options
    end
  end

  def reset_singletons!
    @@singletons = {}
  end
end

Version data entries

7 entries across 4 versions & 1 rubygems

Version Path
carrier-0.1.5 spec/dummy/features/support/singleton.rb
carrier-0.1.5 spec/support/singleton.rb
carrier-0.1.4 spec/dummy/features/support/singleton.rb
carrier-0.1.4 spec/support/singleton.rb
carrier-0.1.3 spec/dummy/features/support/singleton.rb
carrier-0.1.3 spec/support/singleton.rb
carrier-0.1.2 spec/dummy/features/support/singleton.rb