Reasonable ActiveSupport dependency and define_method usage? I'm writing a results wrapper for a gem which wraps a Thesaurus API. Basically, when you lookup a word in the thesaurus, the results come back in approximately this JSON form:

{
  'noun' =&gt; {
    'syn' =&gt; ['array', 'of', 'synonyms'],
    'rel' =&gt; ['array', 'of', 'related terms']
   },
   'verb' =&gt; {
     'syn' =&gt; ['synonyms', 'of', 'verb', 'word form'],
     'ant' =&gt; ['antonyms', 'of', 'word']
   }
}


I would like to be able to access the results in the following ways:


Get an array of synonyms across all parts of speech. eg.

results.synonyms
# =&gt; ['array', 'of', 'synonyms', 'synonyms', 'of', 'verb', 'word form']

Indifferently (writing results['noun'] all the time is a PITA):

results[:noun]



Here is my code and questions:


Is it acceptable to create a dependance on ActiveSupport just so I can access the results indifferently, or should I just suck it up? THe only other AR method I'm using in the gem is blank?.
Is the usage of define_method too magical? Should I just define the convenience methods normally instead?

require "active_support/core_ext/hash/indifferent_access"

module Dinosaurus
  class Results &lt; HashWithIndifferentAccess

    def initialize(data = {})
      super(data)
    end

    # Define some convenience methods.
    { 'synonyms' =&gt; :syn,
      'antonyms' =&gt; :ant,
      'similar_terms' =&gt; :sim,
      'related_terms' =&gt; :rel 
    }.each do |name, key|
      define_method name do
        grouped(key)
      end
    end

  private

    def grouped(key)
      group = []
      self.each do |pos, type|
        group += type[key] if type[key]
      end
      group
    end
  end
end
1) I believe that depending on popular and stable libraries is not a problem. Though I prefer more opinionated approach: to symbolize_keys!.

2) You define_method looks clear enough, IMHO 

3) You may simplify grouped like this:

def grouped_by(key)
  self.values.flat_map { |type| type[key] }.compact!
end