Class: Takagi::Router::RouteEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/takagi/router.rb

Overview

Represents a registered route with its handler and CoRE Link Format metadata

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method:, path:, block:, metadata: {}, receiver: nil) ⇒ RouteEntry

Returns a new instance of RouteEntry.



37
38
39
40
41
42
43
# File 'lib/takagi/router.rb', line 37

def initialize(method:, path:, block:, metadata: {}, receiver: nil)
  @method = method
  @path = path
  @block = block
  @receiver = receiver
  @attribute_set = Core::AttributeSet.new()
end

Instance Attribute Details

#attribute_setObject (readonly)

Returns the value of attribute attribute_set.



35
36
37
# File 'lib/takagi/router.rb', line 35

def attribute_set
  @attribute_set
end

#blockObject (readonly)

Returns the value of attribute block.



35
36
37
# File 'lib/takagi/router.rb', line 35

def block
  @block
end

#methodObject (readonly)

Returns the value of attribute method.



35
36
37
# File 'lib/takagi/router.rb', line 35

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.



35
36
37
# File 'lib/takagi/router.rb', line 35

def path
  @path
end

#receiverObject (readonly)

Returns the value of attribute receiver.



35
36
37
# File 'lib/takagi/router.rb', line 35

def receiver
  @receiver
end

Instance Method Details

#configure_attributes(&block) ⇒ Object

Configure CoRE Link Format attributes using DSL block

Examples:

entry.configure_attributes do
  rt 'sensor'
  obs true
  ct 'application/json'
end


58
59
60
61
# File 'lib/takagi/router.rb', line 58

def configure_attributes(&block)
  @attribute_set.core(&block)
  @attribute_set.apply!
end

#initialize_copy(original) ⇒ Object

Support for dup operation (used in discovery)



64
65
66
67
# File 'lib/takagi/router.rb', line 64

def initialize_copy(original)
  super
  @attribute_set = Core::AttributeSet.new(original..dup)
end

#metadataObject

Returns the underlying metadata hash for backward compatibility



46
47
48
# File 'lib/takagi/router.rb', line 46

def 
  @attribute_set.
end