app/models/switchman/shard.rb
# converts an AR object, integral id, string id, or string short-global-id to a
# integral id. nil if it can't be interpreted
converts an AR object, integral id, string id, or string short-global-id to a
integral id. nil if it can't be interpreted
converts an AR object integral id string id or string short - global - id to a integral id . nil if it can ' t be interpreted
def integral_id_for(any_id)
        if any_id.is_a?(::Arel::Nodes::Casted)
          any_id = any_id.val
        elsif any_id.is_a?(::Arel::Nodes::BindParam) && ::Rails.version >= "5.2"
          any_id = any_id.value.value_before_type_cast
        end
        case any_id
        when ::ActiveRecord::Base
          any_id.id
        when /^(\d+)~(-?\d+)$/
          local_id = $2.to_i
          signed_id_operation(local_id) do |id|
            return nil if id > IDS_PER_SHARD
            $1.to_i * IDS_PER_SHARD + id
          end
        when Integer, /^-?\d+$/
          any_id.to_i
        else
          nil
        end
      end
def integral_id_for ( any_id ) if any_id . is_a? ( :: Arel :: Nodes :: Casted ) any_id = any_id . val elsif any_id . is_a? ( :: Arel :: Nodes :: BindParam ) && :: Rails . version >= "5.2" any_id = any_id . value . value_before_type_cast end case any_id when :: ActiveRecord :: Base any_id . id when / ^( \d +)~(-? \d +)$ / local_id = $2 . to_i signed_id_operation ( local_id ) do | id | return nil if id > IDS_PER_SHARD $1 . to_i * IDS_PER_SHARD + id end when Integer , / ^-? \d +$ / any_id . to_i else nil end end
converts an AR object, integral id, string id, or string short-global-id to a
integral id.
converts an AR object integral id string id or string short - global - id to a integral id .
any_id
<not_specific>