Class: ROM::Memory::Gateway

Inherits:
Gateway
  • Object
show all
Defined in:
core/lib/rom/memory/gateway.rb

Overview

In-memory gateway interface

Examples:

gateway = ROM::Memory::Gateway.new
gateway.dataset(:users)
gateway[:users].insert(name: 'Jane')

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject (readonly)

Returns default logger.

Returns:

  • (Object)

    default logger



23
24
25
# File 'core/lib/rom/memory/gateway.rb', line 23

def logger
  @logger
end

Instance Method Details

#[](name) ⇒ Memory::Dataset

Return dataset with the given name

Returns:



61
62
63
# File 'core/lib/rom/memory/gateway.rb', line 61

def [](name)
  connection[name]
end

#dataset(name) ⇒ Dataset

Register a dataset in the gateway

If dataset already exists it will be returned

Returns:



46
47
48
# File 'core/lib/rom/memory/gateway.rb', line 46

def dataset(name)
  self[name] || connection.create_dataset(name)
end

#dataset?(name) ⇒ Boolean

Returns:

  • (Boolean)

See Also:

  • Gateway#dataset?


51
52
53
# File 'core/lib/rom/memory/gateway.rb', line 51

def dataset?(name)
  connection.key?(name)
end

#use_logger(logger) ⇒ Object

Set default logger for the gateway

Parameters:

  • logger (Object)

    object



35
36
37
# File 'core/lib/rom/memory/gateway.rb', line 35

def use_logger(logger)
  @logger = logger
end