Class: Takagi::Router::RouteEntry

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

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.

Parameters:

  • method: (Object)
  • path: (Object)
  • block: (Object)
  • metadata: (::Hash[untyped, untyped]) (defaults to: {})
  • receiver: (Object, nil) (defaults to: nil)


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.

Returns:

  • (Object)


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

def attribute_set
  @attribute_set
end

#blockObject (readonly)

Returns the value of attribute block.

Returns:

  • (Object)


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

def block
  @block
end

#methodObject (readonly)

Returns the value of attribute method.

Returns:

  • (Object)


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

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.

Returns:

  • (Object)


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

def path
  @path
end

#receiverObject (readonly)

Returns the value of attribute receiver.

Returns:

  • (Object)


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

def receiver
  @receiver
end

Instance Method Details

#configure_attributes {|arg0| ... } ⇒ Object

Configure CoRE Link Format attributes using DSL block

Examples:

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

Yields:

Yield Parameters:

  • arg0

Yield Returns:

  • (Object)

Returns:

  • (Object)


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)

Parameters:

  • original (Object)

Returns:

  • (Object)


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

Returns:

  • (Object)


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

def 
  @attribute_set.
end