call

in lib/primer/classify.rb [44:102]


      def call(args = {})
        style = nil
        classes = [].tap do |result|
          args.each do |key, val|
            case key
            when :classes
              
              if (class_names = validated_class_names(val))
                result.unshift(class_names)
              end
              next
            when :style
              style = val
              next
            end

            next unless LOOKUP[key]

            if val.is_a?(Array)
              
              brk = 0
              while brk < val.size
                item = val[brk]

                if item.nil?
                  brk += 1
                  next
                end

                
                
                
                
                
                found = (LOOKUP[key][item][brk] rescue nil) || validate(key, item, brk)
                
                result << found if found
                brk += 1
              end
            else
              next if val.nil?

              
              found = (LOOKUP[key][val][0] rescue nil) || validate(key, val, 0)
              
              result << found if found
            end
          end
        end.join(" ")

        
        
        {
          class: !classes || classes.empty? ? nil : classes,
          style: !style || style.empty? ? nil : style
        }
        
      end