-
Notifications
You must be signed in to change notification settings - Fork 84
Default values for entries #89
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
Closed
Closed
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
133a0e0
Add default proxy value
tleish 4eff947
Add default list values
tleish 903f2a9
Add default to unique_list
tleish a668f78
Add default to flag
tleish 35dc9bf
Add default to string
tleish e6bcbbd
Add default to integer
tleish ba0092c
Add default to decimal
tleish 52b308b
Add default to datetime
tleish de0e5b1
Add default to float
tleish 77499ed
Add default proc to enum
tleish 46fa83a
rename default_value method to default
tleish abdf95a
Add default proc to set
tleish 4933f6c
Add additional unit tests
tleish 321d33c
Add default proc to json and counter
tleish 411d04a
Add default proc to hash and boolean
tleish ed3cbd8
Add before_method_hook
tleish 1030836
Fix for ruby 3
tleish 1bb9288
refactor Kredis::Types::BeforeMethodsHook#before_methods
tleish 10ceac9
code review updates
tleish 1bff6bf
merge main
tleish 7e85720
fix code review feedback
tleish 180f57c
Match indentation
dhh bf2ba58
create custom callnx method and refactor
tleish d0146ee
add additional default options to set
tleish 90d9208
move primary #set_default method to Kredis::Types::Proxying
tleish 5c4664b
updated enum multi block to use standar [-1] pattern instead of .last
tleish ddf555f
refactor init_default_in_multi to not use multi if default not defined
tleish ef2eacb
refactor multi in Kredis::Types::Proxying
tleish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,45 @@ | ||
class Kredis::Types::List < Kredis::Types::Proxying | ||
proxying :lrange, :lrem, :lpush, :rpush, :exists?, :del | ||
proxying :lrange, :lrem, :lpush, :rpush, :exists?, :del, :callnx | ||
|
||
attr_accessor :typed | ||
|
||
def elements | ||
strings_to_types(lrange(0, -1) || [], typed) | ||
values = init_default_in_multi { lrange(0, -1) } | ||
strings_to_types(values || [], typed) | ||
end | ||
alias to_a elements | ||
|
||
def remove(*elements) | ||
types_to_strings(elements, typed).each { |element| lrem 0, element } | ||
return [] if elements.flatten.blank? | ||
|
||
init_default_in_multi do | ||
types_to_strings(elements, typed).each { |element| lrem 0, element } | ||
end | ||
end | ||
|
||
def prepend(*elements) | ||
lpush types_to_strings(elements, typed) if elements.flatten.any? | ||
return self.elements.count if elements.flatten.blank? | ||
|
||
init_default_in_multi do | ||
lpush types_to_strings(elements, typed) | ||
end | ||
end | ||
|
||
def append(*elements) | ||
rpush types_to_strings(elements, typed) if elements.flatten.any? | ||
return self.elements.count if elements.flatten.blank? | ||
|
||
init_default_in_multi do | ||
rpush types_to_strings(elements, typed) | ||
end | ||
end | ||
alias << append | ||
|
||
def clear | ||
del | ||
end | ||
|
||
private | ||
def set_default(elements) | ||
callnx(:rpush, types_to_strings(Array(elements), typed)) | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed some of these proxying methods because they were no longer used in the class. Do they need to be kept because of the public api others may have tied into?