class NoSE::Plans::LimitPlanStep

Limit results from a previous lookup This should only ever occur at the end of a plan

Attributes

limit[R]

Public Class Methods

apply(_parent, state) click to toggle source

Check if we can apply a limit @return [LimitPlanStep]

# File lib/nose/plans/limit.rb, line 31
def self.apply(_parent, state)
  # TODO: Apply if have IDs of the last entity set
  #       with no filter/sort needed

  return nil if state.query.limit.nil?
  return nil unless state.answered? check_limit: false

  LimitPlanStep.new state.query.limit, state
end
new(limit, state = nil) click to toggle source
Calls superclass method NoSE::Plans::PlanStep::new
# File lib/nose/plans/limit.rb, line 10
def initialize(limit, state = nil)
  super()
  @limit = limit

  return if state.nil?
  @state = state.dup
  @state.cardinality = @limit
end

Public Instance Methods

==(other) click to toggle source

Two limit steps are equal if they have the same value for the limit

# File lib/nose/plans/limit.rb, line 20
def ==(other)
  other.instance_of?(self.class) && @limit == other.limit
end
Also aliased as: eql?
eql?(other)
Alias for: ==
hash() click to toggle source
# File lib/nose/plans/limit.rb, line 25
def hash
  @limit
end