Class Module
In: lib/storage/properties.rb
lib/utility/configuration.rb
lib/utility/log.rb
Parent: Object
Module
Log
Singleton
Log4r
dot/f_56.png

Methods

Public Instance methods

configure adds the options method to a class which allows it to access the global configuration hash.

name
an arrays of symbols representing the attributes on the object.

[Source]

# File lib/utility/configuration.rb, line 51
  def configuration()
    class_eval "def options\nConfiguration.instance.options\nend\n"
  end

logger defines a named log and log method for the class

loglevel
the level of logging to do

[Source]

# File lib/utility/log.rb, line 53
  def logger(loglevel='DEBUG', logto=['stderr','server'])
    class_eval "@log = Log.instance.loginit(self.name, \"\#{loglevel}\", \#{logto.inspect})\ndef log\nself.class.instance_variable_get :@log\nend\n"
  end

Properties modifies class Module by adding the property method which:

  1. creates read/write accessors for each symbol.
  2. defines the to_yaml_properties for use by the database for all symbols.
  3. defines the :id attribute
sym
an arrays of symbols representing the attributes on the object.

[Source]

# File lib/storage/properties.rb, line 26
  def property(*sym)
    if Configuration.instance.options['props_are_accessors_only']
      attr_accessor(*sym)
??
      return
    end
    sym.each do |s|
      class_eval "def \#{s}\n@props ||= {}\nif options['safe_read'] && !@props[:\#{s}].kind_of?(Numeric)\nEngine.instance.db.mark(self.id)\n@props[:updated_on] = Time.now\nend\n@props[:\#{s}]\nend\ndef \#{s}=(val)\n@props ||= {}\nEngine.instance.db.mark(self.id)\n@props[:updated_on] = Time.now\n@props[:\#{s}] = val\nend\n"
    end
    class_eval "def to_yaml_properties\n['@props']\nend\ndef id\n@props ||= {}\n@props[:id] ||= Engine.instance.db.getid\nend\ndef _dump(depth)\nMarshal.dump(@props)\nend\ndef self._load(str)\nobj = allocate\nobj.instance_variable_set(:@props,Marshal.load(str))\nobj\nend\n"
  end

[Validate]