lib/hibachi/querying.rb in hibachi-0.0.1.pre vs lib/hibachi/querying.rb in hibachi-0.0.1
- old
+ new
@@ -1,7 +1,9 @@
module Hibachi
module Querying
+ include Enumerable
+
# Write the given attrs to config and re-run Chef.
def create from_attributes={}
model = new from_attributes
model.save
model
@@ -9,9 +11,13 @@
# Find everything from the JSON.
def all
return fetch if singleton?
node[recipe_name].map { |from_params| new from_params }
+ end
+
+ def each
+ all.each { |model| yield model }
end
# Find all objects of this type matching the given search
# criteria. Uses the all() method to scope calls from within the
# proper JSON for this class, and instantiates objects based on