Class: Percolate::Facet::FixtureFacet

Inherits:
BaseFacet
  • Object
show all
Defined in:
lib/percolate/facet/fixture_facet.rb

Overview

A facet for looking up entities based on a fixed attribute ‘Hash`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFixtureFacet

Returns a new instance of FixtureFacet.



25
26
27
# File 'lib/percolate/facet/fixture_facet.rb', line 25

def initialize
  @fixtures = {}
end

Instance Attribute Details

#fixturesHash

Gets the fixtures.

Returns:

  • (Hash)

    the fixtures.



32
33
34
# File 'lib/percolate/facet/fixture_facet.rb', line 32

def fixtures
  @fixtures
end

Instance Method Details

#find(key) ⇒ Object



36
37
38
# File 'lib/percolate/facet/fixture_facet.rb', line 36

def find(key)
  @fixtures[key]
end

#merge(other) ⇒ Object

Raises:

  • (ArgumentError)


40
41
42
43
44
45
46
47
# File 'lib/percolate/facet/fixture_facet.rb', line 40

def merge(other)
  raise ArgumentError, "Please provide another #{self.class}" if !other.is_a?(FixtureFacet)

  merged = FixtureFacet.new
  merged.fixtures = @fixtures.merge(other.fixtures)

  merged
end