Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/kredis/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def kredis_unique_list(name, limit: nil, key: nil, typed: :string, config: :shar
kredis_connection_with __method__, name, key, limit: limit, typed: typed, config: config, after_change: after_change
end

def kredis_ordered_set(name, limit: nil, key: nil, typed: :string, config: :shared, after_change: nil)
kredis_connection_with __method__, name, key, limit: limit, typed: typed, config: config, after_change: after_change
end

def kredis_set(name, key: nil, typed: :string, config: :shared, after_change: nil)
kredis_connection_with __method__, name, key, typed: typed, config: config, after_change: after_change
end
Expand Down
6 changes: 6 additions & 0 deletions test/attributes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Person
kredis_list :names_with_custom_key_via_lambda, key: ->(p) { "person:#{p.id}:names_customized" }
kredis_list :names_with_custom_key_via_method, key: :generate_key
kredis_unique_list :skills, limit: 2
kredis_ordered_set :reading_list, limit: 2
kredis_flag :special
kredis_flag :temporary_special, expires_in: 1.second
kredis_string :address
Expand Down Expand Up @@ -90,6 +91,11 @@ class AttributesTest < ActiveSupport::TestCase
assert_equal %w[ racing photography ], @person.skills.elements
end

test "ordered set" do
@person.reading_list.prepend(%w[ rework shapeup remote ])
assert_equal %w[ remote shapeup ], @person.reading_list.elements
end

test "flag" do
assert_not @person.special?

Expand Down