Class: AdminAssistant::Route
- Inherits:
-
Object
- Object
- AdminAssistant::Route
- Defined in:
- lib/admin_assistant/route.rb
Instance Attribute Summary collapse
-
#admin_assistant ⇒ Object
readonly
Returns the value of attribute admin_assistant.
Instance Method Summary collapse
- #add(binding) ⇒ Object
- #autocomplete_actions ⇒ Object
- #controller ⇒ Object
-
#initialize(admin_assistant) ⇒ Route
constructor
A new instance of Route.
- #namespace ⇒ Object
- #resource ⇒ Object
Constructor Details
#initialize(admin_assistant) ⇒ Route
Returns a new instance of Route.
5 6 7 |
# File 'lib/admin_assistant/route.rb', line 5 def initialize(admin_assistant) @admin_assistant = admin_assistant end |
Instance Attribute Details
#admin_assistant ⇒ Object (readonly)
Returns the value of attribute admin_assistant.
3 4 5 |
# File 'lib/admin_assistant/route.rb', line 3 def admin_assistant @admin_assistant end |
Instance Method Details
#add(binding) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/admin_assistant/route.rb', line 9 def add(binding) route_str = "resources(:#{resource})" unless autocomplete_actions.empty? route_str << " do " autocomplete_actions.each do |action| route_str << " get :#{action}, :on => :collection;" end route_str << " end " end if namespace route_str = "namespace(:#{namespace}) do " + route_str + " end" end eval(route_str, binding) end |
#autocomplete_actions ⇒ Object
24 25 26 |
# File 'lib/admin_assistant/route.rb', line 24 def autocomplete_actions admin_assistant.autocomplete_actions end |
#controller ⇒ Object
28 29 30 |
# File 'lib/admin_assistant/route.rb', line 28 def controller admin_assistant.controller_class end |
#namespace ⇒ Object
32 33 34 35 36 37 |
# File 'lib/admin_assistant/route.rb', line 32 def namespace name = controller.name.gsub(/Controller$/, '').underscore if name =~ %r|(.*)/(.*)| $1.to_sym end end |
#resource ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/admin_assistant/route.rb', line 39 def resource name = controller.name.gsub(/Controller$/, '').underscore if name =~ %r|(.*)/(.*)| $2.to_sym else name.to_sym end end |