Sha256: 500f5d111bf3e0fe16ceabe0e2e655f14d6ba1f7236f472fb3dfe8b7e56d8a27
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
module Detroit # Custom tool is used to create "quicky" services. # # This is a useful alternative to writing a full-blown plugin # when the need is simple. # class Custom < Tool # Default track(s) in which this plugin operates. DEFAULT_TRACK = "main" # Which track(s) to run this custom plugin. attr_accessor :track # Special writer to allow single track or a list of tracks. def track=(val) @track = val.to_list #[val].flatten end # Plural alias for #track. alias_accessor :tracks, :track private # Instantiate new custom plugin. # # FIXME: Custom#initialize seems to be running twice at startup. Why? # # This works by interpreting the service configuration as a hash of # stop names to ruby code. # def initialize(options) super(options) options.each do |stop, script| # skip specific names used for configuration next if stop == 'service' next if stop == 'tracks' or stop == 'track' next if stop == 'active' next if stop == 'priority' # remaining options are names of track stops #tracks.each do |t| src = %{ def #{stop} #{script} end } (class << self; self; end).module_eval(src) #end end end # Set initial attribute defaults. def initialize_defaults @track = [DEFAULT_TRACK] end # def method_missing(s, *a, &b) super(s, *a, &b) if @context.respond_to?(s) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
detroit-0.1.0 | lib/detroit/custom.rb |