Sha256: 9c9735f46e233457145f53cd5707846d3c8f1a905c585b50412c0af98c639b8d
Contents?: true
Size: 1.09 KB
Versions: 6
Compression:
Stored size: 1.09 KB
Contents
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'fathom')) class Fathom::Agent # ================= # = Class Methods = # ================= include Properties def initialize(opts={}) self.class.define_property_states assert_node_accessors(opts) end def states @states ||= self.class.properties.inject({}) do |h, state_method_name| h[state_method_name] = nil h end end def callbacks @callbacks ||= (self.methods - Object.methods).grep(/^on_(\w+)/) end protected def assert_node_accessors(nodes) nodes.each do |name, node| next unless self.class.properties.include?(name) states[name] = node.respond_to?(:rand) ? node.rand : node method_name = ("node_for_" + name.to_s.downcase.gsub(/\s+/, '_')).to_sym (class << self; self; end).module_eval do define_method method_name do node end end end end end if __FILE__ == $0 include Fathom # TODO: Is there anything you want to do to run this file on its own? # Agent.new end
Version data entries
6 entries across 6 versions & 1 rubygems