Sha256: 2de35fb24c1e2d3ab168ccc27ed4431c89f9928030ff6427258a16f251d83362

Contents?: true

Size: 945 Bytes

Versions: 10

Compression:

Stored size: 945 Bytes

Contents

module Rake
  module Funnel
    module Support
      module ArgumentMapper
        module Styles
          class Default
            attr_reader :prefix, :value_separator

            def initialize
              @prefix = '/'
              @value_separator = ','
            end

            def generate_from(model)
              model.map do |switch|
                switch.values.flatten.map do |value|
                  [top_level(switch), nested(value)].reject(&:empty?)
                end
              end.flatten(2)
            end

            private

            def top_level(switch)
              [prefix, switch.switch]
            end

            def nested(value)
              res = []
              res << value.key
              res << value_separator unless value.key.nil? || value.value.nil?
              res << value.value
              res.compact
            end
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rake-funnel-0.22.2 lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.22.1 lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.22.0 lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.21.2 lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.21.1 lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.21.0 lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.20.2 lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.20.1 lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.20.0 lib/rake/funnel/support/argument_mapper/styles/default.rb
rake-funnel-0.19.0 lib/rake/funnel/support/argument_mapper/styles/default.rb