Method: Waxx::View#run
- Defined in:
- lib/waxx/view.rb
#run(x, id: nil, data: nil, where: nil, having: nil, order: nil, limit: nil, offset: nil, message: {}, as: x.ext, meth: x.meth, args: {}) ⇒ Object Also known as: view
Gets the data for the view and displays it. This is just a shortcut method.
This is normally called from the handler method defined in Object
“‘ App::Usr::List.run(x) # Given a get request with the json extention, the above is a shortcut to: data = App::Usr::List.get(x) App::Usr::List::Json.get(x, data) “`
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/waxx/view.rb', line 290 def run(x, id:nil, data:nil, where:nil, having:nil, order:nil, limit:nil, offset:nil, message:{}, as:x.ext, meth:x.meth, args:{}) case meth.to_sym when :get, :head if data.nil? or data.empty? if id data = get_by_id(x, id) else data = get(x, where:where, having:having, order:(order||x['order']), limit:(limit||x['limit']), offset:(offset||x['offset']), args:args) end end when :put, :post, :patch data = put_post(x, id, data, args:args) when :delete delete(x, id, args:args) else raise "Unknown request method in Waxx::View.run(#{name})" end layout = const_get(as.to_s.capitalize) rescue nil return App.not_found(x, message:"No layout defined for #{as}") if not layout if layout.respond_to? meth render(x, data, message: , as: as, meth: meth) else render(x, data, message: , as: as, meth: "get") end end |