Class: CouchRest::Callbacks::CallbackChain
- Defined in:
- lib/couchrest/mixins/callbacks.rb
Overview
An Array with a compile method
Instance Method Summary collapse
- #clone(klass) ⇒ Object
- #compile(key = nil, options = {}) ⇒ Object
-
#initialize(symbol) ⇒ CallbackChain
constructor
A new instance of CallbackChain.
Constructor Details
#initialize(symbol) ⇒ CallbackChain
Returns a new instance of CallbackChain.
321 322 323 |
# File 'lib/couchrest/mixins/callbacks.rb', line 321 def initialize(symbol) @symbol = symbol end |
Instance Method Details
#clone(klass) ⇒ Object
338 339 340 341 |
# File 'lib/couchrest/mixins/callbacks.rb', line 338 def clone(klass) chain = CallbackChain.new(@symbol) chain.push(*map {|c| c.clone(klass)}) end |
#compile(key = nil, options = {}) ⇒ Object
325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/couchrest/mixins/callbacks.rb', line 325 def compile(key = nil, = {}) method = [] method << "halted = false" each do |callback| method << callback.start(key, ) end method << "yield self if block_given?" reverse_each do |callback| method << callback.end(key, ) end method.compact.join("\n") end |