| Class | Module |
| In: |
lib/storage/properties.rb
lib/utility/configuration.rb lib/utility/log.rb |
| Parent: | Object |
configure adds the options method to a class which allows it to access the global configuration hash.
# 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
# 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:
# 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