Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## NERD_tree_1 [plain_text]
- " Press ? for help
- .. (up a dir)
- /Users/mathias/Documents/Dev/lego-labb2/libs/gems/lego-core/
- |~lib/
- | |~lego/
- | | |~controller/
- | | | |-action_context.rb
- | | | |-plugin_handler.rb
- | | | |-route_matchers.rb
- | | | `-routes.rb
- | | `-controller.rb
- | `-lego-core.rb
- |~spec/
- | |~integration/
- | | `-sample_spec.rb
- | |~lego/
- | | |~controller/
- | | | `-plugin_handler_spec.rb
- | | `-controller_spec.rb
- | |-lego_spec.rb
- | |-spec.opts
- | `-spec_helper.rb
- `-Rakefile
- ## lib/lego/controller.rb [ruby_on_rails]
- class Lego::Controller
- require 'lego/controller/routes'
- require 'lego/controller/action_context'
- require 'lego/controller/plugin_handler'
- class << self
- attr_accessor :routes
- attr_accessor :plugin_handler
- def inherited(subclass)
- subclass.setup_inherited_controller(self)
- end
- def setup_controller
- @routes = Routes.new
- @plugin_handler = PluginHandler.new(self)
- end
- def setup_inherited_controller(parent_controller)
- setup_controller
- @routes.copy_from parent_controller
- self.const_set(:ActionContext, Class.new(parent_controller::ActionContext))
- end
- def use(plugin_mod)
- if plugin_mod.respond_to? :register
- plugin_mod.register(@plugin_handler)
- # elsif plugin_mod.respond_to? :use
- # # Handle Rack plugins
- # else
- # #Handle unkown plugin type
- end
- end
- def action_context
- self::ActionContext
- end
- end
- setup_controller
- def call(env)
- # Handle call....
- end
- end
Add Comment
Please, Sign In to add comment