Class: Dry::Effects::Effect

Inherits:
Object
  • Object
show all
Extended by:
Initializer
Defined in:
lib/dry/effects/effect.rb

Instance Method Summary collapse

Methods included from Initializer

extended

Instance Method Details

#call(*args, **kwargs) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dry/effects/effect.rb', line 34

def call(*args, **kwargs)
  if args.empty?
    if kwargs.empty?
      self
    else
      keywords(**kwargs)
    end
  else
    with(payload: args, keywords: @keywords.merge(kwargs))
  end
end

#keywords(**keywords) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/dry/effects/effect.rb', line 26

def keywords(**keywords)
  if keywords.empty?
    @keywords
  else
    with(keywords: @keywords.merge(keywords))
  end
end

#payload(*payload) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/dry/effects/effect.rb', line 18

def payload(*payload)
  if payload.empty?
    @payload
  else
    with(payload: payload)
  end
end