lib/open_charities/response.rb
# convert the top-level keys in the returned JSON to singleton methods on
# the instance
# NOTE: this *only* converts keys that are in the top-level.
# for example, instance.address returns a hash, but title returns a string
convert the top-level keys in the returned JSON to singleton methods on
the instance
NOTE: this *only* converts keys that are in the top-level.
for example, instance.address returns a hash, but title returns a string
convert the top - level keys in the returned JSON to singleton methods on the instance NOTE : this * only * converts keys that are in the top - level . for example instance . address returns a hash but title returns a string
def generate_convenience_methods
      @attributes.each_pair do |k, v|
        define_singleton_method(k) { v }
      end
    end
def generate_convenience_methods @attributes . each_pair do | k , v | define_singleton_method ( k ) { v } end end
convert the top-level keys in the returned JSON to singleton methods on
the instance
NOTE: this *only* converts keys that are in the top-level.
convert the top - level keys in the returned JSON to singleton methods on the instance NOTE : this * only * converts keys that are in the top - level .