Class: Hoodoo::Services::Discovery::ForLocal

Inherits:
Object
  • Object
show all
Defined in:
lib/hoodoo/services/discovery/results/for_local.rb

Overview

Describe a resource endpoint location in a way that allows it to be method-called from the service middleware directly.

This is a very special case class used for the inter-resource local call code in Hoodoo::Services::Middleware. It really exists only for semantic purposes; the middleware calls via Hoodoo::Client::Endpoint subclass Hoodoo::Sevices::Middleware::InterResourceLocal; and the Endpoint subclass family are supposed to use result classes from the Hoodoo::Services::Discovery engine when they configure instances.

This isn’t actually enforced anywhere, but conceptually it’s cleanest to follow the same pattern.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource:, version:, base_path:, routing_regexp:, de_facto_base_path:, de_facto_routing_regexp:, interface_class:, implementation_instance:) ⇒ ForLocal

Create an instance with named parameters as follows:

resource

See #resource.

version

See #version.

base_path

See #base_path.

routing_regexp

See #routing_regexp.

de_facto_base_path

See #de_facto_base_path.

de_facto_routing_regexp

See #de_facto_routing_regexp.

interface_class

See #interface_class.

implementation_instance

See #implementation_instance.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/hoodoo/services/discovery/results/for_local.rb', line 81

def initialize( resource:,
                version:,
                base_path:,
                routing_regexp:,
                de_facto_base_path:,
                de_facto_routing_regexp:,
                interface_class:,
                implementation_instance: )

  self.resource                = resource.to_sym
  self.version                 = version.to_i
  self.base_path               = base_path
  self.routing_regexp          = routing_regexp
  self.de_facto_base_path      = de_facto_base_path
  self.de_facto_routing_regexp = de_facto_routing_regexp
  self.interface_class         = interface_class
  self.implementation_instance = implementation_instance
end

Instance Attribute Details

#base_pathObject

The base path of this resource and version - for example, “/v1/products” or “/v2/members”. String.



41
42
43
# File 'lib/hoodoo/services/discovery/results/for_local.rb', line 41

def base_path
  @base_path
end

#de_facto_base_pathObject

The de facto routing equivalent of #base_path. This is not a custom path based on the interface’s declared endpoint; it is derived directlyf rom resource or version - for example, “/1/Product” or “/2/Member”. String.



54
55
56
# File 'lib/hoodoo/services/discovery/results/for_local.rb', line 54

def de_facto_base_path
  @de_facto_base_path
end

#de_facto_routing_regexpObject

As #routing_regexp, but matches #de_facto_base_path.



58
59
60
# File 'lib/hoodoo/services/discovery/results/for_local.rb', line 58

def de_facto_routing_regexp
  @de_facto_routing_regexp
end

#implementation_instanceObject

The Hoodoo::Services::Implementation subclass instance which implements the interface described by #interface_class.



68
69
70
# File 'lib/hoodoo/services/discovery/results/for_local.rb', line 68

def implementation_instance
  @implementation_instance
end

#interface_classObject

The Hoodoo::Services::Interface subclass class describing the resource interface.



63
64
65
# File 'lib/hoodoo/services/discovery/results/for_local.rb', line 63

def interface_class
  @interface_class
end

#resourceObject

The resource name described, as a Symbol (e.g. :Purchase).



32
33
34
# File 'lib/hoodoo/services/discovery/results/for_local.rb', line 32

def resource
  @resource
end

#routing_regexpObject

A regular expression which matches the #base_path and any identifier data, allowing inbound URI-based requests to be routed to this endpoint. Regexp instance.



47
48
49
# File 'lib/hoodoo/services/discovery/results/for_local.rb', line 47

def routing_regexp
  @routing_regexp
end

#versionObject

Resource endpoint version, as an Integer (e.g. 2).



36
37
38
# File 'lib/hoodoo/services/discovery/results/for_local.rb', line 36

def version
  @version
end