Sha256: 552f8cc1e59fea730461b75e821b111b277ff98fb1bc25a196a8196dd3357f84

Contents?: true

Size: 494 Bytes

Versions: 49

Compression:

Stored size: 494 Bytes

Contents

module Hamlit
  module Concerns
    module AttributeBuilder
      def flatten_attributes(attributes)
        flattened = {}

        attributes.each do |key, value|
          case value
          when Hash
            flatten_attributes(value).each do |k, v|
              k = k.to_s.gsub(/_/, '-')
              flattened["#{key}-#{k}"] = v if v
            end
          else
            flattened[key] = value if value
          end
        end
        flattened
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
hamlit-1.7.2 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.7.1 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.7.0 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.6.7 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.6.6 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.6.5 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.6.4 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.6.3 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.6.2 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.6.1 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.6.0 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.5.9 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.5.8 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.5.7 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.5.6 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.5.5 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.5.4 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.5.3 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.5.2 lib/hamlit/concerns/attribute_builder.rb
hamlit-1.5.1 lib/hamlit/concerns/attribute_builder.rb