OSA::ObjectSpecifierList#every
-
For those of you who aren’t yet on the RubyOSA list (you should be), Laurent just committed a nice new feature to
OSA::ObjectSpecifierList. It’s actually been there since last week, in the form of somemethod_missinghackery, but we finally decided to take that out and call it#every.Sometimes you need to collect an attribute from every object in the specifier list. Normally, you’d do something like this:
names = OSA.app('iCal').calendars.collect { |c| c.name }Symbol#to_proc fans use the convenient form:
names = OSA.app('iCal').calendars.collect(&:name)Now,
OSA::ObjectSpecifierListalso has the#everymethod:names = OSA.app('iCal').calendars.every(:name)The difference is subtle but
#everywill fetch all of the attributes in a single Apple Event, something not possible when iterating over each item in the collection. For most purposes this is not important but it is a nice feature that could make a difference on larger collections.This feature is currently in the RubyOSA trunk and will appear in the next stable release (coming soon).
Update: RubyOSA 4.0 has been released and includes this feature!
