Sha256: 4bd987b8f694b129aee841f04fd7bce3fa40cd357772d71252b382f9a601260a
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true require 'active_support/core_ext/object/blank' require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/hash/slice' module Bemer class Mixes def initialize(*mixes) @mixes = Array.wrap(mixes).flatten end def to_a @to_a ||= entities.map { |e| [e.bem_class, e.mods] }.flatten.reject(&:blank?).uniq end def to_s @to_s ||= to_a.join(' ') end def entities # rubocop:disable Metrics/MethodLength @entities ||= mixes.flat_map do |mix| if mix.is_a?(Hash) options = mix.extract!(:js, :mods) mix.flat_map do |block, elems| if elems.nil? EntityBuilder.new(block, **options, bem: true) else Array(elems).map { |elem| EntityBuilder.new(block, elem, **options, bem: true) } end end else Array(mix).flat_map { |block| EntityBuilder.new(block) } end end end protected attr_reader :mixes end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bemer-0.6.0 | lib/bemer/mixes.rb |
bemer-0.5.0 | lib/bemer/mixes.rb |
bemer-0.4.0 | lib/bemer/mixes.rb |