Sha256: 82a7f1d31e2d552253da42aef5828e3bfb3285152e80392d0a70e23590c826ed
Contents?: true
Size: 497 Bytes
Versions: 2
Compression:
Stored size: 497 Bytes
Contents
# frozen_string_literal: true module CableReady module Identifiable def dom_id(record, prefix = nil) prefix = prefix.to_s.strip if prefix id = if record.is_a?(ActiveRecord::Relation) [prefix, record.model_name.plural].compact.join("_") elsif record.is_a?(ActiveRecord::Base) ActionView::RecordIdentifier.dom_id(record, prefix) else [prefix, record.to_s.strip].compact.join("_") end "##{id}".squeeze("#").strip end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cable_ready-5.0.0.pre1 | lib/cable_ready/identifiable.rb |
cable_ready-5.0.0.pre0 | lib/cable_ready/identifiable.rb |