ruby-grape/grape-entity

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

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module Grape
  class Entity
    module Condition
      class SymbolCondition < Base
        attr_reader :symbol

        def setup(symbol)
          @symbol = symbol
        end

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

        def if_value(_entity, options)
          options[symbol]
        end
      end
    end
  end
end