lib/redis-model-extension/old_initialize.rb
def initialize_redis_model_methods conf
      puts "WARNING: This initilization method is deprecated and will be removed in future! \n Please read documentation how to change your model to use new initialization methods"

      remove_redis_autoincrement_key

      @conf = {:reject_nil_values => true}.merge(conf)
      #take all fields and make methods for them
      conf[:fields].each do |name, action|
        redis_fields_config[name] = TYPE_TRANSLATIONS.invert[action]
        redis_fields_defaults_config[name] = nil

        # define getter method for field
        define_method "#{name}" do
          value_get name
        end
        
        # define setter method for field
        define_method "#{name}=" do |new_value|
          value_set name, new_value
        end
        
        # define exists? method for field
        define_method "#{name}?" do
          value_get(name) && !value_get(name).blank? ? true : false
        end
      end
      
      # save nil values?
      redis_save_fields_with_nil false if !conf.has_key?(:reject_nil_values) || conf[:reject_nil_values] == true

      # save into class config about redis key
      @redis_key_config = conf[:redis_key]

      #validate presence of all fields in key
      @required_config = (@redis_key_config | conf[:required]) 
      (@redis_key_config | conf[:required]).each do |field|
        validates field, :presence => :true
      end

      # save into class config about redis keys
      @redis_alias_config = {}
      conf[:redis_aliases].each do |key, fields|
        @redis_alias_config[key] = { 
          main_fields: fields,
          order_field: nil,
          args_field: nil,
        }
      end
    end
def initialize_redis_model_methods conf
      puts "WARNING: This initilization method is deprecated and will be removed in future! \n Please read documentation how to change your model to use new initialization methods"

      remove_redis_autoincrement_key

      @conf = {:reject_nil_values => true}.merge(conf)
      #take all fields and make methods for them
      conf[:fields].each do |name, action|
        redis_fields_config[name] = TYPE_TRANSLATIONS.invert[action]
        redis_fields_defaults_config[name] = nil

        # define getter method for field
        define_method "#{name}" do
          value_get name
        end
        
        # define setter method for field
        define_method "#{name}=" do |new_value|
          value_set name, new_value
        end
        
        # define exists? method for field
        define_method "#{name}?" do
          value_get(name) && !value_get(name).blank? ? true : false
        end
      end
      
      # save nil values?
      redis_save_fields_with_nil false if !conf.has_key?(:reject_nil_values) || conf[:reject_nil_values] == true

      # save into class config about redis key
      @redis_key_config = conf[:redis_key]

      #validate presence of all fields in key
      @required_config = (@redis_key_config | conf[:required]) 
      (@redis_key_config | conf[:required]).each do |field|
        validates field, :presence => :true
      end

      # save into class config about redis keys
      @redis_alias_config = {}
      conf[:redis_aliases].each do |key, fields|
        @redis_alias_config[key] = { 
          main_fields: fields,
          order_field: nil,
          args_field: nil,
        }
      end
    end
old method to initialize redis model extenstion
 Usage:
  REDIS_MODEL_CONF = {
   :fields => {
     :integer => :to_i,
     :boolean => :to_bool,
     :string => :to_s,
     :symbol => :to_sym,
    },
    :required => [:integer, :string],
    :redis_key => [:string, :symbol],
    :redis_aliases => {
      :token => [:symbol]
    },
    # (default is true) if true all nil values will not be saved into redis,
    # there should be problem when you want to set some value to nil and same
    # it will not be saved (use false to prevent this)
    :reject_nil_values => false
 }
 include RedisModel
 initialize_redis_model_methods REDIS_MODEL_CONF