Class: MuchRails::Action::BaseRouter::BaseURL
- Inherits:
-
Object
- Object
- MuchRails::Action::BaseRouter::BaseURL
- Defined in:
- lib/much-rails/action/base_router.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#router ⇒ Object
readonly
Returns the value of attribute router.
-
#url_name ⇒ Object
readonly
Returns the value of attribute url_name.
-
#url_path ⇒ Object
readonly
Returns the value of attribute url_path.
Class Method Summary collapse
- .for(router, url_or_path) ⇒ Object
- .url_name(router, name) ⇒ Object
- .url_path(router, path) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(router, url_path, url_name = nil) ⇒ BaseURL
constructor
A new instance of BaseURL.
- #name ⇒ Object
- #path ⇒ Object
- #path_for(**kargs) ⇒ Object
- #url_for(**kargs) ⇒ Object
Constructor Details
#initialize(router, url_path, url_name = nil) ⇒ BaseURL
Returns a new instance of BaseURL.
393 394 395 396 397 |
# File 'lib/much-rails/action/base_router.rb', line 393 def initialize(router, url_path, url_name = nil) @router = router @url_path = url_path.to_s @url_name = url_name&.to_sym end |
Instance Attribute Details
#router ⇒ Object (readonly)
Returns the value of attribute router.
391 392 393 |
# File 'lib/much-rails/action/base_router.rb', line 391 def router @router end |
#url_name ⇒ Object (readonly)
Returns the value of attribute url_name.
391 392 393 |
# File 'lib/much-rails/action/base_router.rb', line 391 def url_name @url_name end |
#url_path ⇒ Object (readonly)
Returns the value of attribute url_path.
391 392 393 |
# File 'lib/much-rails/action/base_router.rb', line 391 def url_path @url_path end |
Class Method Details
.for(router, url_or_path) ⇒ Object
385 386 387 388 389 |
# File 'lib/much-rails/action/base_router.rb', line 385 def self.for(router, url_or_path) return url_or_path if url_or_path.is_a?(self) new(router, url_or_path) end |
.url_name(router, name) ⇒ Object
371 372 373 374 375 376 |
# File 'lib/much-rails/action/base_router.rb', line 371 def self.url_name(router, name) return unless name return name unless router&.name "#{router.name}_#{name}".to_sym end |
.url_path(router, path) ⇒ Object
378 379 380 381 382 383 |
# File 'lib/much-rails/action/base_router.rb', line 378 def self.url_path(router, path) return unless path return path unless router&.base_url File.join(router.base_url, path) end |
Instance Method Details
#==(other) ⇒ Object
415 416 417 418 419 420 421 |
# File 'lib/much-rails/action/base_router.rb', line 415 def ==(other) return super unless other.is_a?(self.class) @router == other.router && @url_path == other.url_path && @url_name == other.url_name end |
#name ⇒ Object
399 400 401 |
# File 'lib/much-rails/action/base_router.rb', line 399 def name self.class.url_name(@router, @url_name) end |
#path ⇒ Object
403 404 405 |
# File 'lib/much-rails/action/base_router.rb', line 403 def path self.class.url_path(@router, @url_path) end |
#path_for(**kargs) ⇒ Object
407 408 409 |
# File 'lib/much-rails/action/base_router.rb', line 407 def path_for(**kargs) raise NotImplementedError end |
#url_for(**kargs) ⇒ Object
411 412 413 |
# File 'lib/much-rails/action/base_router.rb', line 411 def url_for(**kargs) raise NotImplementedError end |