Class: Genesis::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/genesis/handler.rb

Overview

Interface for a GenesisHandler Allows subclasess specifying routes and subscribers in a DSL

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.routesObject

Returns the value of attribute routes.



6
7
8
# File 'lib/genesis/handler.rb', line 6

def routes
  @routes
end

.subscribersObject

Returns the value of attribute subscribers.



6
7
8
# File 'lib/genesis/handler.rb', line 6

def subscribers
  @subscribers
end

Class Method Details

.inherited(subclass) ⇒ Object



20
21
22
23
# File 'lib/genesis/handler.rb', line 20

def inherited(subclass)
  subclass.reset!
  super
end

.register_route(match, opts = {}, &block) ⇒ Object



7
8
9
# File 'lib/genesis/handler.rb', line 7

def register_route(match, opts = {}, &block)
  @routes[match] = { verb: __callee__.to_s, opts: opts, block: block }
end

.register_subscriber(*_args, &block) ⇒ Object Also known as: subscribe



11
12
13
# File 'lib/genesis/handler.rb', line 11

def register_subscriber(*_args, &block)
  @subscribers << { block: block }
end

.reset!Object



15
16
17
18
# File 'lib/genesis/handler.rb', line 15

def reset!
  @subscribers = []
  @routes = {}
end