Sha256: bba2c261c0ed6f3b7ef0f6055336ed6ba7f40e756f6499ba2c7cf5ae2202e53a

Contents?: true

Size: 656 Bytes

Versions: 5

Compression:

Stored size: 656 Bytes

Contents

# frozen_string_literal: true

class Tramway::Landing::NavbarDecorator < ::Tramway::ApplicationDecoratedCollection
  def initialize(array)
    original = if array.any? { |obj| obj.is_a? Hash }
                 get_original_array array
               else
                 array
               end
    super array, original
  end

  def original_array
    get_original_array @original_array
  end

  def dropdown_title
    object.keys.first
  end

  private

  def get_original_array(arr)
    arr.reduce([]) do |array, obj|
      if obj.is_a? Hash
        array += obj.values.first.original_array
      else
        array << obj
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tramway-landing-3.3.0.11 app/decorators/tramway/landing/navbar_decorator.rb
tramway-landing-3.3.0.10 app/decorators/tramway/landing/navbar_decorator.rb
tramway-landing-3.3.0.9 app/decorators/tramway/landing/navbar_decorator.rb
tramway-landing-3.3.0.8 app/decorators/tramway/landing/navbar_decorator.rb
tramway-landing-3.3.0.7 app/decorators/tramway/landing/navbar_decorator.rb