Class: WhiskeyDisk::Config::DropEmptyDomainRolesFilter
- Inherits:
-
AbstractFilter
show all
- Defined in:
- lib/whiskey_disk/config/filters/drop_empty_domain_roles_filter.rb
Instance Attribute Summary
#config
Instance Method Summary
collapse
#environment_name, #initialize, #project_name
Instance Method Details
#drop_empty_domain_roles(domains_list) ⇒ Object
22
23
24
|
# File 'lib/whiskey_disk/config/filters/drop_empty_domain_roles_filter.rb', line 22
def drop_empty_domain_roles(domains_list)
domains_list.collect { |domain| drop_empty_roles_for_domain(domain) }
end
|
#drop_empty_roles_for_domain(domain) ⇒ Object
17
18
19
20
|
# File 'lib/whiskey_disk/config/filters/drop_empty_domain_roles_filter.rb', line 17
def drop_empty_roles_for_domain(domain)
return domain unless has_empty_role?(domain)
domain.reject {|key, value| key == 'roles' }
end
|
#filter(data) ⇒ Object
26
27
28
|
# File 'lib/whiskey_disk/config/filters/drop_empty_domain_roles_filter.rb', line 26
def filter(data)
data.merge('domain' => drop_empty_domain_roles(data['domain']))
end
|
#has_empty_role?(domain) ⇒ Boolean
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/whiskey_disk/config/filters/drop_empty_domain_roles_filter.rb', line 6
def has_empty_role?(domain)
return true unless domain.has_key?('roles')
return true if domain['roles'].nil?
roles = domain['roles'].uniq.compact
return true if roles == [ '' ]
return true if roles == []
false
end
|