Class: Metalive::Chain

Inherits:
Object
  • Object
show all
Defined in:
lib/metalive/chain.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChain

Returns a new instance of Chain.



5
6
7
# File 'lib/metalive/chain.rb', line 5

def initialize
  @updaters = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *arguments, &block) ⇒ Object



20
21
22
# File 'lib/metalive/chain.rb', line 20

def method_missing(name, *arguments, &block)
  add name, arguments.first
end

Instance Attribute Details

#updatersObject (readonly)

Returns the value of attribute updaters.



3
4
5
# File 'lib/metalive/chain.rb', line 3

def updaters
  @updaters
end

Instance Method Details

#add(updater, options = {}) ⇒ Object



9
10
11
12
13
# File 'lib/metalive/chain.rb', line 9

def add(updater, options = {})
  updater = create(updater, options) unless updater.respond_to?(:update)
  updaters << updater
  self
end

#create(updater, options = {}) ⇒ Object



15
16
17
18
# File 'lib/metalive/chain.rb', line 15

def create(updater, options = {})
  updater = Metalive.const_get(updater.to_s.capitalize) if String === updater or Symbol === updater
  updater.new options
end

#update(metadata) ⇒ Object



24
25
26
27
28
# File 'lib/metalive/chain.rb', line 24

def update()
  not updaters.collect do |updater|
    updater.update()
  end.include?(false)
end