Class: Sanford::Hosts
- Inherits:
-
Object
show all
- Defined in:
- lib/sanford.rb
Instance Method Summary
collapse
Constructor Details
#initialize(values = []) ⇒ Hosts
Returns a new instance of Hosts.
47
48
49
|
# File 'lib/sanford.rb', line 47
def initialize(values = [])
@set = Set.new(values)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
65
66
67
|
# File 'lib/sanford.rb', line 65
def method_missing(method, *args, &block)
@set.send(method, *args, &block)
end
|
Instance Method Details
#find(name) ⇒ Object
We want class names to take precedence over a configured name, so that if a user specifies a specific class, they always get it
53
54
55
|
# File 'lib/sanford.rb', line 53
def find(name)
self.find_by_class_name(name) || self.find_by_name(name)
end
|
#find_by_class_name(class_name) ⇒ Object
57
58
59
|
# File 'lib/sanford.rb', line 57
def find_by_class_name(class_name)
@set.detect{|host_class| host_class.to_s == class_name.to_s }
end
|
#find_by_name(name) ⇒ Object
61
62
63
|
# File 'lib/sanford.rb', line 61
def find_by_name(name)
@set.detect{|host_class| host_class.name == name.to_s }
end
|
#respond_to?(method) ⇒ Boolean
69
70
71
|
# File 'lib/sanford.rb', line 69
def respond_to?(method)
super || @set.respond_to?(method)
end
|