anima icon indicating copy to clipboard operation
anima copied to clipboard

Anima breaks on `#with` and `#to_h` if an attribute is private or protected

Open backus opened this issue 9 years ago • 1 comments

require 'anima'

Anima::VERSION # => "0.4.2"

class Dog
  include Anima.new(:name, :age, :breed)

  private :breed
end

spot = Dog.new(name: 'Spot', age: 5, breed: 'Dalmatian')
spot                # => #<Dog name="Spot" age=5 breed="Dalmatian">
spot.with(age: 6)   # => private method `breed' called for #<Dog name="Spot" age=5 breed="Dalmatian"> (NoMethodError)
spot.to_h           # => private method `breed' called for #<Dog name="Spot" age=5 breed="Dalmatian"> (NoMethodError)

backus avatar Jul 19 '16 21:07 backus

@mbj I would be happy to PR a fix for this if you would agree this should be fixed. I realize you eventually want protected by default like in #24 but I would consider fixing this an incremental improvement.

backus avatar Jul 19 '16 21:07 backus