Sha256: 204816404c053309d55d95e7aa04fbc4a09927904d086c08407d2bb3754044a0
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
# coding: UTF-8 module Raccoon class Router < Spec def initialize &proc instance_eval &proc end [:method, :controller, :action].each do |name| define_method name do |value=nil| instance_variable_set("@#{name}", value) if value instance_variable_get("@#{name}") end end def name value=nil @name unless value @name = value.to_s ::Raccoon.config.application.routes.routes.each do |route| if @name == route.name @controller = route.defaults[:controller] @action = route.defaults[:action] end end end def params value=nil, &block @params ||= Proc.new { {} } @params = Proc.new { value } if value @params = block if block_given? @params end def response_code response_code=nil @response_code = response_code if response_code @response_code ||= 200 end def controller_class return nil unless controller clazz = Object names = controller.split('/') controller = "#{names.pop.capitalize}Controller" names.each do |name| clazz = clazz.const_get(name.capitalize) end clazz.const_get(controller) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
raccoon-0.0.1 | lib/raccoon/spec/router.rb |