Class: ROM::DynamoDB::Gateway

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Gateway

Returns a new instance of Gateway.



6
7
8
9
# File 'lib/rom/dynamodb/gateway.rb', line 6

def initialize(config = {})
  @config = config
  @datasets ||= {}
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



4
5
6
# File 'lib/rom/dynamodb/gateway.rb', line 4

def config
  @config
end

#datasetsObject (readonly)

Returns the value of attribute datasets.



4
5
6
# File 'lib/rom/dynamodb/gateway.rb', line 4

def datasets
  @datasets
end

Instance Method Details

#connectionObject



20
21
22
# File 'lib/rom/dynamodb/gateway.rb', line 20

def connection
  @connection ||= Aws::DynamoDB::Client.new(@config)
end

#dataset(name) ⇒ Object



11
12
13
# File 'lib/rom/dynamodb/gateway.rb', line 11

def dataset(name)
  datasets[name] ||= Dataset.new(name: name, config: config)
end

#dataset?(name) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/rom/dynamodb/gateway.rb', line 15

def dataset?(name)
  list = connection.list_tables
  list.table_names.include?(name)
end