Class: AdminBits::AdminResource::PathHandler
- Inherits:
-
Object
- Object
- AdminBits::AdminResource::PathHandler
- Defined in:
- lib/admin_bits/admin_resource/path_handler.rb
Instance Attribute Summary collapse
-
#request_params ⇒ Object
readonly
Returns the value of attribute request_params.
-
#unprocessed_path ⇒ Object
readonly
Returns the value of attribute unprocessed_path.
Instance Method Summary collapse
-
#initialize(path, request_params) ⇒ PathHandler
constructor
A new instance of PathHandler.
- #path ⇒ Object
- #with_params(params = {}) ⇒ Object
Constructor Details
#initialize(path, request_params) ⇒ PathHandler
Returns a new instance of PathHandler.
4 5 6 7 |
# File 'lib/admin_bits/admin_resource/path_handler.rb', line 4 def initialize(path, request_params) @request_params = request_params @unprocessed_path = path end |
Instance Attribute Details
#request_params ⇒ Object (readonly)
Returns the value of attribute request_params.
2 3 4 |
# File 'lib/admin_bits/admin_resource/path_handler.rb', line 2 def request_params @request_params end |
#unprocessed_path ⇒ Object (readonly)
Returns the value of attribute unprocessed_path.
2 3 4 |
# File 'lib/admin_bits/admin_resource/path_handler.rb', line 2 def unprocessed_path @unprocessed_path end |
Instance Method Details
#path ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/admin_bits/admin_resource/path_handler.rb', line 9 def path @path ||= begin if unprocessed_path.is_a?(Proc) @path = routes.instance_exec(request_params, &unprocessed_path) elsif unprocessed_path.is_a?(String) @path = unprocessed_path else unknown_argument_type end end end |
#with_params(params = {}) ⇒ Object
21 22 23 |
# File 'lib/admin_bits/admin_resource/path_handler.rb', line 21 def with_params(params = {}) path + "?" + request_params.merge(params).to_param end |