Class: Sqreen::PayloadCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/sqreen/payload_creator.rb,
lib/sqreen/payload_creator/header_section.rb

Overview

Create a payload from a given query

Template elements are made of sections and subsections. This class is able to send the full content of section or only the required subsections as needed.

The payload will always be outputed as a Hash of section => subsection.

Defined Under Namespace

Classes: HeaderSection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(framework) ⇒ PayloadCreator

Returns a new instance of PayloadCreator.



21
22
23
# File 'lib/sqreen/payload_creator.rb', line 21

def initialize(framework)
  @framework = framework
end

Instance Attribute Details

#frameworkObject (readonly)

Returns the value of attribute framework.



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

def framework
  @framework
end

Instance Method Details

#payload(query) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/sqreen/payload_creator.rb', line 36

def payload(query)
  self.query = query
  ret = {}
  METHODS.each_key do |section|
    ret = fill(section, ret, @framework)
  end
  ret
end

#query=(keys) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/sqreen/payload_creator.rb', line 25

def query=(keys)
  @sections = {}
  keys.each do |key|
    section, subsection = key.split('.', 2)
    @sections[section] = true if subsection.nil?
    next if @sections[section] == true
    @sections[section] ||= []
    @sections[section].push(subsection)
  end
end