Sha256: 9ace91adc13534fe409302e052b955774196c75b6593ef2dc067123c4625f202

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

module Faalis
  class Routes

    def self.localized_scop(router: Rails.application.routes)
      langs = ::I18n.available_locales.join('|')
      router.scope '(:locale)', locale: Regexp.new(langs)
    end

    # This class method will add `Faalis` routes to host application
    # Router
    def self.define_api_routes(routes: Rails.application.routes,
                               version: :v1)

      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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
faalis-1.0.0.alpha4 lib/faalis/route.rb
faalis-1.0.0.alpha3 lib/faalis/route.rb
faalis-1.0.0.alpha2 lib/faalis/route.rb