Sha256: 48e91824a4c921101eac975412ea23f9dd1e24ee0996e6973c426e08796b983b
Contents?: true
Size: 925 Bytes
Versions: 1
Compression:
Stored size: 925 Bytes
Contents
require_relative 'priority' module Priora class PriorityBuilder class << self 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 => e raise InvalidPrioritySyntaxError end private def build_from_hash(priority_hash) unless priority_hash.one? raise InvalidPrioritySyntaxError, 'directional priority declaration takes only a single priority at a time!' end attribute = priority_hash.keys.first direction = priority_hash[attribute] Priority.new(attribute: attribute, direction: direction) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
priora-0.1.0 | lib/priora/priority_builder.rb |