Class: EDango::DI::Service

Inherits:
Object show all
Includes:
Observable
Defined in:
lib/edango/di/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition = nil) ⇒ Service

Returns a new instance of Service.



29
30
31
32
# File 'lib/edango/di/service.rb', line 29

def initialize(definition = nil)
  @definition = definition || default_definition
  state_update()
end

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



27
28
29
# File 'lib/edango/di/service.rb', line 27

def definition
  @definition
end

Instance Method Details

#[](key) ⇒ Object



34
35
36
# File 'lib/edango/di/service.rb', line 34

def [](key)
  @definition[key]
end

#[]=(key, value) ⇒ Object



38
39
40
41
42
43
# File 'lib/edango/di/service.rb', line 38

def []=(key, value)
  previous_value, @definition[key] = @definition[key], value
  state_update() if previous_value != value

  value
end

#nil?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/edango/di/service.rb', line 45

def nil?
  @definition.nil?
end