Class: Uchi::Repository::Routes
- Inherits:
-
Object
- Object
- Uchi::Repository::Routes
- Defined in:
- lib/uchi/repository/routes.rb
Instance Attribute Summary collapse
-
#plural ⇒ Object
readonly
Returns the value of attribute plural.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#singular ⇒ Object
readonly
Returns the value of attribute singular.
Instance Method Summary collapse
-
#initialize(repository) ⇒ Routes
constructor
A new instance of Routes.
- #path_for(action, **options) ⇒ Object
- #root_path ⇒ Object
Constructor Details
#initialize(repository) ⇒ Routes
Returns a new instance of Routes.
8 9 10 11 12 |
# File 'lib/uchi/repository/routes.rb', line 8 def initialize(repository) @repository = repository @singular = repository.controller_name.singularize @plural = repository.controller_name.pluralize end |
Instance Attribute Details
#plural ⇒ Object (readonly)
Returns the value of attribute plural.
6 7 8 |
# File 'lib/uchi/repository/routes.rb', line 6 def plural @plural end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
6 7 8 |
# File 'lib/uchi/repository/routes.rb', line 6 def repository @repository end |
#singular ⇒ Object (readonly)
Returns the value of attribute singular.
6 7 8 |
# File 'lib/uchi/repository/routes.rb', line 6 def singular @singular end |
Instance Method Details
#path_for(action, **options) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/uchi/repository/routes.rb', line 14 def path_for(action, **) action = action.to_sym case action when :destroy, :edit, :new, :show, :update singular_path_for(action, **) else plural_path_for(action, **) end end |
#root_path ⇒ Object
24 25 26 |
# File 'lib/uchi/repository/routes.rb', line 24 def root_path "/#{uchi_namespace}/" end |