Sha256: 08738d011d774a443f90ddc5fd96091ea3ed2c9c1d5cdabc8d1bb35a575f4acf

Contents?: true

Size: 611 Bytes

Versions: 17

Compression:

Stored size: 611 Bytes

Contents

module Brightbox
  class FirewallRules
    def self.from_policy(firewall_policy)
      rules = firewall_policy.rules
      rules.map do |rule|
        fwr = FirewallRule.new("fwr")
        fwr.attributes = symbolize_keys(rule)
        fwr
      end
    end

    def self.symbolize_keys(object) # :nodoc:
      modify_keys(object) do |key|
        key.is_a?(String) ? key.to_sym : key
      end
    end

    def self.modify_keys(object, &modifier) # :nodoc:
      object.reduce({}) do |result, (key, value)|
        new_key = modifier.call(key)
        result.merge! new_key => value
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
brightbox-cli-5.0.0.rc2 lib/brightbox-cli/firewall_rules.rb
brightbox-cli-5.0.0.rc1 lib/brightbox-cli/firewall_rules.rb
brightbox-cli-5.0.0.alpha lib/brightbox-cli/firewall_rules.rb
brightbox-cli-4.8.0 lib/brightbox-cli/firewall_rules.rb
brightbox-cli-4.7.0 lib/brightbox-cli/firewall_rules.rb
brightbox-cli-4.6.0 lib/brightbox-cli/firewall_rules.rb
brightbox-cli-4.5.0 lib/brightbox-cli/firewall_rules.rb
brightbox-cli-4.5.0.rc1 lib/brightbox-cli/firewall_rules.rb
brightbox-cli-4.4.0 lib/brightbox-cli/firewall_rules.rb
brightbox-cli-4.3.2 lib/brightbox-cli/firewall_rules.rb
brightbox-cli-4.3.1 lib/brightbox-cli/firewall_rules.rb
brightbox-cli-4.3.0 lib/brightbox-cli/firewall_rules.rb
brightbox-cli-4.2.1 lib/brightbox-cli/firewall_rules.rb
brightbox-cli-4.2.0 lib/brightbox-cli/firewall_rules.rb
brightbox-cli-4.1.0 lib/brightbox-cli/firewall_rules.rb
brightbox-cli-4.0.0 lib/brightbox-cli/firewall_rules.rb
brightbox-cli-4.0.0.rc2 lib/brightbox-cli/firewall_rules.rb