Class: WhiskeyDisk::Config::HashifyDomainEntriesFilter

Inherits:
AbstractFilter
  • Object
show all
Defined in:
lib/whiskey_disk/config/filters/hashify_domain_entries_filter.rb

Instance Attribute Summary

Attributes inherited from AbstractFilter

#config

Instance Method Summary collapse

Methods inherited from AbstractFilter

#environment_name, #initialize, #project_name

Constructor Details

This class inherits a constructor from WhiskeyDisk::Config::AbstractFilter

Instance Method Details

#filter(data) ⇒ Object



23
24
25
# File 'lib/whiskey_disk/config/filters/hashify_domain_entries_filter.rb', line 23

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

#hashify_domain(domain) ⇒ Object



10
11
12
# File 'lib/whiskey_disk/config/filters/hashify_domain_entries_filter.rb', line 10

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

#hashify_domains(domain_list) ⇒ Object



18
19
20
21
# File 'lib/whiskey_disk/config/filters/hashify_domain_entries_filter.rb', line 18

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

#needs_hashing?(domain) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/whiskey_disk/config/filters/hashify_domain_entries_filter.rb', line 6

def needs_hashing?(domain)
  ! domain.respond_to?(:keys)
end

#new_domainObject



14
15
16
# File 'lib/whiskey_disk/config/filters/hashify_domain_entries_filter.rb', line 14

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