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

Enum Bang setter #82

Merged
merged 3 commits into from
Apr 25, 2022
Merged

Enum Bang setter #82

merged 3 commits into from
Apr 25, 2022

Conversation

dkam
Copy link
Contributor

@dkam dkam commented Mar 31, 2022

Add a bang method to set enums. This makes it function a bit more like the rails enums.

README.md Outdated
@@ -109,8 +109,8 @@ enum = Kredis.enum "myenum", values: %w[ one two three ], default: "one"
true == enum.one? # => GET myenum
enum.value = "two" # => SET myenum "two"
"two" == enum.value # => GET myenum
enum.value = "four"
"two" == enum.value # => GET myenum
enum.four! # => SET myenum "four"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense that you can set the enum to a value which is not available in the values array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Thanks for the feedback. Updated the example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. It's not a very nice exception when you try setting an invalid value.

@jeremy jeremy merged commit 6abb2b2 into rails:main Apr 25, 2022
lewispb added a commit to lewispb/kredis that referenced this pull request May 2, 2022
* main:
  Bump version for 1.2.0
  Use pipeline for migration too
  Ensure to pass the pipeline to super
  Use block parameter to pipeline in Redis#multi (rails#68)
  Note tested / supported versions of Redis in the Readme (rails#79)
  Return counter value after incrementing/decrementing
  Enum Bang setter (rails#82)
  Add reset to Cycle after_change callbacks
  Add example in Readme.md
  Support configuring custom keys via method invocation
  Use bundle add instead (rails#81)
lewispb added a commit to lewispb/kredis that referenced this pull request May 26, 2022
* main:
  Bump version for 1.2.0
  Use pipeline for migration too
  Ensure to pass the pipeline to super
  Use block parameter to pipeline in Redis#multi (rails#68)
  Note tested / supported versions of Redis in the Readme (rails#79)
  Return counter value after incrementing/decrementing
  Enum Bang setter (rails#82)
  Add reset to Cycle after_change callbacks
  Add example in Readme.md
  Support configuring custom keys via method invocation
  Use bundle add instead (rails#81)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants