module Belajar::Storeable
Constants
- LEADING_NUMBERS
- PART_JOINTS
Public Class Methods
key(text, options = {})
click to toggle source
# File lib/belajar/storeable.rb, line 7 def key(text, options = {}) separator = QuickStore.config.key_separator prefix = options[:prefix] suffix = clean(options[:suffix]) suffixes = options[:suffixes] suffixes_items = suffixes ? suffixes.map { |s| clean(s) }.compact : nil [prefix, clean(text), suffix || suffixes_items].compact.join(separator) end
Private Class Methods
clean(text)
click to toggle source
# File lib/belajar/storeable.rb, line 19 def clean(text) return if text.nil? parts(text.to_s).join(QuickStore.config.key_separator) end
parts(text)
click to toggle source
# File lib/belajar/storeable.rb, line 24 def parts(text) text.split(QuickStore.config.key_separator).map do |key| key.gsub(LEADING_NUMBERS, '').gsub(PART_JOINTS, '_').downcase end end