2014-07-11 2 views

답변

1

dm-type에서 monkey-patch enum.rb를 지원해야합니다.

module DataMapper 
    class Property 
    class Enum < Object 

     def initialize(model, name, options = {}) 
     @flag_map = {} 

     flags = options.fetch(:flags, self.class.flags) 
     flags.each_with_index do |flag, i| 
      @flag_map[i] = flag 
     end 

     if self.class.accepted_options.include?(:set) && !options.include?(:set) 
      options[:set] = @flag_map.values_at(*@flag_map.keys.sort) 
     end 

     super 
     end # end initialize 

    end # end class Enum 
    end # end class Property 
end # end module DataMapper 
: 당신은 @flag_map[i+1]@flag_map[i]로 대체 약간 수정 된 복사본으로 initialize 방법을 교체해야합니다
관련 문제