Sha256: bd2377b81af520782e8b0dc4c247a83313aa66915f2a469bf5931a7bb3022b68

Contents?: true

Size: 942 Bytes

Versions: 10

Compression:

Stored size: 942 Bytes

Contents

require 'norikra/error'
require 'norikra/query'

module Norikra
  class SuspendedQuery
    attr_accessor :name, :group, :expression, :targets

    def initialize(query)
      @name = query.name
      @group = query.group
      @expression = query.expression
      @targets = query.targets
    end

    def <=>(other)
      if @group.nil? || other.group.nil?
        if @group.nil? && other.group.nil?
          @name <=> other.name
        else
          @group.to_s <=> other.group.to_s
        end
      else
        if @group == other.group
          self.name <=> other.name
        else
          self.group <=> other.group
        end
      end
    end

    def suspended?
      true
    end

    def to_hash
      {'name' => @name, 'group' => @group, 'expression' => @expression, 'targets' => @targets, 'suspended' => true}
    end

    def create
      Query.new(name: @name, group: @group, expression: @expression)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
norikra-1.5.1-java lib/norikra/suspended_query.rb
norikra-1.5.0-java lib/norikra/suspended_query.rb
norikra-1.4.0-java lib/norikra/suspended_query.rb
norikra-1.3.1-java lib/norikra/suspended_query.rb
norikra-1.3.0-java lib/norikra/suspended_query.rb
norikra-1.3.0.beta.1-java lib/norikra/suspended_query.rb
norikra-1.2.2-java lib/norikra/suspended_query.rb
norikra-1.2.1-java lib/norikra/suspended_query.rb
norikra-1.2.0-java lib/norikra/suspended_query.rb
norikra-1.1.2-java lib/norikra/suspended_query.rb