Class: Dry::Effects::Providers::State

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/effects/providers/state.rb

Instance Method Summary collapse

Instance Method Details

#call(state = Undefined) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Yield the block with the handler installed



19
20
21
22
# File 'lib/dry/effects/providers/state.rb', line 19

def call(state = Undefined)
  r = super
  [self.state, r]
end

#provide?(effect) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


27
28
29
# File 'lib/dry/effects/providers/state.rb', line 27

def provide?(effect)
  effect.type.equal?(:state) && scope.equal?(effect.scope)
end

#write(value:) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/dry/effects/providers/state.rb', line 7

def write(value:)
  case value
  when state_type
    @state = value
  else
    Instructions.Raise(Errors::InvalidValueError.new(state, value))
  end
end