Sha256: b6405dd8ea15217c8aab242f7848a8c768bbd4086749efe200b1d6ee1ca96937

Contents?: true

Size: 1.61 KB

Versions: 5

Compression:

Stored size: 1.61 KB

Contents

module AgnosticBackend
  module Queryable
    module Expressions
      class Expression < TreeNode
      end

      class Where < Expression
        def initialize(criterion:, context:)
          super([criterion], context)
        end

        def criterion
          children.first
        end
      end


      class Filter < Expression
        def initialize(criterion:, context:)
          super([criterion], context)
        end

        def criterion
          children.first
        end
      end

      class Select < Expression
        def initialize(attributes:, context:)
          super(attributes.map { |a| Attribute.new(a, parent: self, context: context) }, context)
        end

        alias_method :projections, :children
      end

      class Order < Expression
        def initialize(attributes:, context:)
          super(attributes, context)
        end

        alias_method :qualifiers, :children
      end

      class Limit < Expression
        def initialize(value:, context:)
          super([Value.new(value, parent: self, context: context)], context)
        end

        def limit
          children.first
        end
      end

      class Offset < Expression
        def initialize(value:, context:)
          super([Value.new(value, parent: self, context: context)], context)
        end

        def offset
          children.first
        end
      end

      class ScrollCursor < Expression
        def initialize(value:, context:)
          super([Value.new(value, parent: self, context: context)], context)
        end

        def scroll_cursor
          children.first
        end
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
agnostic_backend-1.0.4 lib/agnostic_backend/queryable/expressions/expression.rb
agnostic_backend-1.0.3 lib/agnostic_backend/queryable/expressions/expression.rb
agnostic_backend-1.0.2 lib/agnostic_backend/queryable/expressions/expression.rb
agnostic_backend-1.0.1 lib/agnostic_backend/queryable/expressions/expression.rb
agnostic_backend-1.0.0 lib/agnostic_backend/queryable/expressions/expression.rb