Sha256: ab0976f4029a350f02e9408accfd75c1fe723167cf09a39f257bef412d325ff2
Contents?: true
Size: 769 Bytes
Versions: 2
Compression:
Stored size: 769 Bytes
Contents
require 'set' require 'sanford/host' module Sanford class Hosts def initialize(values = []) @set = Set.new(values) end def method_missing(method, *args, &block) @set.send(method, *args, &block) end def respond_to?(method) super || @set.respond_to?(method) end # We want class names to take precedence over a configured name, so that if # a user specifies a specific class, they always get it def find(name) find_by_class_name(name) || find_by_name(name) end private def find_by_class_name(class_name) @set.detect{|host_class| host_class.to_s == class_name.to_s } end def find_by_name(name) @set.detect{|host_class| host_class.name == name.to_s } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sanford-0.10.1 | lib/sanford/hosts.rb |
sanford-0.10.0 | lib/sanford/hosts.rb |