I have a suggestion for some attribute helpers when creating custom tag defs:
attributes_declared and attributes_not_declared inside of a tag definition. I don't really understand why the current attributes provides attributes not declared by the tag? Why must I do something like: all_attributes & attributes[:tag] ? Is there an easy way to filter these attributes, such as: all_attributes & [:a, :b] to only get the attributes with values for a and b? Kris On Sep 8, 11:54 am, Tom Locke <[email protected]> wrote: > Yep I don't see why not : ) > > Just committed > > Tom > > On 30 Aug 2009, at 03:15, Scott Bronson wrote: > > > What do you guys think of passing a hash to build_hash and > > map_hash? That way I can do this: > > > hash = HashWithIndifferentAccess.new > > str.build_hash(hash) { |s| s.split(/\s*=\s*/) } > > > or this: > > > hash = {} > > complexfunc do |a| > > # keep adding items to the existing hash > > a.build_hash(hash) { |n| [n.id, n] } > > end > > > Trivial patch below, happy to apply if it's thought a good idea. > > > - Scott > > > diff --git a/vendor/plugins/hobo/hobosupport/lib/hobo_support/ > > enumerable.rb b/ve > > index cc0f0e5..7098059 100644 > > --- a/vendor/plugins/hobo/hobosupport/lib/hobo_support/enumerable.rb > > +++ b/vendor/plugins/hobo/hobosupport/lib/hobo_support/enumerable.rb > > @@ -8,14 +8,12 @@ module Enumerable > > not_found > > end > > > - def map_with_index > > - res = [] > > + def map_with_index(res = []) > > each_with_index {|x, i| res << yield(x, i)} > > res > > end > > > - def build_hash > > - res = {} > > + def build_hash(res = {}) > > each do |x| > > pair = block_given? ? yield(x) : x > > res[pair.first] = pair.last if pair > > @@ -23,8 +21,7 @@ module Enumerable > > res > > end > > > - def map_hash > > - res = {} > > + def map_hash(res = {}) > > each do |x| > > v = yield x > > res[x] = v > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/hobousers?hl=en -~----------~----~----~----~------~----~------~--~---
