Module: Redcord::Attribute::InstanceMethods

Extended by:
T::Sig
Defined in:
lib/redcord/attribute.rb

Instance Method Summary collapse

Instance Method Details

#hash_tagObject



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/redcord/attribute.rb', line 162

def hash_tag
  attr = self.class.class_variable_get(:@@shard_by_attribute)

  return nil if attr.nil?

  # A blank hash tag would cause MOVED error in cluster mode
  tag = send(attr)
  default_tag = '__redcord_hash_tag_null__'

  if tag == default_tag
    raise Redcord::InvalidAttribute, "#{attr}=#{default_tag} conflicts with default hash_tag value"
  end

  "{#{tag || default_tag}}"
end