Class: Alephant::Lookup::LookupQuery

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/alephant/lookup/lookup_query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table_name, component_id, opts, batch_version) ⇒ LookupQuery

Returns a new instance of LookupQuery.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/alephant/lookup/lookup_query.rb', line 11

def initialize(table_name, component_id, opts, batch_version)
  @client          = AWS::DynamoDB::Client::V20120810.new
  @table_name      = table_name
  @lookup_location = LookupLocation.new(component_id, opts, batch_version)

  logger.info(
    "event"        => "LookupQueryInitialized",
    "tableName"    => table_name,
    "componentId"  => component_id,
    "location"     => lookup_location,
    "batchVersion" => batch_version,
    "method"       => "#{self.class}#initialize"
  )
end

Instance Attribute Details

#lookup_locationObject (readonly)

Returns the value of attribute lookup_location.



9
10
11
# File 'lib/alephant/lookup/lookup_query.rb', line 9

def lookup_location
  @lookup_location
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



9
10
11
# File 'lib/alephant/lookup/lookup_query.rb', line 9

def table_name
  @table_name
end

Instance Method Details

#run!Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/alephant/lookup/lookup_query.rb', line 26

def run!
  lookup_location.tap do |l|
    l.location = s3_location_from(
      @client.query(to_q)
    ).tap do |loc|
      logger.info(
        "event"    => "S3LocationRetrieved",
        "location" => loc,
        "method"   => "#{self.class}#run!"
      )
    end
  end
end