Module: Factis

Defined in:
lib/factis.rb,
lib/factis/memory.rb,
lib/factis/version.rb,
lib/generators/factis/rspec_generator.rb,
lib/generators/factis/cucumber_generator.rb

Overview

This module contains syntactic sugar for the methods in Factis::Memory. The purpose is, basically, to make the methods easily injected into, say, Cucumber via extend.

Defined Under Namespace

Modules: Generators Classes: Memory

Constant Summary collapse

VERSION =
'1.0.1'

Instance Method Summary collapse

Instance Method Details

#all_factsHash

Returns the entire facts hash

Returns:

  • (Hash)

    the facts hash

See Also:



20
21
22
# File 'lib/factis.rb', line 20

def all_facts
  Factis::Memory.all_facts
end

#clear_all_facts!Object

Forget all of the known facts



12
13
14
# File 'lib/factis.rb', line 12

def clear_all_facts!
  Factis::Memory.reset!
end

#forget_fact(fact) ⇒ Object

Removes the given fact (key) from internal storage, raising an error for an unknown fact

Parameters:

  • fact

    the key of the fact to remove

Returns:

  • (Object)

    the content of the removed fact

Raises:

  • (RuntimeError)

    if the key is not in the fact hash



64
65
66
# File 'lib/factis.rb', line 64

def forget_fact(fact)
  Factis::Memory.forget(fact)
end

#indifferently_memorize_fact(fact, content) ⇒ Object

Note:

This undermines the goal of safely tracking state. Please refrain from using it if at all possible.

This method is equivalent to memorize_fact in all ways, save that it disregards the possible existence of the fact key within the internal hash.



45
46
47
# File 'lib/factis.rb', line 45

def indifferently_memorize_fact(fact, content)
  Factis::Memory.memorize(fact, content, :overwrite => true)
end

#memorize_fact(fact, content) ⇒ Object

Memorize the given content, keyed by the given fact key. This wrapper does not allow for overwriting of a fact, and an atttempt to do so will raise an error.

Parameters:

  • fact

    a key suitable for use in a Hash

  • content (Object)

    the content to store

Returns:

  • (Object)

    the content that was stored

Raises:

  • (RuntimeError)

    if the fact key is already in the facts hash

See Also:



33
34
35
# File 'lib/factis.rb', line 33

def memorize_fact(fact, content)
  Factis::Memory.memorize(fact, content)
end

#recall_fact(fact) ⇒ Object

Get fact content by key, raising an error for an unknown fact

Parameters:

  • fact

    the key of the fact to retrieve

Returns:

  • (Object)

    the content of the recalled fact

Raises:

  • (RuntimeError)

    if the key is not in the fact hash



54
55
56
# File 'lib/factis.rb', line 54

def recall_fact(fact)
  Factis::Memory.recall(fact)
end