Class: Fixture

Inherits:
Object
  • Object
show all
Defined in:
lib/joinfix/fixture.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#[]=(key, value) ⇒ Object



25
26
27
# File 'lib/joinfix/fixture.rb', line 25

def []=(key, value)
  @fixture[key] = value
end

#delete_if(&block) ⇒ Object



20
21
22
23
# File 'lib/joinfix/fixture.rb', line 20

def delete_if(&block)
  # should work for Hash and Omap

  @fixture.delete_if(&block)
end

#each_pair(&block) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/joinfix/fixture.rb', line 10

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

#has_key?(key) ⇒ Boolean



5
6
7
8
# File 'lib/joinfix/fixture.rb', line 5

def has_key?(key)
  # should work for Hash and Omap

  @fixture.keys.include?(key)
end