Class: JkoApi::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/jko_api/util.rb

Class Method Summary collapse

Class Method Details

.eager_load_api_controllersObject



11
12
13
14
15
16
17
18
# File 'lib/jko_api/util.rb', line 11

def self.eager_load_api_controllers
  [Rails.root.join('app', 'controllers')].each do |load_path|
    matcher = /\A#{Regexp.escape(load_path.to_s)}\/(.*)\.rb\Z/
    Dir.glob("#{load_path}/#{JkoApi.configuration.api_namespace}/**/*.rb").sort.each do |file|
      require_dependency file.sub(matcher, '\1')
    end
  end
end

.stupid_hack!Object

This was a hack needed in rails 4.2 I’m keeping the code for backwards compatibility (for now)



6
7
8
9
# File 'lib/jko_api/util.rb', line 6

def self.stupid_hack!
  Rails.application.reload_routes!
  eager_load_api_controllers
end