Class: Doorkeeper::Rails::Routes

Inherits:
Object
  • Object
show all
Defined in:
lib/doorkeeper/rails/routes.rb,
lib/doorkeeper/rails/routes/mapper.rb,
lib/doorkeeper/rails/routes/mapping.rb

Defined Under Namespace

Modules: Helper Classes: Mapper, Mapping

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(routes, &options) ⇒ Routes

Returns a new instance of Routes.



31
32
33
# File 'lib/doorkeeper/rails/routes.rb', line 31

def initialize(routes, &options)
  @routes, @options = routes, options
end

Instance Attribute Details

#routesObject

Returns the value of attribute routes.



29
30
31
# File 'lib/doorkeeper/rails/routes.rb', line 29

def routes
  @routes
end

Class Method Details

.install!Object



14
15
16
# File 'lib/doorkeeper/rails/routes.rb', line 14

def self.install!
  ActionDispatch::Routing::Mapper.send :include, Doorkeeper::Rails::Routes::Helper
end

.warn_if_using_mount_method!Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/doorkeeper/rails/routes.rb', line 18

def self.warn_if_using_mount_method!
  paths = ::Rails.application.config.paths["config/routes"] ||
    ::Rails.application.config.paths["config/routes.rb"]

  paths.each do |path|
    if File.read(::Rails.root.join(path)) =~ %r[mount Doorkeeper::Engine]
      warn "\n[DOORKEEPER] `mount Doorkeeper::Engine` is not being used anymore. Please replace it with `use_doorkeeper` in your #{path} file\n"
    end
  end
end

Instance Method Details

#generate_routes!(options) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/doorkeeper/rails/routes.rb', line 35

def generate_routes!(options)
  @mapping = Mapper.new.map(&@options)
  routes.scope 'oauth', :as => 'oauth' do
    map_route(:authorizations, :authorization_routes)
    map_route(:tokens, :token_routes)
    map_route(:applications, :application_routes)
    map_route(:authorized_applications, :authorized_applications_routes)
    map_route(:token_info, :token_info_routes)
  end
end