Sha256: 487c84292f8cbc91fdd4c4876d7780d41ec18bf70b9ac89916df915da569a659
Contents?: true
Size: 687 Bytes
Versions: 7
Compression:
Stored size: 687 Bytes
Contents
require_relative 'core' module ActsAsHashids module Methods extend ActiveSupport::Concern module ClassMethods def acts_as_hashids(options = {}) include ActsAsHashids::Core unless ancestors.include?(ActsAsHashids::Core) define_singleton_method :hashids_secret do secret = options[:secret] (secret.respond_to?(:call) ? instance_exec(&secret) : secret) || base_class.name end define_singleton_method :hashids do length = options[:length] || 8 alphabet = options[:alphabet] || Hashids::DEFAULT_ALPHABET Hashids.new(hashids_secret, length, alphabet) end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems