Class: AePageObjects::RakeRouter::Param
- Inherits:
-
Struct
- Object
- Struct
- AePageObjects::RakeRouter::Param
- Includes:
- Comparable
- Defined in:
- lib/ae_page_objects/core/rake_router.rb
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #optional? ⇒ Boolean
- #replace_param_in_url(url) ⇒ Object
- #substitute(url, values) ⇒ Object
Instance Method Details
#<=>(other) ⇒ Object
100 101 102 |
# File 'lib/ae_page_objects/core/rake_router.rb', line 100 def <=>(other) name.to_s <=> other.name.to_s end |
#eql?(other) ⇒ Boolean
104 105 106 |
# File 'lib/ae_page_objects/core/rake_router.rb', line 104 def eql?(other) name == other.name end |
#hash ⇒ Object
108 109 110 |
# File 'lib/ae_page_objects/core/rake_router.rb', line 108 def hash name.hash end |
#optional? ⇒ Boolean
96 97 98 |
# File 'lib/ae_page_objects/core/rake_router.rb', line 96 def optional? optional end |
#replace_param_in_url(url) ⇒ Object
112 113 114 115 116 117 118 |
# File 'lib/ae_page_objects/core/rake_router.rb', line 112 def replace_param_in_url(url) if optional? url.gsub("(/:#{name})", '(\/.+)?') else url.gsub(":#{name}", '(.+)') end end |
#substitute(url, values) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/ae_page_objects/core/rake_router.rb', line 120 def substitute(url, values) if optional? if values[name] url.sub("(/:#{name})", "/#{values[name]}") else url.sub("(/:#{name})", '') end else raise ArgumentError, "Missing required parameter '#{name}' for '#{url}' in #{values.inspect}" unless values.key? name url.sub(":#{name}", values[name]) end end |