Class: Aleph::Base

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

Direct Known Subclasses

Armstrong

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.connObject

Returns the value of attribute conn.



15
16
17
# File 'lib/armstrong.rb', line 15

def conn
  @conn
end

.routesObject

Returns the value of attribute routes.



15
16
17
# File 'lib/armstrong.rb', line 15

def routes
  @routes
end

Class Method Details

.delete(path, &block) ⇒ Object



35
# File 'lib/armstrong.rb', line 35

def delete(path, &block) route "DELETE", path, &block end

.get(path, &block) ⇒ Object



31
# File 'lib/armstrong.rb', line 31

def get(path, &block) route "GET", path, &block end

.head(path, &block) ⇒ Object



34
# File 'lib/armstrong.rb', line 34

def head(path, &block) route "HEAD", path, &block end

.new_uuidObject

uuid generator. There’s a pretty low chance of collision.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/armstrong.rb', line 18

def new_uuid
  values = [
    rand(0x0010000),
    rand(0x0010000),
    rand(0x0010000),
    rand(0x0010000),
    rand(0x0010000),  
    rand(0x1000000),
    rand(0x1000000),
  ]
  "%04x%04x-%04x-%04x-%04x%06x%06x" % values
end

.patch(path, &block) ⇒ Object



36
# File 'lib/armstrong.rb', line 36

def patch(path, &block) route "PATCH", path, &block end

.post(path, &block) ⇒ Object



33
# File 'lib/armstrong.rb', line 33

def post(path, &block) route "POST", path, &block end

.put(path, &block) ⇒ Object



32
# File 'lib/armstrong.rb', line 32

def put(path, &block)  route "PUT",  path, &block end

.route(verb, path, &block) ⇒ Object



38
39
40
41
# File 'lib/armstrong.rb', line 38

def route(verb, path, &block)
  @routes ||= {}
  (@routes[verb] ||= []) << AddRoute.new(compile(path), block)
end