Sha256: 8f9a777ab28e49d34cc4f79806788d987dd51d48be3d1a134af157a4f1d5c886
Contents?: true
Size: 929 Bytes
Versions: 1
Compression:
Stored size: 929 Bytes
Contents
require_relative 'bird' module MockingBird class Flock attr_accessor :service, :birds def initialize(path = '') @birds = {} @path = path @service = path.split("/").last.classify load if @path.present? end private def load Dir.entries(@path).each do |dir| spawn_birds(dir) end end def spawn_birds(dir) full_path = File.join(@path,dir) if File.directory?(full_path) && dir != ".." && dir != "." bird = Bird.new(:service => @service, :path => full_path) @birds[bird.klass.downcase.to_sym] = bird end end def method_missing(method, *args, &block) if match = method.to_s.match(/^(.*)=$/) raise NoMethodError elsif bird = has_bird?(method) @birds[method] else raise NoMethodError end end def has_bird?(klass) @birds.has_key?(klass) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mocking_bird-0.0.2 | lib/mocking_bird/flock.rb |