Sha256: a67c9c41a71fcc5972afb25114df62e7b214e947e94430fec62d2937de92c32b

Contents?: true

Size: 864 Bytes

Versions: 4

Compression:

Stored size: 864 Bytes

Contents

# frozen_string_literal: true

require 'forwardable'

module DynamoidAdvancedWhere
  module Nodes
    module Concerns
      module Negatable
        def negate
          NotNode.new(sub_node: self)
        end
        alias ! negate
      end
    end

    # I know this is weird but it prevents a circular dependency
    require_relative './and_node'
    require_relative './or_node'

    class NotNode
      extend Forwardable
      include Concerns::SupportsLogicalAnd
      include Concerns::SupportsLogicalOr

      attr_accessor :sub_node

      def_delegators :@sub_node,
                     :expression_attribute_names,
                     :expression_attribute_values

      def initialize(sub_node:)
        self.sub_node = sub_node
        freeze
      end

      def to_expression
        "NOT(#{sub_node.to_expression})"
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dynamoid_advanced_where-1.3.0 lib/dynamoid_advanced_where/nodes/not.rb
dynamoid_advanced_where-1.2.0 lib/dynamoid_advanced_where/nodes/not.rb
dynamoid_advanced_where-1.1.0 lib/dynamoid_advanced_where/nodes/not.rb
dynamoid_advanced_where-1.0.1 lib/dynamoid_advanced_where/nodes/not.rb