Module: Releaf::RouteMapper
- Defined in:
- lib/releaf/route_mapper.rb
Instance Method Summary collapse
- #initialize_releaf_components ⇒ Object
- #mount_releaf_at(mount_location) ⇒ Object
-
#releaf_resources(*args) ⇒ Object
Pass given resource to “resources” mount method and add extra routes for members and collections needed by releaf.
Instance Method Details
#initialize_releaf_components ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/releaf/route_mapper.rb', line 17 def initialize_releaf_components Releaf.application.config.components.each do|component_class| if component_class.respond_to? :draw_component_routes component_class.draw_component_routes(self) end end end |
#mount_releaf_at(mount_location) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/releaf/route_mapper.rb', line 25 def mount_releaf_at(mount_location) mount_location_namespace = mount_location.delete("/").to_sym Releaf.application.config.mount_location = mount_location_namespace.to_s scope mount_location do initialize_releaf_components if mount_location_namespace.empty? yield if block_given? else namespace mount_location_namespace, path: nil do yield if block_given? end end namespace :releaf, path: nil do get '/*path' => 'errors#page_not_found' end end end |
#releaf_resources(*args) ⇒ Object
Pass given resource to “resources” mount method and add extra routes for members and collections needed by releaf
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/releaf/route_mapper.rb', line 4 def releaf_resources(*args) resources(*args) do yield if block_given? member do get :confirm_destroy if route_enabled?(:destroy, args.last) get :toolbox if route_enabled?(:toolbox, args.last) end collection do post :create_releaf_richtext_attachment if route_enabled?(:releaf_richtext_attachments, args.last) end end end |