Class: Async::Service::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/async/service/environment.rb

Defined Under Namespace

Classes: Builder, Evaluator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(facet = ::Module.new, parent = nil) ⇒ Environment

Returns a new instance of Environment.



59
60
61
62
63
64
65
66
# File 'lib/async/service/environment.rb', line 59

def initialize(facet = ::Module.new, parent = nil)
	unless facet.class == ::Module
		raise ArgumentError, "Facet must be a module!"
	end
	
	@facet = facet
	@parent = parent
end

Instance Attribute Details

#facetObject (readonly)

Returns the value of attribute facet.



69
70
71
# File 'lib/async/service/environment.rb', line 69

def facet
  @facet
end

#parentObject (readonly)

Returns the value of attribute parent.



72
73
74
# File 'lib/async/service/environment.rb', line 72

def parent
  @parent
end

#The parent environment, if any.(parentenvironment) ⇒ Object (readonly)



72
# File 'lib/async/service/environment.rb', line 72

attr :parent

Class Method Details

.buildObject



55
56
57
# File 'lib/async/service/environment.rb', line 55

def self.build(...)
	Environment.new(Builder.for(...))
end

Instance Method Details

#evaluatorObject



149
150
151
# File 'lib/async/service/environment.rb', line 149

def evaluator
	return Evaluator.wrap(self)
end

#implements?(interface) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/async/service/environment.rb', line 83

def implements?(interface)
	@facet <= interface
end

#included(target) ⇒ Object



74
75
76
77
# File 'lib/async/service/environment.rb', line 74

def included(target)
	@parent&.included(target)
	target.include(@facet)
end

#The facet module.=(facet) ⇒ Object



69
# File 'lib/async/service/environment.rb', line 69

attr :facet

#to_hObject



153
154
155
# File 'lib/async/service/environment.rb', line 153

def to_h
	evaluator.to_h
end

#withObject



79
80
81
# File 'lib/async/service/environment.rb', line 79

def with(...)
	return self.class.new(Builder.for(...), self)
end