Module: Bridgetown::Prioritizable::ClassMethods

Defined in:
lib/bridgetown-core/concerns/prioritizable.rb

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Integer

Spaceship is priority [higher -> lower]

Parameters:

  • other (Class)

    The class to be compared.

Returns:

  • (Integer)

    -1, 0, 1.



26
27
28
# File 'lib/bridgetown-core/concerns/prioritizable.rb', line 26

def <=>(other)
  priorities[other.priority] <=> priorities[priority]
end

#prioritiesHash<Symbol, Object>

Returns:

  • (Hash<Symbol, Object>)


# File 'lib/bridgetown-core/concerns/prioritizable.rb', line 6

#priority(priority = nil) ⇒ Symbol

Get or set the priority of this class. When called without an argument it returns the priority. When an argument is given, it will set the priority.

Parameters:

  • priority (Symbol) (defaults to: nil)

    new priority (optional) Valid options are: :lowest, :low, :normal, :high, :highest

Returns:

  • (Symbol)


16
17
18
19
20
# File 'lib/bridgetown-core/concerns/prioritizable.rb', line 16

def priority(priority = nil)
  @priority ||= nil
  @priority = priority if priority && priorities.key?(priority)
  @priority || :normal
end