Class: CouchRest::Mixins::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.
349 350 351 |
# File 'lib/couchrest/mixins/callbacks.rb', line 349 def initialize(symbol) @symbol = symbol end |
Instance Method Details
#clone(klass) ⇒ Object
366 367 368 369 |
# File 'lib/couchrest/mixins/callbacks.rb', line 366 def clone(klass) chain = CallbackChain.new(@symbol) chain.push(*map {|c| c.clone(klass)}) end |
#compile(key = nil, options = {}) ⇒ Object
353 354 355 356 357 358 359 360 361 362 363 364 |
# File 'lib/couchrest/mixins/callbacks.rb', line 353 def compile(key = nil, = {}) method = [] method << "halted = false" each do |callback| method << callback.start(key, ) end method << "yield self if block_given? && !halted" reverse_each do |callback| method << callback.end(key, ) end method.compact.join("\n") end |