Module: JSRailsRoutes
- Defined in:
- lib/js_rails_routes.rb,
lib/js_rails_routes/route.rb,
lib/js_rails_routes/engine.rb,
lib/js_rails_routes/builder.rb,
lib/js_rails_routes/version.rb,
lib/js_rails_routes/generator.rb,
lib/js_rails_routes/route_set.rb,
lib/js_rails_routes/configuration.rb,
lib/js_rails_routes/language/base.rb,
lib/js_rails_routes/language/javascript.rb,
lib/js_rails_routes/language/typescript.rb
Defined Under Namespace
Modules: Language Classes: Builder, Configuration, Engine, Generator, Route, RouteSet
Constant Summary collapse
- PARAM_REGEXP =
%r{:(.*?)(/|$)}.freeze
- VERSION =
'1.2.0'
Class Method Summary collapse
-
.config ⇒ Configuration
Current configuration.
- .configure {|Configuration| ... } ⇒ Object
- .generate(task) ⇒ Object
- .language ⇒ JSRailsRoutes::Language::Base
-
.sandbox { ... } ⇒ Object
Execute a given block within a new sandbox.
Class Method Details
.config ⇒ Configuration
Current configuration.
23 24 25 |
# File 'lib/js_rails_routes.rb', line 23 def config @config ||= Configuration.new end |
.configure {|Configuration| ... } ⇒ Object
16 17 18 |
# File 'lib/js_rails_routes.rb', line 16 def configure yield config if block_given? end |
.generate(task) ⇒ Object
28 29 30 31 |
# File 'lib/js_rails_routes.rb', line 28 def generate(task) builder = Builder.new(JSRailsRoutes.language) Generator.new(builder).generate(task) end |
.language ⇒ JSRailsRoutes::Language::Base
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/js_rails_routes.rb', line 51 def language case config.target when 'js' Language::JavaScript.new when 'ts' Language::TypeScript.new else raise NotImplementedError, config.target end end |
.sandbox { ... } ⇒ Object
Execute a given block within a new sandbox. For test purpose.
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/js_rails_routes.rb', line 36 def sandbox raise 'Already in a sandbox' if @sandbox @sandbox = true prev = @config @config = Configuration.new begin yield if block_given? ensure @config = prev @sandbox = nil end end |