Class: Shaf::CreateUriMethods
- Inherits:
-
Object
- Object
- Shaf::CreateUriMethods
- Defined in:
- lib/shaf/extensions/resource_uris.rb
Overview
This class register uri helper methods like: books_uri => /books book_uri(book) => /books/5 new_book_uri => /books/form edit_book_uri(book) => /books/5/edit
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(name, base: nil, plural_name: nil) ⇒ CreateUriMethods
constructor
A new instance of CreateUriMethods.
Constructor Details
#initialize(name, base: nil, plural_name: nil) ⇒ CreateUriMethods
Returns a new instance of CreateUriMethods.
43 44 45 46 47 |
# File 'lib/shaf/extensions/resource_uris.rb', line 43 def initialize(name, base: nil, plural_name: nil) @name = name.to_s @base = base&.sub(%r(/\Z), '') || '' @plural_name = plural_name&.to_s || name.to_s + 's' end |
Instance Method Details
#call ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/shaf/extensions/resource_uris.rb', line 49 def call if plural_name == name register_resource_uri_by_arg else register_resources_uri register_resource_uri end register_new_resource_uri register_edit_resource_uri end |