Class MusicExtras::DataAccessor
In: lib/musicextras/dataaccessor.rb
Parent: Object

DataAccessor class provides the interface between data classes and plugins. It allows plugins to register with the class. When someone calls a method of the class that doesn’t exist, the registered plugins are checked for implementations of the method. Whatever (non-nil) data returned from a plugin is used

Methods

Included Modules

Debuggable

Classes and Modules

Class MusicExtras::DataAccessor::AccessorNotImplemented

Public Class methods

Returns a list of available accessors as Symbols

Setups up cache. Data Accessors should be sure to call super

use_cache
set to false if you don’t want to use the cache

This method should be called in the initialize() for each plugin. It should be called one time per accessor method.

plugin
The instance of the plugin (should pass in ‘self’)
accessor
The method that should be called to fetch the data
cache_path
The cache path to load and save data (see Cache)

Public Instance methods

Replaces tags with correct values. Each data accessor should implement this. Eg: Song would replace {TITLE} with the correct title Return the new string

Determines the filename the data should be cached under

name
The accessor name (ie: :lyrics, :image, etc)

Returns nil if no accessors are found

Returns all accessors that are associated with this method

meth
The method we want accessors for

Data is retrieved using the accessor information. First the cache is checked. If that fails, the accessor fetch methods are called. If data is retrieved, it is saved in the cache and returned. Otherwise nil is returned

Whenever a method doesn’t exist, we check if there are any registered accessors to handle it. Raises AccessorNotImplemented when none of the registred plugins implement the method

[Validate]