Class: Faalis::RouteHelpers::Routes

Inherits:
Object
  • Object
show all
Defined in:
lib/faalis/route.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) define_api_routes(routes: Rails.application.routes, version: :v1)

This class method will add Faalis routes to host application Router



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/faalis/route.rb', line 62

def self.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

+ (Object) localized_scop(router: Rails.application.routes)



54
55
56
57
58
# File 'lib/faalis/route.rb', line 54

def self.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