lib/lotus/routing/resource/action.rb in lotus-router-0.2.1 vs lib/lotus/routing/resource/action.rb in lotus-router-0.3.0
- old
+ new
@@ -204,11 +204,11 @@
# 'flowers#index'
#
# @api private
# @since 0.1.0
def endpoint
- [ resource_name, action_name ].join separator
+ [ controller_name, action_name ].join separator
end
# Separator between controller and action name
#
# @see Lotus::Routing::EndpointResolver#separator
@@ -219,10 +219,26 @@
# @api private
# @since 0.1.0
def separator
@options[:separator]
end
+
+ # Resource controller name
+ #
+ # @example
+ # Lotus::Router.new do
+ # resources 'flowers', controller: 'rocks'
+ # end
+ #
+ # # It will mount path 'flowers/new' to Rocks::New instead of Flowers::New
+ # # Same for other action names
+ #
+ # @api private
+ # @since x.x.x
+ def controller_name
+ @options[:controller] || resource_name
+ end
end
# Collection action
# It implements #collection within a #resource block.
#
@@ -247,10 +263,10 @@
def path(action_name)
rest_path.join(action_name)
end
def endpoint(action_name)
- [ resource_name, action_name ].join separator
+ [ controller_name, action_name ].join separator
end
def as(action_name)
[ action_name, super() ].join(self.class.named_route_separator).to_sym
end