Sha256: 83f34b7b79f2b8d02d641bcc741a0ee1fb0d410924da262cd204a201a6174bb6

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'fileutils'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/class/inheritable_attributes'
require 'active_support/concern'

module MediaControl
  class << self
    attr_accessor :root
    # Configuration options
    # * log: Enable message logging using ActiveRecord's logger if available or 'puts' if not. Defaults to true.
    def options
      @options ||= {
        :log => true
      }
    end
    
    def configure
      yield(self) if block_given?
    end
    
    # Log a message if logging is enabled in options
    def log message
      logger "[media_control] #{message}" if logging?
    end
    def logger message #:nodoc:
      puts message
    end
    def logging? #:nodoc:
      options[:log]
    end
  end
  
end

# Use Railties if we're using Rails
if defined?(Rails)
  module MediaControl
    class Railtie < Rails::Railtie
      initializer "media_control.set_paths" do
        MediaControl.root = Rails.root.join(Rails.public_path).to_s
      end
    end
    # Since we're using Rails, use ActiveRecord's logger so it honors log levels, etc
    def logger message #:nodoc:
      ActiveRecord::Base.logger.info message
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
media_control-0.0.3 lib/media_control.rb