Skip to content

Commit

Permalink
feature(unique_hash_counter): introduce unique list postfix delimiter
Browse files Browse the repository at this point in the history
  • Loading branch information
Napolskih committed Oct 10, 2013
1 parent 8a9a2a9 commit 67c5200
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/redis_counters/unique_hash_counter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ module RedisCounters
class UniqueHashCounter < HashCounter
UNIQUE_LIST_POSTFIX = 'uq'.freeze

UNIQUE_LIST_POSTFIX_DELIMITER = '_'.freeze

class_attribute :unique_list_postfix_delimiter

self.unique_list_postfix_delimiter = UNIQUE_LIST_POSTFIX_DELIMITER

protected

def process_value
Expand All @@ -29,12 +35,16 @@ def unique_values_list_options
end

def unique_values_list_name
[counter_name, UNIQUE_LIST_POSTFIX].join(key_delimiter)
[counter_name, UNIQUE_LIST_POSTFIX].join(unique_list_postfix_delimiter)
end

def unique_values_list_class
unique_values_list_options.fetch(:list_class).to_s.constantize
end

def unique_list_postfix_delimiter
@unique_list_postfix_delimiter ||= options.fetch(:unique_list_postfix_delimiter, self.class.unique_list_postfix_delimiter)
end
end

end

0 comments on commit 67c5200

Please sign in to comment.