Sha256: 8d4cc38375be9734167386fce58af737713facd5a6b955020edc0700f345978d

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

module Aqua::Config
  def self.included( klass ) 
    # This per aquatic class storage class is used to maintain the storage specific options, 
    # such as a particular database for the class. Otherwise, appeals directly to Aqua::Storage 
    # for class methods will loose database and other class specific storage options
    klass.class_eval "
      class Storage < Aqua::Storage
        def self.parent_class
          '#{klass}'
        end  
      end
    "
    
    klass.class_eval do
      extend ClassMethods
      configure_aqua
      
      hide_attributes :_aqua_opts
    end   
  end
  
  module ClassMethods 
    def configure_aqua(opts={})
      database = opts.delete(:database)
      self::Storage.database = database
      @_aqua_opts = Mash.new( _aqua_opts ).merge!(opts)
    end
    
    def _aqua_opts
      @_aqua_opts ||= _aqua_config_defaults
    end   
    
    private
      def _aqua_config_defaults
        {
          :database => nil, # Default is the same as the server. Everything is saved to the same db
          :embed => false,  # options false, true, or :stub => [:attributes, :to_save, :in_the_other_object]
        }
      end
    public   
  end

end   

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aqua-0.1.6 lib/aqua/object/config.rb