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
14 15 16 17 18 19 20 |
# File 'lib/releaf/route_mapper.rb', line 14 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
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/releaf/route_mapper.rb', line 22 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' => 'root#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 |
# 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 end end |