Class: Unbind::View
- Inherits:
-
Object
- Object
- Unbind::View
- Defined in:
- lib/unbind/view.rb
Class Method Summary collapse
Instance Method Summary collapse
- #clients ⇒ Object
-
#initialize(name, config) ⇒ View
constructor
A new instance of View.
- #master ⇒ Object
- #slave ⇒ Object
Constructor Details
#initialize(name, config) ⇒ View
Returns a new instance of View.
13 14 15 16 17 18 19 20 21 |
# File 'lib/unbind/view.rb', line 13 def initialize name, config raise "view must have a name" unless name.is_a?(String) && 0 < name.length raise "config should include clients and zones lists" unless config.is_a?(Hash) && [:clients, :zones].all? { |k| config.has_key?(k) && config[k].is_a?(Array) } @name = name @clients = config[:clients] @zones = config[:zones] end |
Class Method Details
.expand_countries(clients) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/unbind/view.rb', line 3 def self. clients clients.flat_map { |i| if i.is_a?(Hash) && i.has_key?("countries") i["countries"].map { |c| "country_#{c.upcase}" } else i end } end |
Instance Method Details
#clients ⇒ Object
31 32 33 |
# File 'lib/unbind/view.rb', line 31 def clients self.class.(@clients) end |
#master ⇒ Object
27 28 29 |
# File 'lib/unbind/view.rb', line 27 def master ["view \"#{@name}\" {", match_clients, servers, view_settings(:master), zones(:master), "};\n"].join("\n") end |
#slave ⇒ Object
23 24 25 |
# File 'lib/unbind/view.rb', line 23 def slave ["view \"#{@name}\" {", match_clients, zones(:slave), "};\n"].join("\n") end |