Module: Siresta::API::ClassMethods

Defined in:
lib/siresta/api.rb

Instance Method Summary collapse

Instance Method Details

#_gen_route(meth, path, formats, pipe, handler) ⇒ Object

generate route



97
98
99
100
101
# File 'lib/siresta/api.rb', line 97

def _gen_route(meth, path, formats, pipe, handler)
  send(meth, path) do
    _handle_request meth, path, formats, pipe, handler
  end
end

#data(k, v) ⇒ Object

declare data (atom)



109
110
111
# File 'lib/siresta/api.rb', line 109

def data(k, v)
  settings.siresta[:data][k] = Obfusk.atom v
end

#handle(name, &b) ⇒ Object

named handler



104
105
106
# File 'lib/siresta/api.rb', line 104

def handle(name, &b)
  define_method name, &b
end

#to_authorize(handler, &b) ⇒ Object

handle authorization



114
115
116
# File 'lib/siresta/api.rb', line 114

def to_authorize(handler, &b)
  settings.siresta[:authorize][handler] = b
end

#to_convert_from(format, handler = :__all__, &b) ⇒ Object

convert body from format



119
120
121
# File 'lib/siresta/api.rb', line 119

def to_convert_from(format, handler = :__all__, &b)
  (settings.siresta[:convert_from][format] ||= {})[handler] = b
end

#to_convert_params(handler, &b) ⇒ Object

convert params



124
125
126
# File 'lib/siresta/api.rb', line 124

def to_convert_params(handler, &b)
  settings.siresta[:convert_params][handler] = b
end

#to_convert_to(format, handler = :__all__, &b) ⇒ Object

convert body to format



129
130
131
# File 'lib/siresta/api.rb', line 129

def to_convert_to(format, handler = :__all__, &b)
  (settings.siresta[:convert_to][format] ||= {})[handler] = b
end

#to_validate_body(handler, &b) ⇒ Object

validate body



134
135
136
# File 'lib/siresta/api.rb', line 134

def to_validate_body(handler, &b)
  settings.siresta[:validate_body][handler] = b
end

#to_validate_params(handler, &b) ⇒ Object

validate params



139
140
141
# File 'lib/siresta/api.rb', line 139

def to_validate_params(handler, &b)
  settings.siresta[:validate_params][handler] = b
end