Module: Pepper::Context::Delegate::ClassMethods

Includes:
InstanceMethods
Defined in:
lib/pepper.rb

Overview

Pepper::Context::Delegate::ClassMethods

Constant Summary

Constants included from InstanceMethods

InstanceMethods::HTTP_METHODS, InstanceMethods::PATTERNS

Instance Attribute Summary

Attributes included from InstanceMethods

#app, #block, #delegate, #options, #parent, #pattern

Instance Method Summary collapse

Methods included from InstanceMethods

#actions, #after, #after_blocks, #before, #before_blocks, #child_exists?, #children, #delegate_to, #find_action, #map, #match?, #method_missing, #params, #request, #resolve, #simple_match?, #value

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Pepper::Context::InstanceMethods

Instance Method Details

#build(options = {}, &block) ⇒ Object

define the standard build method so the delegate can start creating the context tree



264
265
266
267
# File 'lib/pepper.rb', line 264

def build(options={}, &block)
  @options=options
  @block=block
end

#delegate!(delegating_for, slices) ⇒ Object

Sets up this module as a delegate handler delegating_for - Pepper::Context::Base instance slices - array of path fragments



274
275
276
277
278
279
280
281
282
283
# File 'lib/pepper.rb', line 274

def delegate!(delegating_for, slices)
  @app=delegating_for.app
  @parent=delegating_for.parent
  # Set the @pattern to the delegating_for's value so that when resolve is called, there will be a match
  @pattern=delegating_for.value
  # add this delegate to the delegating_for.parent.children
  delegating_for.parent.children.unshift self
  # find the matching context based on the slices
  return resolve(slices)
end