Class: NoSE::Plans::LimitPlanStep
- Defined in:
- lib/nose/plans/limit.rb
Overview
Limit results from a previous lookup This should only ever occur at the end of a plan
Instance Attribute Summary collapse
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
Attributes inherited from PlanStep
#children, #cost, #fields, #parent, #state
Class Method Summary collapse
-
.apply(_parent, state) ⇒ LimitPlanStep
Check if we can apply a limit.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Two limit steps are equal if they have the same value for the limit.
- #hash ⇒ Object
-
#initialize(limit, state = nil) ⇒ LimitPlanStep
constructor
A new instance of LimitPlanStep.
Methods inherited from PlanStep
#add_fields_from_index, #calculate_cost, inherited, #parent_index, #parent_steps, #to_color
Methods included from Supertype
Constructor Details
#initialize(limit, state = nil) ⇒ LimitPlanStep
Returns a new instance of LimitPlanStep.
10 11 12 13 14 15 16 17 |
# 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 |
Instance Attribute Details
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
8 9 10 |
# File 'lib/nose/plans/limit.rb', line 8 def limit @limit end |
Class Method Details
.apply(_parent, state) ⇒ LimitPlanStep
Check if we can apply a limit
31 32 33 34 35 36 37 38 39 |
# 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 |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Two limit steps are equal if they have the same value for the limit
20 21 22 |
# File 'lib/nose/plans/limit.rb', line 20 def ==(other) other.instance_of?(self.class) && @limit == other.limit end |
#hash ⇒ Object
25 26 27 |
# File 'lib/nose/plans/limit.rb', line 25 def hash @limit end |