Class: Axiom::Relation::Operation::Sorted::Direction
- Inherits:
-
Object
- Object
- Axiom::Relation::Operation::Sorted::Direction
- Extended by:
- Aliasable
- Includes:
- AbstractType
- Defined in:
- lib/axiom/relation/operation/sorted/direction.rb
Overview
Abstract base class for attribute sorting
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attribute ⇒ Attribute
readonly
private
The attribute to sort on.
Class Method Summary collapse
-
.coerce(object) ⇒ Direction
private
Coerce an object into a Direction.
Instance Method Summary collapse
-
#call(left, right) ⇒ -1, ...
Compare the left and right Tuple attribute values.
-
#initialize(attribute) ⇒ undefined
constructor
private
Initialize a Direction.
-
#name ⇒ Symbol
Return the attribute name.
-
#rename(aliases) ⇒ self, Direction
Rename the contained attribute with the provided aliases.
-
#reverse ⇒ Direction
Return the reverse Direction.
Methods included from Aliasable
Constructor Details
#initialize(attribute) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a Direction
31 32 33 |
# File 'lib/axiom/relation/operation/sorted/direction.rb', line 31 def initialize(attribute) @attribute = attribute end |
Instance Attribute Details
#attribute ⇒ Attribute (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The attribute to sort on
21 22 23 |
# File 'lib/axiom/relation/operation/sorted/direction.rb', line 21 def attribute @attribute end |
Class Method Details
.coerce(object) ⇒ Direction
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Coerce an object into a Direction
108 109 110 |
# File 'lib/axiom/relation/operation/sorted/direction.rb', line 108 def self.coerce(object) object.kind_of?(Direction) ? object : new(Attribute.coerce(object)) end |
Instance Method Details
#call(left, right) ⇒ -1, ...
Compare the left and right Tuple attribute values
65 66 67 |
# File 'lib/axiom/relation/operation/sorted/direction.rb', line 65 def call(left, right) self.class.call(attribute.call(left), attribute.call(right)) end |
#name ⇒ Symbol
Return the attribute name
43 44 45 |
# File 'lib/axiom/relation/operation/sorted/direction.rb', line 43 def name attribute.name end |
#rename(aliases) ⇒ self, Direction
Rename the contained attribute with the provided aliases
83 84 85 86 |
# File 'lib/axiom/relation/operation/sorted/direction.rb', line 83 def rename(aliases) renamed = aliases[attribute] renamed.equal?(attribute) ? self : self.class.new(renamed) end |
#reverse ⇒ Direction
Return the reverse Direction
96 97 98 |
# File 'lib/axiom/relation/operation/sorted/direction.rb', line 96 def reverse self.class.reverse.new(attribute) end |