Module: Bridgetown::Prioritizable::ClassMethods

Defined in:
bridgetown-core/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 'bridgetown-core/lib/bridgetown-core/concerns/prioritizable.rb', line 26

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

#prioritiesObject

Return either this class’ priorities or the superclass which has them (if any)



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

#priorities=(val) ⇒ Object



37
38
39
# File 'bridgetown-core/lib/bridgetown-core/concerns/prioritizable.rb', line 37

def priorities=(val)
  @priorities = val
end

#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 'bridgetown-core/lib/bridgetown-core/concerns/prioritizable.rb', line 16

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