Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: deprecated attributes #21

Open
caspiano opened this issue Jul 7, 2020 · 2 comments
Open

feat: deprecated attributes #21

caspiano opened this issue Jul 7, 2020 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@caspiano
Copy link
Contributor

caspiano commented Jul 7, 2020

add a default false deprecated option to attribute.
access to a deprecated field will be logged as a warning.

class Model < ActiveModel::Model
  attribute shiver_me_timbers : String?
  attribute shine_my_timbs : String?, deprecated: true
end

Model.new.shine_my_timbs
# => WARN source=active-model message=deprecated field `shine_my_timbs` accessed
@caspiano caspiano added enhancement New feature or request good first issue Good for newcomers labels Jul 7, 2020
@kimburgess
Copy link
Contributor

An alternative to the additional arg is using the deprecated annotation from stdlib. This looks to be safe to use here - when the marco expands it will associated with the instance var so won’t fill compiler warning with garbage. The advantage of this is it keeps the same semantics as deprecating other functionality.

@caspiano
Copy link
Contributor Author

caspiano commented Jul 7, 2020

Logging access at runtime if the annotation is present seems easy enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants