Sha256: ded6611c02a9efdc5d338906f4835f0a46d5f243680b3e22845bb037158b6738

Contents?: true

Size: 660 Bytes

Versions: 2

Compression:

Stored size: 660 Bytes

Contents

# Defines additional methods to make Fixture behave like a Hash.  Required for resolving joins. 
#
# Accomodates both of the allowed internal data structures for Fixture: Hash and YAML::Omap
class Fixture
	def has_key?(key)
		# should work for Hash and Omap
		@fixture.keys.include?(key)
	end
	
	def each_pair(&block)
		if @fixture.respond_to?(:each_pair) 
			# for Hash
			@fixture.each_pair(&block)
		else
			# for Omap
			@fixture.map { |key, value| yield(key, value) } 
		end
	end
	
	def delete_if(&block)
		# should work for Hash and Omap
		@fixture.delete_if(&block)
	end
	
	def []=(key, value)
		@fixture[key] = value
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
joinfix-1.0.1 lib/joinfix/fixture.rb
joinfix-1.0.0 lib/joinfix/fixture.rb