Module: Dry::Logic::Appliable

Defined in:
lib/dry/logic/appliable.rb

Instance Method Summary collapse

Instance Method Details

#applied?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/dry/logic/appliable.rb', line 14

def applied?
  !result.nil?
end

#failure?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/dry/logic/appliable.rb', line 22

def failure?
  !success?
end

#idObject



6
7
8
# File 'lib/dry/logic/appliable.rb', line 6

def id
  options[:id]
end

#resultObject



10
11
12
# File 'lib/dry/logic/appliable.rb', line 10

def result
  options[:result]
end

#success?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/dry/logic/appliable.rb', line 18

def success?
  result.equal?(true)
end

#to_astObject



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

def to_ast
  if applied? && id
    [success? ? :success : :failure, [id, ast]]
  else
    ast
  end
end