Sha256: 2bfd233a7a8e69d0942b7bbaa20400dd0dbffa34406f985dcb6ca32539113b81
Contents?: true
Size: 1.22 KB
Versions: 8
Compression:
Stored size: 1.22 KB
Contents
class Jets::Router::MethodCreator class Index < Code def meth_name # Well this is pretty confusing and tough to follow. TODO: figure out how to improve this. # # Example 1: # # resources :users, only: [] do # resources :posts, only: :index # end # # Results in: # # full_as: user_posts # method_name_leaf: nil # # Example 2: # # resources :users, only: [] do # get "posts", to: "posts#index" # end # # Results in: # # full_as: users # method_name_leaf: posts # # This is because using resources contains all the info we need in parent scopes. # The scope.full_as already has the desired meth_name. # # However, when using the simple create_route methods like get, the parent scope does not contain # all the info we need. In this tricky case, the method_name_leaf is set. # We then have to reconstruct the meth_name. # if method_name_leaf join(singularize(full_as), method_name_leaf) # reconstruct else join(full_as) # construct entirely from scope info end end end end
Version data entries
8 entries across 8 versions & 1 rubygems