Module: MediaControl

Defined in:
lib/media_control.rb,
lib/media_control.rb

Defined Under Namespace

Classes: Railtie

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.rootObject

Returns the value of attribute root.



8
9
10
# File 'lib/media_control.rb', line 8

def root
  @root
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (MediaControl)

    the object that the method was called on



17
18
19
# File 'lib/media_control.rb', line 17

def configure
  yield(self) if block_given?
end

.log(message) ⇒ Object

Log a message if logging is enabled in options



22
23
24
# File 'lib/media_control.rb', line 22

def log message
  logger "[media_control] #{message}" if logging?
end

.logger(message) ⇒ Object

:nodoc:



25
26
27
# File 'lib/media_control.rb', line 25

def logger message #:nodoc:
  puts message
end

.logging?Boolean

:nodoc:

Returns:

  • (Boolean)


28
29
30
# File 'lib/media_control.rb', line 28

def logging? #:nodoc:
  options[:log]
end

.optionsObject

Configuration options

  • log: Enable message logging using ActiveRecord’s logger if available or ‘puts’ if not. Defaults to true.



11
12
13
14
15
# File 'lib/media_control.rb', line 11

def options
  @options ||= {
    :log => true
  }
end

Instance Method Details

#logger(message) ⇒ Object

Since we’re using Rails, use ActiveRecord’s logger so it honors log levels, etc



44
45
46
# File 'lib/media_control.rb', line 44

def logger message #:nodoc:
  ActiveRecord::Base.logger.info message
end