Class: Faalis::Routes
- Inherits:
-
Object
- Object
- Faalis::Routes
- Defined in:
- lib/faalis/routes.rb
Class Attribute Summary collapse
-
.engine ⇒ Object
Returns the value of attribute engine.
Class Method Summary collapse
-
.define_api_routes(routes: Rails.application.routes, version: :v1) ⇒ Object
This class method will add ‘Faalis` routes to host application Router.
- .draw(engine, &block) ⇒ Object
- .faalis(&block) ⇒ Object
- .localized_scop(router: Rails.application.routes) ⇒ Object
- .plugin(&block) ⇒ Object
Class Attribute Details
.engine ⇒ Object
Returns the value of attribute engine.
58 59 60 |
# File 'lib/faalis/routes.rb', line 58 def engine @engine end |
Class Method Details
.define_api_routes(routes: Rails.application.routes, version: :v1) ⇒ Object
This class method will add ‘Faalis` routes to host application Router
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/faalis/routes.rb', line 84 def define_api_routes(routes: Rails.application.routes, version: :v1) puts '[Warning]: This method is depricated. Please use "api_routes" directly in your router.' routes.draw do # TODO: Add a dynamic solution for formats namespace :api, defaults: { format: :json } do namespace version do # Call user given block to define user routes # inside this namespace yield self if block_given? end end scope 'module'.to_sym => 'faalis' do # TODO: Add a dynamic solution for formats namespace :api, defaults: { format: :json } do namespace version do get 'permissions', to: 'permissions#index' get 'permissions/user', to: 'permissions#user_permissions' resources :groups, except: [:new] resources :users, except: [:new] resource :profile, except: [:new, :destroy] get 'logs', to: 'logs#index' end end end end end |
.draw(engine, &block) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/faalis/routes.rb', line 68 def draw(engine, &block) self.engine = engine raise ArgumentError.new 'block is needed' unless block_given? self.class_eval(&block) end |
.faalis(&block) ⇒ Object
60 61 62 |
# File 'lib/faalis/routes.rb', line 60 def faalis(&block) Faalis::Engine.routes.draw(&block) end |
.localized_scop(router: Rails.application.routes) ⇒ Object
76 77 78 79 80 |
# File 'lib/faalis/routes.rb', line 76 def localized_scop(router: Rails.application.routes) puts '[Warning]: This method is depricated please just use "localized_scope" in your router.' langs = ::I18n.available_locales.join('|') router.scope '(:locale)', locale: Regexp.new(langs) end |
.plugin(&block) ⇒ Object
64 65 66 |
# File 'lib/faalis/routes.rb', line 64 def plugin(&block) self.engine.routes.draw(&block) end |