Sha256: a2e74bb8444b3641904f32fabd09a5e1a0d0f68d9b3777906355f0218d875053
Contents?: true
Size: 885 Bytes
Versions: 13
Compression:
Stored size: 885 Bytes
Contents
# -*- Coding: utf-8 -*- require "cuba" require 'ixtlan/babel/factory' module CubaApi module WriteAspects module ClassMethods def append_aspect( arg ) aspects << arg warn "[CubaAPI] Appended aspect #{arg}" end def prepend_aspect( arg ) aspects.insert( 0, arg ) warn "[CubaAPI] Prepended aspect #{arg}" end def aspects self[ :aspects ] ||= [] end end def head( status ) res.status = status res.write '' end def write( obj, args = {} ) self.res.status = args[:status] || 200 # make sure we inherit aspects and repsect the order aspects = self.class == CubaAPI ? [] : self.class.superclass[ :aspects ] (aspects + self.class[ :aspects ]).uniq.each do |w| obj = send( w, obj, args ) if obj end res.write obj.to_s end end end
Version data entries
13 entries across 13 versions & 1 rubygems