Class: AsyncStorage::Naming

Inherits:
Object
  • Object
show all
Includes:
Util::Strings
Defined in:
lib/async_storage/naming.rb

Constant Summary collapse

SET =
{
  temp: 't',
  head: 'h',
  body: 'b',
  none: '_null_',
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util::Strings

underscore

Constructor Details

#initialize(klass, *args) ⇒ Naming

Returns a new instance of Naming.



21
22
23
24
# File 'lib/async_storage/naming.rb', line 21

def initialize(klass, *args)
  @class_name = normalize_class(klass.name)
  @class_args = normalize_args(args)
end

Instance Attribute Details

#class_argsObject (readonly)

Returns the value of attribute class_args.



18
19
20
# File 'lib/async_storage/naming.rb', line 18

def class_args
  @class_args
end

#class_nameObject (readonly)

Returns the value of attribute class_name.



18
19
20
# File 'lib/async_storage/naming.rb', line 18

def class_name
  @class_name
end

#prefixObject

Returns the value of attribute prefix.



19
20
21
# File 'lib/async_storage/naming.rb', line 19

def prefix
  @prefix
end

Instance Method Details

#bodyObject



34
35
36
# File 'lib/async_storage/naming.rb', line 34

def body
  "#{base}:#{SET[:body]}"
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


46
47
48
49
50
# 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

#headObject



30
31
32
# File 'lib/async_storage/naming.rb', line 30

def head
  "#{base}:#{SET[:head]}"
end

#tempObject



26
27
28
# File 'lib/async_storage/naming.rb', line 26

def temp
  "#{base}:#{SET[:temp]}"
end

#to_sObject



38
39
40
41
42
43
44
# 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