lib/brightbox-cli/cloud_ips.rb in brightbox-cli-1.1.0 vs lib/brightbox-cli/cloud_ips.rb in brightbox-cli-1.2.0

- old
+ new

@@ -1,9 +1,10 @@ module Brightbox class CloudIP < Api def self.require_account?; true; end - def self.get id + + def self.get(id) conn.cloud_ips.get id end def self.all conn.cloud_ips @@ -22,25 +23,19 @@ new(r["id"]) end def self.format_translators_for_api(translators) translators.split(",").map do |t| - incoming,outgoing,protocol = t.split(":") + incoming, outgoing, protocol = t.split(":") raise "translator #{t} is invalid" if incoming.nil? || outgoing.nil? || protocol.nil? - {:incoming => incoming, :outgoing => outgoing, :protocol => protocol} + { :incoming => incoming, :outgoing => outgoing, :protocol => protocol } end end def attributes a = fog_model.attributes - if(lb_id = a[:load_balancer] || a["load_balancer"]) - a[:destination] = lb_id - elsif(server_group_id = a[:server_group] || a["server_group"]) - a[:destination] = server_group - else - a[:destination] = a[:server_id] - end + a[:destination] = destination_id a end def to_row o = attributes @@ -52,22 +47,24 @@ status == 'mapped' end def translators(raw_attributes) if translators = (raw_attributes[:port_translators] || raw_attributes['port_translators']) - translators.map {|t| [t['incoming'],t['outgoing'],t['protocol']].join(":") } + translators.map do |t| + [t['incoming'], t['outgoing'], t['protocol']].join(":") + end else nil end end def self.default_field_order [:id, :status, :public_ip, :destination, :reverse_dns, :name] end - def <=>(b) - self.status <=> b.status + def <=>(other) + status <=> other.status end def update(options) params = {} if options[:r] @@ -85,11 +82,10 @@ if options[:t] params[:port_translators] = CloudIP.format_translators_for_api(options[:t]) end self.class.conn.update_cloud_ip(id, params) - self.reload + reload self end - end end