Method: DataMapper::Property::Flag#load
- Defined in:
- lib/dm-types/flag.rb
#load(value) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dm-types/flag.rb', line 21 def load(value) return [] if value.nil? || value <= 0 begin matches = [] 0.upto(flag_map.size - 1) do |i| matches << flag_map[i] if value[i] == 1 end matches.compact rescue TypeError, Errno::EDOM [] end end |