Class: Roadie::ProviderList

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable, AssetProvider
Defined in:
lib/roadie/provider_list.rb

Overview

An asset provider that just composes a list of other asset providers.

Give it a list of providers and they will all be tried in order.

ProviderList behaves like an Array, and an asset provider, and can be coerced into an array.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AssetProvider

#find_stylesheet!

Constructor Details

#initialize(providers) ⇒ ProviderList



34
35
36
# File 'lib/roadie/provider_list.rb', line 34

def initialize(providers)
  @providers = providers
end

Class Method Details

.wrap(provider_list) ⇒ Object .wrap(provider) ⇒ Object .wrap(provider1, provider2, ...) ⇒ Object

Wrap a single provider, or a list of providers into a Roadie::ProviderList.



26
27
28
29
30
31
32
# File 'lib/roadie/provider_list.rb', line 26

def self.wrap(*providers)
  if providers.size == 1 && providers.first.class == self
    providers.first
  else
    new(providers.flatten)
  end
end

Instance Method Details

#<<Object

See Also:

  • Array#<<


69
# File 'lib/roadie/provider_list.rb', line 69

def_delegators :@providers, :each, :size, :empty?, :push, :<<, :pop, :unshift, :shift, :last

#eachObject

See Also:

  • Array#each


69
# File 'lib/roadie/provider_list.rb', line 69

def_delegators :@providers, :each, :size, :empty?, :push, :<<, :pop, :unshift, :shift, :last

#empty?Object

See Also:

  • Array#empty?


69
# File 'lib/roadie/provider_list.rb', line 69

def_delegators :@providers, :each, :size, :empty?, :push, :<<, :pop, :unshift, :shift, :last

#find_stylesheet(name) ⇒ Stylesheet?



39
40
41
42
43
44
45
# File 'lib/roadie/provider_list.rb', line 39

def find_stylesheet(name)
  @providers.each do |provider|
    css = provider.find_stylesheet(name)
    return css if css
  end
  nil
end

#lastObject

See Also:

  • Array#last


69
# File 'lib/roadie/provider_list.rb', line 69

def_delegators :@providers, :each, :size, :empty?, :push, :<<, :pop, :unshift, :shift, :last

#popObject

See Also:

  • Array#pop


69
# File 'lib/roadie/provider_list.rb', line 69

def_delegators :@providers, :each, :size, :empty?, :push, :<<, :pop, :unshift, :shift, :last

#pushObject

See Also:

  • Array#push


69
# File 'lib/roadie/provider_list.rb', line 69

def_delegators :@providers, :each, :size, :empty?, :push, :<<, :pop, :unshift, :shift, :last

#shiftObject

See Also:

  • Array#shift


69
# File 'lib/roadie/provider_list.rb', line 69

def_delegators :@providers, :each, :size, :empty?, :push, :<<, :pop, :unshift, :shift, :last

#sizeObject

See Also:

  • Array#size


69
# File 'lib/roadie/provider_list.rb', line 69

def_delegators :@providers, :each, :size, :empty?, :push, :<<, :pop, :unshift, :shift, :last

#to_aryObject

ProviderList can be coerced to an array. This makes Array#flatten work with it, among other things.



49
# File 'lib/roadie/provider_list.rb', line 49

def to_ary() to_a end

#unshiftObject

See Also:

  • Array#unshift


69
# File 'lib/roadie/provider_list.rb', line 69

def_delegators :@providers, :each, :size, :empty?, :push, :<<, :pop, :unshift, :shift, :last