active-hash / active_hash

A readonly ActiveRecord-esque base class that lets you use a hash, a Yaml file or a custom file as the datasource
MIT License
1.19k stars 178 forks source link

ActiveHash::Relation can not use respond_to? method #289

Closed yleek closed 11 months ago

yleek commented 11 months ago

Hi!

system: Rails: 6.1.4 Ruby: 3.0.6

active_hash: old: 3.1.1 new: 3.2.0

I upgrade to 3.2.0 from 3.1.1. I find that ActiveHash::Relation can not use respond_to? method. An error occurs when using this method. version 3.1.1 is not occurs this error.

class Country < ActiveHash::Base
  Country.data = [
    { :id => 1, :name => "US" },
    { :id => 2, :name => "Canada" }
  ]
end

> Country.all.class
=> ActiveHash::Relation

v3.2.0
> Country.all.respond_to?(:dummy_method)
NoMethodError: undefined method `key?' for nil:NilClass
from /app/vendor/bundle/ruby/3.0.0/gems/active_hash-3.2.0/lib/active_hash/relation.rb:173:in `respond_to_missing?'

v3.1.1
> Country.all.respond_to?(:dummy_method)
=> false

Is this a bug? please check it.

iberianpig commented 11 months ago

This issue has been fixed and merged at https://github.com/active-hash/active_hash/pull/286, but has not been released to Rubygems.

Use gem "active_hash", github: "active-hash/active_hash", commit: "master" in the Gemfile to get around this.

yleek commented 11 months ago

Thank you for your comment. I confirm that respond_to? method can use at master branch. This issue is closed.

flavorjones commented 11 months ago

v3.2.1 should be out soon, see https://github.com/active-hash/active_hash/pull/290