Module: MessageStore::Controls::StreamName
- Defined in:
- lib/message_store/controls/stream_name.rb
Class Method Summary collapse
- .example(category: nil, id: nil, type: nil, types: nil, randomize_category: nil) ⇒ Object
- .stream_name(category, id = nil, type: nil, types: nil) ⇒ Object
Class Method Details
.example(category: nil, id: nil, type: nil, types: nil, randomize_category: nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/message_store/controls/stream_name.rb', line 4 def self.example(category: nil, id: nil, type: nil, types: nil, randomize_category: nil) if id == :none id = nil else id ||= Identifier::UUID.random end category = Category.example(category: category, randomize_category: randomize_category) stream_name(category, id, type: type, types: types) end |
.stream_name(category, id = nil, type: nil, types: nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/message_store/controls/stream_name.rb', line 16 def self.stream_name(category, id=nil, type: nil, types: nil) types = Array(types) types.unshift(type) unless type.nil? type_list = nil type_list = types.join('+') unless types.empty? stream_name = category stream_name = "#{stream_name}:#{type_list}" unless type_list.nil? if not id.nil? composed_id = MessageStore::ID.id(id) stream_name = "#{stream_name}-#{composed_id}" end stream_name end |