Sha256: 744652620603da3e1973fc5e9032d61fb891ad0fa45b68a866c64526e9f9aaec
Contents?: true
Size: 447 Bytes
Versions: 1
Compression:
Stored size: 447 Bytes
Contents
module ActiveEnum module MixIn def enum_attr attr, enums, options={} attr = attr.to_s self.class_eval <<-EOF ENUMS_#{attr.upcase} = enums options.merge! :in => enums.map{|e| e[1]} validates_inclusion_of attr, options def #{attr}_name ENUMS_#{attr.upcase}.find{|op| op[1] == #{attr}}[0] unless #{attr}.nil? end EOF end end end Object.send :include, ActiveEnum::MixIn
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sga_enum-0.1.0 | lib/sga_enum.rb |