class Webservice::Base
Public Instance Methods
before()
click to toggle source
note: before (filter) for now is just a method (NOT a chain for blocks, etc.);
override method to change before (filter)
# File lib/webservice/base/base.rb, line 11 def before ### move cors headers to responseHandler to initialize!!!! - why? why not?? ## (auto-)add (merge in) cors headers ## todo: move into a before filter ?? lets you overwrite headers - needed - why? why not?? headers 'Access-Control-Allow-Origin' => '*', 'Access-Control-Allow-Headers' => 'Authorization,Accepts,Content-Type,X-CSRF-Token,X-Requested-With', 'Access-Control-Allow-Methods' => 'GET,POST,PUT,DELETE,OPTIONS' end
dump_routes()
click to toggle source
fallback helpers
# File lib/webservice/base/base.rb, line 81 def dump_routes ## todo/check - rename to build_routes/show_routes/etc. - why? why not? buf = "" walk_routes_for( buf, self.class ) buf end
dump_version()
click to toggle source
# File lib/webservice/base/base.rb, line 105 def dump_version ## single line version string buf = " " # note: start with two leading spaces (indent) buf << "webservice/#{VERSION} " buf << "(#{self.class.environment}), " buf << "rack/#{Rack::RELEASE} (#{Rack::VERSION.join('.')}) - " buf << "ruby/#{RUBY_VERSION} (#{RUBY_RELEASE_DATE}/#{RUBY_PLATFORM})" buf end
handle_response( obj, opts={} )
click to toggle source
note: for now use “plugable” response handler
rename to respond_with or something? why? why not?? make it a "stateless" function e.g. just retrun tripled [status, headers, body] - why? why not??
# File lib/webservice/base/base.rb, line 24 def handle_response( obj, opts={} ) handler = ResponseHandler.new( self ) ## for now "hard-coded"; make it a setting later - why? why not? handler.handle_response( obj ) ## prepare response end
walk_routes_for( buf, base=self.class )
click to toggle source
# File lib/webservice/base/base.rb, line 87 def walk_routes_for( buf, base=self.class ) buf << " Routes >#{base.name}<:\n\n" base.routes.each do |method,routes| buf << " #{method}:\n" routes.each do |pattern,block| buf << " #{pattern.to_s}\n" end end if base.superclass.respond_to? :routes buf << "\n\n" walk_routes_for( buf, base.superclass ) end end