Sha256: ff29eebbb3736aea364989463191fae7c8ecede6622aba745ae7c3d297e1ec54

Contents?: true

Size: 945 Bytes

Versions: 9

Compression:

Stored size: 945 Bytes

Contents

class DripDrop::Node
  # See the documentation for +nodelet+ in DripDrop::Node
  class Nodelet
    attr_accessor :name, :routing
    
    def initialize(ctx, name, *configure_args) 
      @ctx              = ctx
      @name             = name
      @internal_routing = {}
      configure(*configure_args)
    end
    
    def configure(*args)
      # Do nothing!
    end
    
    def route(name,handler_type,*handler_args)
      handler = @ctx.route_full(self, name, handler_type, *handler_args)
      @internal_routing[name] = handler
       
      (class << self; self; end).class_eval do
        define_method(name) { handler }
      end
    end

    # Check for the method as a route in @ctx, if found
    # memoize it by defining it as a singleton
    def method_missing(meth,*args)
      (class << self; self; end).class_eval do
        define_method(meth) { @ctx.send(meth,*args) }
      end
      self.send(meth,*args)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dripdrop-0.11.0-java lib/dripdrop/node/nodelet.rb
dripdrop-0.11.0 lib/dripdrop/node/nodelet.rb
dripdrop-0.10.0 lib/dripdrop/node/nodelet.rb
dripdrop-0.10.0-java lib/dripdrop/node/nodelet.rb
dripdrop-0.10.0.beta2 lib/dripdrop/node/nodelet.rb
dripdrop-0.10.0.beta1 lib/dripdrop/node/nodelet.rb
dripdrop-0.9.10 lib/dripdrop/node/nodelet.rb
dripdrop-0.9.9 lib/dripdrop/node/nodelet.rb
dripdrop-0.9.8 lib/dripdrop/node/nodelet.rb