Sha256: 788e87b733da0b76676c4d46857b2001c9e234b61b53ca85510ed70581e39a7d

Contents?: true

Size: 497 Bytes

Versions: 15

Compression:

Stored size: 497 Bytes

Contents

# frozen_string_literal: true

module Dry
  module Logic
    module Appliable
      def id
        options[:id]
      end

      def result
        options[:result]
      end

      def applied?
        !result.nil?
      end

      def success?
        result.equal?(true)
      end

      def failure?
        !success?
      end

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

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
dry-logic-1.6.0 lib/dry/logic/appliable.rb
dry-logic-1.5.0 lib/dry/logic/appliable.rb
dry-logic-1.4.0 lib/dry/logic/appliable.rb
dry-logic-1.3.0 lib/dry/logic/appliable.rb
dry-logic-1.2.0 lib/dry/logic/appliable.rb
dry-logic-1.1.1 lib/dry/logic/appliable.rb
dry-logic-1.1.0 lib/dry/logic/appliable.rb
dry-logic-1.0.8 lib/dry/logic/appliable.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/dry-logic-1.0.7/lib/dry/logic/appliable.rb
dry-logic-1.0.7 lib/dry/logic/appliable.rb
dry-logic-1.0.6 lib/dry/logic/appliable.rb
dry-logic-1.0.5 lib/dry/logic/appliable.rb
dry-logic-1.0.4 lib/dry/logic/appliable.rb
dry-logic-1.0.3 lib/dry/logic/appliable.rb
dry-logic-1.0.2 lib/dry/logic/appliable.rb