Sha256: 9c0ab6005e12d4966156be134ff3baf17bdcab4b7a74c242347f3d2a3fab509d

Contents?: true

Size: 383 Bytes

Versions: 3

Compression:

Stored size: 383 Bytes

Contents

require 'logger'

module Dragonfly
  module BelongsToApp
    
    # Exceptions
    class NotConfigured < RuntimeError; end
    
    attr_writer :app
    
    def app
      @app || raise(NotConfigured, "#{self.inspect} has no app set")
    end
    
    def app_set?
      !!@app
    end
    
    def log
      app_set? ? app.log : (@log ||= Logger.new(STDOUT))
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dragonfly-0.6.2 lib/dragonfly/belongs_to_app.rb
dragonfly-0.6.1 lib/dragonfly/belongs_to_app.rb
dragonfly-0.6.0 lib/dragonfly/belongs_to_app.rb