lib/seymour/distributable.rb in seymour-0.0.8 vs lib/seymour/distributable.rb in seymour-0.0.9
- old
+ new
@@ -45,10 +45,11 @@
[].tap do |feeds|
audience_mappings.each do |audience_name, mapping|
feed_classes, options = mapping
[feed_classes].flatten.each do |feed_class_name|
try_find_each(activity.send(audience_name), options) do |member|
+
feed = feed_class_name.constantize.new(member)
yield feed if block_given?
feeds << feed
end
end
@@ -67,31 +68,32 @@
# TODO support exclusive scope
# activity_audience.find_each(options) do
# relation.send(:with_exclusive_scope) &block
# end
activity_audience.find_each(options, &block)
- else
+ elsif activity_audience.respond_to?(:each)
activity_audience.each &block
+ elsif !activity_audience.nil?
+ yield activity_audience
end
end
end
- module InstanceMethods
+ # instance methods
- def distribute
- self.class.distribute(self)
- end
+ def distribute
+ self.class.distribute(self)
+ end
- def remove
- self.class.remove(self)
- end
+ def remove
+ self.class.remove(self)
+ end
- def feeds
- self.class.feeds_for(self)
- end
-
+ def feeds
+ self.class.feeds_for(self)
end
+
end
end