DmitryTsepelev / store_model

Work with JSON-backed attributes as ActiveRecord-ish models
MIT License
1.04k stars 85 forks source link

Delegation of `fetch` to `attributes` causes issues #129

Closed danielvdao closed 1 year ago

danielvdao commented 2 years ago

Context

When using fetch on the model - the model can result in unexpected responses. Take for example:

class Configuration
  include StoreModel::Model

  attribute :id
end

example = Configuration.new
puts example.id # nil
puts example.fetch(:id) # KeyError: key not found: :id

I have a PR here: https://github.com/DmitryTsepelev/store_model/pull/128 to continue the discussion! 🙏🏽

danielvdao commented 1 year ago

Hey @DmitryTsepelev would it make sense to close this issue? I'm not sure what to do, and I assume maybe you're busy and haven't kept up with the PR or think the current way fetch works makes sense. Let me know 👍🏽

DmitryTsepelev commented 1 year ago

Sounds good, will close for now 🙂