Class: Priora::PriorityBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/priora/priority_builder.rb

Class Method Summary collapse

Class Method Details

.build(raw_priority) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/priora/priority_builder.rb', line 6

def build(raw_priority)
  case raw_priority
  when Symbol
    Priority.new(attribute: raw_priority)
  when Array
    priority_hash = raw_priority.reduce(:merge)
    build_from_hash(priority_hash)
  when Hash
    build_from_hash(raw_priority)
  else
    raise InvalidPrioritySyntaxError
  end
rescue StandardError
  raise InvalidPrioritySyntaxError
end