Class: SamlTool::Redirect
- Inherits:
-
Object
- Object
- SamlTool::Redirect
- Defined in:
- lib/saml_tool/redirect.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Class Method Summary collapse
Instance Method Summary collapse
- #append_data ⇒ Object
- #build_uri ⇒ Object
- #data_string ⇒ Object
-
#initialize(args) ⇒ Redirect
constructor
A new instance of Redirect.
- #to_s ⇒ Object
- #uri ⇒ Object
- #uri_from_to ⇒ Object
Constructor Details
#initialize(args) ⇒ Redirect
Returns a new instance of Redirect.
23 24 25 26 |
# File 'lib/saml_tool/redirect.rb', line 23 def initialize(args) @to = args[:to] @data = args[:data] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
17 18 19 |
# File 'lib/saml_tool/redirect.rb', line 17 def data @data end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
17 18 19 |
# File 'lib/saml_tool/redirect.rb', line 17 def to @to end |
Class Method Details
.uri(args) ⇒ Object
19 20 21 |
# File 'lib/saml_tool/redirect.rb', line 19 def self.uri(args) new(args).to_s end |
Instance Method Details
#append_data ⇒ Object
37 38 39 |
# File 'lib/saml_tool/redirect.rb', line 37 def append_data uri.query = [uri.query, data_string].compact.join('&') end |
#build_uri ⇒ Object
45 46 47 48 49 |
# File 'lib/saml_tool/redirect.rb', line 45 def build_uri uri_from_to append_data return uri end |
#data_string ⇒ Object
32 33 34 35 |
# File 'lib/saml_tool/redirect.rb', line 32 def data_string return data if data.kind_of? String data.to_a.collect{|pair| pair.collect{|p| CGI.escape(p.to_s)}.join('=')}.join('&') end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/saml_tool/redirect.rb', line 41 def to_s uri.to_s end |
#uri ⇒ Object
28 29 30 |
# File 'lib/saml_tool/redirect.rb', line 28 def uri @uri || build_uri end |
#uri_from_to ⇒ Object
51 52 53 |
# File 'lib/saml_tool/redirect.rb', line 51 def uri_from_to @uri = URI(to) end |