def map_model(model_name, opts = {})
      model_name = model_name.to_s
      class_name = Risky::Inflector.classify(model_name)

      opts.replace({:type => :index2i, :suffix => '_id'}.merge(opts))

      class_eval %Q{
        def #{model_name}
          @#{model_name} ||= #{class_name}.#{opts[:finder]} #{model_name}#{opts[:suffix]}
        end

        def #{model_name}=(value)
          @#{model_name} = value
          self.#{model_name}#{opts[:suffix]} = value.nil? ? nil : value.id
        end

        def #{model_name}_id=(value)
          @#{model_name} = nil if self.#{model_name}_id != value
          indexes2i['#{model_name}#{opts[:suffix]}'] = value
        end
      }
    end
def map_model(model_name, opts = {})
      model_name = model_name.to_s
      class_name = Risky::Inflector.classify(model_name)

      opts.replace({:type => :index2i, :suffix => '_id'}.merge(opts))

      class_eval %Q{
        def #{model_name}
          @#{model_name} ||= #{class_name}.#{opts[:finder]} #{model_name}#{opts[:suffix]}
        end

        def #{model_name}=(value)
          @#{model_name} = value
          self.#{model_name}#{opts[:suffix]} = value.nil? ? nil : value.id
        end

        def #{model_name}_id=(value)
          @#{model_name} = nil if self.#{model_name}_id != value
          indexes2i['#{model_name}#{opts[:suffix]}'] = value
        end
      }
    end
The map_model method is a convenience method to map the model_id to getters and setters.
 The assumption is that you have a value or index2i for model_id.
 The default suffix is '_id', so map_model :promotion implies that promotion_id is the index2i.

 For example, map_model :promotion will create these three methods
 ```ruby
 def promotion
   @promotion ||= Promotion.find_by_id promotion_id
 end

 def promotion=(value)
   @promotion = promotion
   self.promotion_id = value.nil? ? nil : value.id
 end

 def promotion_id=(value)
   @promotion = nil if self.promotion_id != value
   indexes2i['promotion_id'] = value
 end
 ```