Class: Magnetite::Routing::Base

Inherits:
BasicObject
Defined in:
lib/magnetite/routing/base.rb

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



8
9
10
11
# File 'lib/magnetite/routing/base.rb', line 8

def initialize
  @pipelines = {}
  @scopes    = {}
end

Instance Method Details

#get_pipeline(name) ⇒ Object



37
38
39
# File 'lib/magnetite/routing/base.rb', line 37

def get_pipeline(name)
  @pipelines[name.to_sym]
end

#pipeline(name, &block) ⇒ Object

Parameters:

  • name (Symbol)

    A name representing the pipeline this name will be used to get the pipeline in the scopes.



16
17
18
19
20
21
22
# File 'lib/magnetite/routing/base.rb', line 16

def pipeline(name, &block)
  ::Kernel.raise NameRequired if name.nil?

  @pipelines[name] = Pipeline.new(name)
  @pipelines[name].instance_eval(&block) if ::Kernel.block_given?
  @pipelines[name]
end

#resolve(path) ⇒ Object



33
34
35
# File 'lib/magnetite/routing/base.rb', line 33

def resolve(path)

end

#scope(path, &block) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/magnetite/routing/base.rb', line 24

def scope(path, &block)
  ::Kernel.raise PathRequired if path.nil?
  ::Kernel.raise BlockRequired unless ::Kernel.block_given?

  @scopes[path] = Scope.new(path, self)
  @scopes[path].instance_eval(&block)
  @scopes[path]
end