4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/simple_enum/persistence/extension.rb', line 4
def self.included base
base.module_eval do
alias_method :as_enum_without_persistence, :as_enum
def as_enum name, values, options = {}
persistence = options.delete :persistence
if persistence
options[:with] ||= SimpleEnum.with.reject do |feature|
i(attribute scope).include? feature
end
options[:map] = :persistence
values = [ values ]
values.push persistence if persistence.kind_of? Hash
end
as_enum_without_persistence name, values, options
end
end
end
|