Class: Dry::Effects::Providers::Cmp

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/dry/effects/providers/cmp.rb', line 9

def value
  @value
end

Instance Method Details

#call(value = Undefined) ⇒ Array(Any, Any)

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

Returns:

  • (Array(Any, Any))


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dry/effects/providers/cmp.rb', line 21

def call(value = Undefined)
  if Undefined.equal?(value)
    @value = false
    first = yield
    @value = true
    [first, yield]
  else
    @value = value
    yield
  end
end

#getObject



13
14
15
# File 'lib/dry/effects/providers/cmp.rb', line 13

def get
  value
end

#provide?(effect) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


36
37
38
# File 'lib/dry/effects/providers/cmp.rb', line 36

def provide?(effect)
  super && id.equal?(effect.id)
end

#representString

Returns:

  • (String)


42
43
44
# File 'lib/dry/effects/providers/cmp.rb', line 42

def represent
  "cmp[#{id}=#{@value}]"
end