class AsyncStorage::Naming
Constants
- SET
Attributes
class_args[R]
class_name[R]
prefix[RW]
Public Class Methods
new(klass, *args)
click to toggle source
# File lib/async_storage/naming.rb, line 21 def initialize(klass, *args) @class_name = normalize_class(klass.name) @class_args = normalize_args(args) end
Public Instance Methods
body()
click to toggle source
# File lib/async_storage/naming.rb, line 34 def body "#{base}:#{SET[:body]}" end
eql?(other)
click to toggle source
# File lib/async_storage/naming.rb, line 46 def eql?(other) return false unless other.is_a?(self.class) [head, body] == [other.head, other.body] end
Also aliased as: ==
head()
click to toggle source
# File lib/async_storage/naming.rb, line 30 def head "#{base}:#{SET[:head]}" end
temp()
click to toggle source
# File lib/async_storage/naming.rb, line 26 def temp "#{base}:#{SET[:temp]}" end
to_s()
click to toggle source
# File lib/async_storage/naming.rb, line 38 def to_s format( '#<AsyncStorage::Naming head=%<head>p body=%<body>p>', head: head, body: body, ) end
Protected Instance Methods
base()
click to toggle source
# File lib/async_storage/naming.rb, line 55 def base [ns, prefix, class_name, class_args].compact.join(':') end
normalize_args(args)
click to toggle source
# File lib/async_storage/naming.rb, line 67 def normalize_args(args) return SET[:none] if args.empty? Digest::SHA256.hexdigest( AsyncStorage::JSON.dump(args, mode: :compat), ) end
normalize_class(name)
click to toggle source
# File lib/async_storage/naming.rb, line 59 def normalize_class(name) if name.nil? || name.empty? raise ArgumentError, 'Anonymous class is not allowed' end underscore(name, ':') end
ns()
click to toggle source
# File lib/async_storage/naming.rb, line 75 def ns AsyncStorage.config.namespace end