Class: Leadlight::Link
- Inherits:
-
Object
- Object
- Leadlight::Link
- Includes:
- Leadlight
- Defined in:
- lib/leadlight/link.rb
Direct Known Subclasses
Constant Summary collapse
- HTTP_METHODS_WITH_BODY =
[:post, :put, :patch]
- HTTP_METHODS_WITHOUT_BODY =
[ :options, :head, :get, :get_representation!, :delete ]
- HTTP_METHODS =
HTTP_METHODS_WITHOUT_BODY + HTTP_METHODS_WITH_BODY
Constants included from Leadlight
Instance Attribute Summary collapse
-
#aliases ⇒ Object
readonly
Returns the value of attribute aliases.
-
#expansion_params ⇒ Object
readonly
Expansion params have no effect on the Link.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#rel ⇒ Object
readonly
Returns the value of attribute rel.
-
#rev ⇒ Object
readonly
Returns the value of attribute rev.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #[](*args) ⇒ Object
- #expand(expansion_params = nil) ⇒ Object
- #follow(*args) ⇒ Object
-
#initialize(service, href, rel = nil, title = rel, options = {}) ⇒ Link
constructor
A new instance of Link.
- #params ⇒ Object
- #to_s ⇒ Object
Methods included from Leadlight
ParamHash, build_connection_common, build_service, common_connection_stack
Constructor Details
#initialize(service, href, rel = nil, title = rel, options = {}) ⇒ Link
Returns a new instance of Link.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/leadlight/link.rb', line 28 def initialize(service, href, rel=nil, title=rel, ={}) @options = @service = service @href = Addressable::URI.parse(href) @rel = rel.to_s @title = title.to_s @rev = [:rev] @aliases = Array([:aliases]) self.expansion_params = .fetch(:expansion_params) { {} } end |
Instance Attribute Details
#aliases ⇒ Object (readonly)
Returns the value of attribute aliases.
20 21 22 |
# File 'lib/leadlight/link.rb', line 20 def aliases @aliases end |
#expansion_params ⇒ Object
Expansion params have no effect on the Link. They exist to keep a record of how this particular Link instance was constructed, if it was constructed via expansion.
26 27 28 |
# File 'lib/leadlight/link.rb', line 26 def expansion_params @expansion_params end |
#href ⇒ Object
Returns the value of attribute href.
19 20 21 |
# File 'lib/leadlight/link.rb', line 19 def href @href end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
21 22 23 |
# File 'lib/leadlight/link.rb', line 21 def @options end |
#rel ⇒ Object (readonly)
Returns the value of attribute rel.
16 17 18 |
# File 'lib/leadlight/link.rb', line 16 def rel @rel end |
#rev ⇒ Object (readonly)
Returns the value of attribute rev.
17 18 19 |
# File 'lib/leadlight/link.rb', line 17 def rev @rev end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
15 16 17 |
# File 'lib/leadlight/link.rb', line 15 def service @service end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
18 19 20 |
# File 'lib/leadlight/link.rb', line 18 def title @title end |
Instance Method Details
#[](*args) ⇒ Object
74 75 76 |
# File 'lib/leadlight/link.rb', line 74 def [](*args) (*args) end |
#expand(expansion_params = nil) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/leadlight/link.rb', line 66 def (expansion_params=nil) if expansion_params dup_with_new_href((href.dup, expansion_params), expansion_params) else self end end |
#follow(*args) ⇒ Object
60 61 62 63 64 |
# File 'lib/leadlight/link.rb', line 60 def follow(*args) get_representation!(*args) do |representation| return representation end end |
#params ⇒ Object
82 83 84 |
# File 'lib/leadlight/link.rb', line 82 def params extracted_params.merge(expansion_params) end |
#to_s ⇒ Object
78 79 80 |
# File 'lib/leadlight/link.rb', line 78 def to_s "Link(#{rel}:#{href}#{inspect_expansion_params})" end |