Sha256: 6f7f3e480b97ce5925b8312b6412d15b7b7aea98bbf1e7ace1edb01267d028f5

Contents?: true

Size: 454 Bytes

Versions: 4

Compression:

Stored size: 454 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|
              flattened["#{key}-#{k}"] = v if v
            end
          else
            flattened[key] = value if value
          end
        end
        flattened
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hamlit-0.3.0 lib/hamlit/concerns/attribute_builder.rb
hamlit-0.2.0 lib/hamlit/concerns/attribute_builder.rb
hamlit-0.1.3 lib/hamlit/concerns/attribute_builder.rb
hamlit-0.1.2 lib/hamlit/concerns/attribute_builder.rb