Sha256: df1893aaf3efad19fa52a68846003e3f9a497e630c3586a4d1aa9a358f620a7b
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
module Taza class Entity #Creates a entity, pass in a hash to be methodized and the fixture to look up other fixtures (not entirely happy with this abstraction) def initialize(hash,fixture) @hash = hash @fixture = fixture define_methods_for_hash_keys end #This method converts hash keys into methods onto the entity def define_methods_for_hash_keys @hash.keys.each do |key| create_method(key) do get_value_for_entry(key) end end end #This method will lookup another fixture if a pluralized fixture exists otherwise return the value in the hash def get_value_for_entry(key) # :nodoc: if @fixture.fixture_exists?(key) @fixture.specific_fixture_entities(key.to_sym, @hash[key]) elsif @fixture.pluralized_fixture_exists?(key) @fixture.get_fixture_entity(key.pluralize_to_sym,@hash[key]) else @hash[key] end end private def create_method(name, &block) # :nodoc: self.class.send(:define_method, name, &block) end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
scudco-taza-0.8.4 | lib/taza/entity.rb |
taza-0.8.4 | lib/taza/entity.rb |