Class: Superlink::Builder
- Inherits:
-
URI::Builder::DSL
- Object
- URI::Builder::DSL
- Superlink::Builder
- Defined in:
- lib/superlink.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Class Method Summary collapse
Instance Method Summary collapse
- #clear_format ⇒ Object
- #format(format) ⇒ Object
- #initialize_copy(original) ⇒ Object
- #join(*segments) ⇒ Object
- #uri ⇒ Object
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
12 13 14 |
# File 'lib/superlink.rb', line 12 def model @model end |
Class Method Details
.parse ⇒ Object
38 39 40 |
# File 'lib/superlink.rb', line 38 def self.parse(...) new URI(...) end |
Instance Method Details
#clear_format ⇒ Object
23 24 25 26 |
# File 'lib/superlink.rb', line 23 def clear_format @format = nil self end |
#format(format) ⇒ Object
18 19 20 21 |
# File 'lib/superlink.rb', line 18 def format(format) @format = format self end |
#initialize_copy(original) ⇒ Object
42 43 44 45 |
# File 'lib/superlink.rb', line 42 def initialize_copy(original) super @uri = original.uri end |
#join(*segments) ⇒ Object
14 15 16 |
# File 'lib/superlink.rb', line 14 def join(*segments) super(*route(*segments)) end |
#uri ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/superlink.rb', line 28 def uri super.clone.tap do |uri| uri.path = "#{uri.path}.#{@format}" if @format # Check if the route exists in the routes.rb file unless Rails.application.routes.recognize_path(uri.path) raise ActionController::UrlGenerationError, "No route matches [#{uri.path}]" end end end |