Class: Hactor::HAL::Link
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Hactor::HAL::Link
- Defined in:
- lib/hactor/hal/link.rb
Instance Attribute Summary collapse
-
#parent_resource ⇒ Object
readonly
Returns the value of attribute parent_resource.
-
#rel ⇒ Object
readonly
Returns the value of attribute rel.
-
#template_class ⇒ Object
readonly
Returns the value of attribute template_class.
Instance Method Summary collapse
- #href(variables = nil) ⇒ Object
-
#initialize(obj, options) ⇒ Link
constructor
A new instance of Link.
- #templated? ⇒ Boolean
Constructor Details
#initialize(obj, options) ⇒ Link
Returns a new instance of Link.
9 10 11 12 13 14 15 |
# File 'lib/hactor/hal/link.rb', line 9 def initialize(obj, ) @href = obj['href'] @rel = .fetch(:rel) @parent_resource = .fetch(:context) @template_class = [:template_class] || Addressable::Template super(obj) end |
Instance Attribute Details
#parent_resource ⇒ Object (readonly)
Returns the value of attribute parent_resource.
7 8 9 |
# File 'lib/hactor/hal/link.rb', line 7 def parent_resource @parent_resource end |
#rel ⇒ Object (readonly)
Returns the value of attribute rel.
7 8 9 |
# File 'lib/hactor/hal/link.rb', line 7 def rel @rel end |
#template_class ⇒ Object (readonly)
Returns the value of attribute template_class.
7 8 9 |
# File 'lib/hactor/hal/link.rb', line 7 def template_class @template_class end |
Instance Method Details
#href(variables = nil) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/hactor/hal/link.rb', line 17 def href(variables=nil) if templated? variables ||= {} template_class.new(@href).(variables).to_s else @href end end |
#templated? ⇒ Boolean
26 27 28 |
# File 'lib/hactor/hal/link.rb', line 26 def templated? !!templated end |