Class: DbFuel::Library::Dbee::Range

Inherits:
Base
  • Object
show all
Defined in:
lib/db_fuel/library/dbee/range.rb

Overview

This Burner Job does the same data query and loading as the Query Job with the addition of the ability to dynamically add an IN filter for a range of values. The values are retrieved from the register’s array of records using the defined key.

Expected Payload input: array of objects. Payload output: array of objects.

Instance Attribute Summary collapse

Attributes inherited from Base

#debug, #model, #provider, #query

Instance Method Summary collapse

Constructor Details

#initialize(key:, name: '', key_path: '', model: {}, query: {}, register: Burner::DEFAULT_REGISTER, separator: '', debug: false) ⇒ Range

Arguments:

  • key: Specifies which key to use to aggregate a list of values for within

    the specified register's dataset.
    
  • key_path: Specifies the Dbee identifier (column) to use for the IN filter.

  • model: Dbee Model configuration

  • query: Dbee Query configuration

  • register: Name of the register to use for gathering the IN clause values and where

    to store the resulting recordset.
    
  • separator: Character to use to split the key-path for nested object support.

  • debug: If debug is set to true (defaults to false) then the SQL statements

    will be printed in the output.  Only use this option while
    debugging issues as it will fill
    up the output with (potentially too much) data.
    

Raises:

  • (ArgumentError)


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/db_fuel/library/dbee/range.rb', line 40

def initialize(
  key:,
  name: '',
  key_path: '',
  model: {},
  query: {},
  register: Burner::DEFAULT_REGISTER,
  separator: '',
  debug: false
)
  raise ArgumentError, 'key is required' if key.to_s.empty?

  @key      = key.to_s
  @key_path = key_path.to_s.empty? ? @key : key_path.to_s
  @resolver = Objectable.resolver(separator: separator)

  super(
    model: model,
    name: name,
    query: query,
    register: register,
    debug: debug
  )
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



22
23
24
# File 'lib/db_fuel/library/dbee/range.rb', line 22

def key
  @key
end

#key_pathObject (readonly)

Returns the value of attribute key_path.



22
23
24
# File 'lib/db_fuel/library/dbee/range.rb', line 22

def key_path
  @key_path
end

#resolverObject (readonly)

Returns the value of attribute resolver.



22
23
24
# File 'lib/db_fuel/library/dbee/range.rb', line 22

def resolver
  @resolver
end

Instance Method Details

#perform(output, payload) ⇒ Object



65
66
67
68
69
# File 'lib/db_fuel/library/dbee/range.rb', line 65

def perform(output, payload)
  records = execute(sql(output, payload))

  load_register(records, output, payload)
end