Class: HALDecorator::Links::Link

Inherits:
Property
  • Object
show all
Defined in:
lib/hal_decorator/links.rb

Instance Attribute Summary collapse

Attributes inherited from Property

#name, #options, #resource

Instance Method Summary collapse

Methods inherited from Property

#change_scope, #method_missing, #respond_to_missing?, #value

Constructor Details

#initialize(rel, value = nil, http_method: nil, &block) ⇒ Link

Returns a new instance of Link.



19
20
21
22
23
24
25
# File 'lib/hal_decorator/links.rb', line 19

def initialize(rel, value = nil, http_method: nil, &block)
  if value.nil? && !block_given?
    raise 'link must be called with non nil value or be given a block'
  end
  @http_method = http_method
  super(rel, value, &block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class HALDecorator::Property

Instance Attribute Details

#http_methodObject (readonly)

Returns the value of attribute http_method.



18
19
20
# File 'lib/hal_decorator/links.rb', line 18

def http_method
  @http_method
end

Instance Method Details

#relObject



27
28
29
# File 'lib/hal_decorator/links.rb', line 27

def rel
  name
end