Sha256: ed608c16b50cf38bf4f104eefd8cddd1b9a1ee3d1fb9a3bfd2d00e1dccf13bb8

Contents?: true

Size: 466 Bytes

Versions: 4

Compression:

Stored size: 466 Bytes

Contents

class Trailblazer::Operation
  module Policy
    def self.Guard(proc, name: :default, &block)
      Policy.step( Guard.build(proc), name: name )
    end

    module Guard
      def self.build(callable)
        option = Trailblazer::Option::KW(callable)

        # this gets wrapped in a Operation::Result object.
        ->( (options, *), circuit_args ) do
          Result.new( !!option.(options, circuit_args), {} )
        end
      end
    end # Guard
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trailblazer-2.1.0.beta4 lib/trailblazer/operation/guard.rb
trailblazer-2.1.0.beta3 lib/trailblazer/operation/guard.rb
trailblazer-2.1.0.beta2 lib/trailblazer/operation/guard.rb
trailblazer-2.1.0.beta1 lib/trailblazer/operation/guard.rb