Sha256: ffec14e4c28ed9f96a8fccde92b1a64acfe07d1537b7e66851421f7113081f22

Contents?: true

Size: 537 Bytes

Versions: 25

Compression:

Stored size: 537 Bytes

Contents

require 'unstrict_proc'
module JSONAPIonify
  class Continuation
    using UnstrictProc

    def initialize(**options)
      @options = options
    end

    def check(*arguments)
      yield if check_if(*arguments) && check_unless(*arguments)
    end

    private

    def check_if(*arguments)
      return true unless @options[:if]
      @options[:if].unstrict.call(*arguments)
    end

    def check_unless(*arguments)
      return true unless @options[:unless]
      not @options[:unless].unstrict.call(*arguments)
    end

  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
jsonapionify-0.10.0 lib/jsonapionify/continuation.rb
jsonapionify-0.9.3 lib/jsonapionify/continuation.rb
jsonapionify-0.9.2 lib/jsonapionify/continuation.rb
jsonapionify-0.9.1 lib/jsonapionify/continuation.rb
jsonapionify-0.9.0 lib/jsonapionify/continuation.rb