Class: Shaf::CreateUriMethods

Inherits:
Object
  • Object
show all
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 => /book/form edit_book_uri(book) => /books/5/edit

And uri template methods: books_uri_template => /books book_uri_template => /books/:id new_book_uri_template => /book/form edit_book_uri_template => /books/:id/edit

Instance Method Summary collapse

Constructor Details

#initialize(name, plural_name: nil, base: nil, namespace: nil, only: nil, except: nil) ⇒ CreateUriMethods

Returns a new instance of CreateUriMethods.



109
110
111
112
113
114
115
116
117
118
# File 'lib/shaf/extensions/resource_uris.rb', line 109

def initialize(name, plural_name: nil, base: nil, namespace: nil, only: nil, except: nil)
  @name = name.to_s
  @plural_name = plural_name&.to_s || Utils::pluralize(name.to_s)
  @base = base&.sub(%r(/\Z), '') || ''
  @base = "/#{namespace}" if namespace && !base
  @namespace = namespace
  @only = only
  @except = except
  @added_path_methods = []
end

Instance Method Details

#callObject



120
121
122
123
124
125
126
# File 'lib/shaf/extensions/resource_uris.rb', line 120

def call
  register_collection_helper
  register_resource_helper
  register_new_resource_helper
  register_edit_resource_helper
  @added_path_methods
end