Class: Pleiades::Command::Router

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Pleiades::Command::Routing::EventProccessor

#event, #match

Methods included from Pleiades::Command::Routing::NestBlocks

#_method_, #action, #concern, #method, #nest_blocks, #scope

Methods included from Pleiades::Command::Routing::RouteRefine

#only_events, #talk_type

Methods included from Pleiades::Command::Routing::PathBuilder

#normalize_path

Methods included from Pleiades::Command::Routing::Reflection

#__event_name__

Constructor Details

#initialize(options = nil) ⇒ Router

Returns a new instance of Router.



49
50
51
52
# File 'lib/pleiades/core/command/router.rb', line 49

def initialize(options = nil)
  @event = Router.event
  @options = options || default_options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Pleiades::Command::Routing::EventProccessor

Class Attribute Details

.eventObject (readonly)

Returns the value of attribute event.



20
21
22
# File 'lib/pleiades/core/command/router.rb', line 20

def event
  @event
end

.path_infoObject



34
35
36
# File 'lib/pleiades/core/command/router.rb', line 34

def path_info
  @path_info || default_path_info
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



47
48
49
# File 'lib/pleiades/core/command/router.rb', line 47

def options
  @options
end

Class Method Details

.default_path_infoObject



38
39
40
# File 'lib/pleiades/core/command/router.rb', line 38

def default_path_info
  new.instance_eval { Pleiades::Command::Routing::Result.create(@options) }
end

.find_route(event, router_path) ⇒ Object



23
24
25
26
27
28
# File 'lib/pleiades/core/command/router.rb', line 23

def find_route(event, router_path)
  @event = event
  @path_info = nil

  load router_path
end

.path_found?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/pleiades/core/command/router.rb', line 42

def path_found?
  !!@path_info
end

.route(&block) ⇒ Object



30
31
32
# File 'lib/pleiades/core/command/router.rb', line 30

def route(&block)
  new.instance_eval(&block) if block_given?
end