How do I remove the warning warning: delegator does not forward private method #to_ary
?
Following is a code snippet for recreating the problem with the given technologies:
class Foo < ActiveRecord::Base
def name
"foobar"
end
end
class FooDelegator < SimpleDelegator
def name
"name"
end
end
pry(main)> [FooDelegator.new(Foo.new)].flatten
(pry):12: warning: delegator does not forward private method #to_ary
=> [#<Foo:0x00007f3fa3b1ebf0 id: nil, created_at: nil, updated_at: nil>]
EDIT: This issue was also posted on Github because I figured that it actually belongs to ActiveRecord (rails).
Use public :to_ary
in the ActiveRecord class to convert the private method to public:
class Foo < ActiveRecord::Base
def name
"foobar"
end
public :to_ary
end
class FooDelegator < SimpleDelegator
def name
"name"
end
end