theborch / rackspace_lbaas

Libraries for managing Rackspace Cloud Load Balancers with Chef.
Apache License 2.0
0 stars 0 forks source link

Repeated pattern could be factored out #8

Open martinb3 opened 9 years ago

martinb3 commented 9 years ago

This pattern happens a lot in the library:

    def create_node(id = retrieve_lb_id, addr, port)
      return if check_node_exists(id, addr, port)
      begin
        <do something>
      rescue <various errors>
        <log some stuff>
      end
    end

Perhaps you could abstract that out into its own method that accepts a block, and then just pass the various specifics into the more generic method. You'd do this under the hood, still having the end users see the nice method names, but underneath, you'd really have very simple logic.