ruby-grape/grape-entity

View on GitHub
lib/grape_entity/condition/block_condition.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module Grape
  class Entity
    module Condition
      class BlockCondition < Base
        attr_reader :block

        def setup(block)
          @block = block
        end

        def ==(other)
          super && @block == other.block
        end

        def if_value(entity, options)
          entity.exec_with_object(options, &@block)
        end
      end
    end
  end
end