8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/acts_as_hashids/methods.rb', line 8
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
|