Sha256: 95073f29388a5d29126f66257525e3e56bf7492a6612e9f39e9a9f64ca5680d1

Contents?: true

Size: 776 Bytes

Versions: 10

Compression:

Stored size: 776 Bytes

Contents

class SID
  SID_S_KEY_RE = /\A[\w\/\-]+\z/
  SID_S_RE = /\ASID__([a-zA-Z0-9:]+)__([\w\/\-]+)__\z/ # must use this way for compatiblity

  class << self
    def from_s(sid_s)
      m = SID_S_RE.match(sid_s)
      self.new(m[1], m[2]) if m
    end

    def is?(string)
      SID_S_RE.match?(string)
    end
  end

  attr_reader :class_name
  attr_reader :key

  if RUBY_ENGINE == 'opal'
    def initialize(class_name, key)
      @class_name = class_name
      @key = key
    end
  else
    def initialize(class_name, key)
      raise "Invalid class name '#{class_name}!" unless Isomorfeus.valid_data_class_name?(class_name)
      @class_name = class_name
      @key = key
    end
  end

  def to_s
    "SID__#{@class_name}__#{@key}__"
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
isomorfeus-data-23.9.0.rc12 lib/isomorfeus/data/sid.rb
isomorfeus-data-23.9.0.rc11 lib/isomorfeus/data/sid.rb
isomorfeus-data-23.9.0.rc10 lib/isomorfeus/data/sid.rb
isomorfeus-data-23.9.0.rc9 lib/isomorfeus/data/sid.rb
isomorfeus-data-23.9.0.rc8 lib/isomorfeus/data/sid.rb
isomorfeus-data-23.9.0.rc7 lib/isomorfeus/data/sid.rb
isomorfeus-data-23.9.0.rc6 lib/isomorfeus/data/sid.rb
isomorfeus-data-23.9.0.rc5 lib/isomorfeus/data/sid.rb
isomorfeus-data-23.9.0.rc4 lib/isomorfeus/data/sid.rb
isomorfeus-data-23.9.0.rc3 lib/isomorfeus/data/sid.rb