Guest User

Untitled

a guest
Jul 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. ## NERD_tree_1 [plain_text]
  2. " Press ? for help
  3.  
  4. .. (up a dir)
  5. /Users/mathias/Documents/Dev/lego-labb2/libs/gems/lego-core/
  6. |~lib/
  7. | |~lego/
  8. | | |~controller/
  9. | | | |-action_context.rb
  10. | | | |-plugin_handler.rb
  11. | | | |-route_matchers.rb
  12. | | | `-routes.rb
  13. | | `-controller.rb
  14. | `-lego-core.rb
  15. |~spec/
  16. | |~integration/
  17. | | `-sample_spec.rb
  18. | |~lego/
  19. | | |~controller/
  20. | | | `-plugin_handler_spec.rb
  21. | | `-controller_spec.rb
  22. | |-lego_spec.rb
  23. | |-spec.opts
  24. | `-spec_helper.rb
  25. `-Rakefile
  26.  
  27. ## lib/lego/controller.rb [ruby_on_rails]
  28. class Lego::Controller
  29.  
  30. require 'lego/controller/routes'
  31. require 'lego/controller/action_context'
  32. require 'lego/controller/plugin_handler'
  33.  
  34. class << self
  35. attr_accessor :routes
  36. attr_accessor :plugin_handler
  37.  
  38. def inherited(subclass)
  39. subclass.setup_inherited_controller(self)
  40. end
  41.  
  42. def setup_controller
  43. @routes = Routes.new
  44. @plugin_handler = PluginHandler.new(self)
  45. end
  46.  
  47. def setup_inherited_controller(parent_controller)
  48. setup_controller
  49. @routes.copy_from parent_controller
  50. self.const_set(:ActionContext, Class.new(parent_controller::ActionContext))
  51. end
  52.  
  53. def use(plugin_mod)
  54. if plugin_mod.respond_to? :register
  55. plugin_mod.register(@plugin_handler)
  56. # elsif plugin_mod.respond_to? :use
  57. # # Handle Rack plugins
  58. # else
  59. # #Handle unkown plugin type
  60. end
  61. end
  62.  
  63. def action_context
  64. self::ActionContext
  65. end
  66. end
  67.  
  68. setup_controller
  69.  
  70. def call(env)
  71. # Handle call....
  72. end
  73.  
  74. end
Add Comment
Please, Sign In to add comment