Sha256: 893cd0ff1ccdf662b8439b3a634b1780dbfcf3cdc2b3cf238c6e582189ad9f3d

Contents?: true

Size: 664 Bytes

Versions: 4

Compression:

Stored size: 664 Bytes

Contents

require 'whiskey_disk/config/abstract_filter'

class WhiskeyDisk
  class Config
    class HashifyDomainEntriesFilter < AbstractFilter
      def needs_hashing?(domain)
        ! domain.respond_to?(:keys)
      end

      def hashify_domain(domain)
        needs_hashing?(domain) ? { 'name' => domain } : domain
      end

      def new_domain
        { 'name' => '' }
      end

      def hashify_domains(domain_list)
        return new_domain unless domain_list
        [ domain_list ].flatten.collect {|domain| hashify_domain(domain) }
      end

      def filter(data)
        data.merge('domain' => hashify_domains(data['domain']))
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
ol-whisk_deploy-0.6.25 lib/whiskey_disk/config/filters/hashify_domain_entries_filter.rb
ol-whisk_deploy-0.6.26 lib/whiskey_disk/config/filters/hashify_domain_entries_filter.rb
whisk_deploy-0.6.26 lib/whiskey_disk/config/filters/hashify_domain_entries_filter.rb
whiskey_disk-0.6.24 lib/whiskey_disk/config/filters/hashify_domain_entries_filter.rb