lib/pears.rb in pears-0.3.0 vs lib/pears.rb in pears-0.3.1
- old
+ new
@@ -14,17 +14,17 @@
def self.subjects
@subjects ||= []
end
# This is the main way of locating a subject.
- def self.subject(name)
+ def self.subject(name, &block)
if subjects.any? { |sub| sub.name == name }
raise Pears::Error.new("subject name #{name} is already in use.")
end
- Subject.new(name).tap do |subject|
- builder = Provider::Builder.new(subject)
- yield(builder)
- @subjects.push subject
- end
+ Subject.new(name, loader: block).tap { |sub| @subjects.push sub }
+ end
+
+ def self.[](name)
+ subjects.find { |subject| subject.name == name }
end
end