Class: Mockolate::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/mockolate/request.rb

Defined Under Namespace

Classes: DSL, Parser

Constant Summary collapse

@@public_attributes =
[]
@@payloads =
[]
@@payload_options =
{}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.paramsObject



19
20
21
# File 'lib/mockolate/request.rb', line 19

def self.params
  @@public_attributes
end

.payload(options = {}, &block) ⇒ Object



8
9
10
# File 'lib/mockolate/request.rb', line 8

def self.payload(options = {}, &block)
  @@payloads << payload_parser(options, &block)
end

.payload_parser(options = {}, &block) ⇒ Object



12
13
14
15
16
17
# File 'lib/mockolate/request.rb', line 12

def self.payload_parser(options = {}, &block)
  @@payload_options = options
  dsl = DSL.new(@@payload_options)
  dsl.instance_exec(&block)
  @@public_attributes = dsl.attributes
end

Instance Method Details

#generate_array!(count = nil) ⇒ Object



23
24
25
26
27
# File 'lib/mockolate/request.rb', line 23

def generate_array!(count = nil)
  attr_arr = @@payloads
  parser = Parser.new(attr_arr)
  parser.parse
end

#generate_hash!(count = nil) ⇒ Object



29
30
31
32
33
# File 'lib/mockolate/request.rb', line 29

def generate_hash!(count = nil)
  attr_arr = @@payloads
  parser = Parser.new(attr_arr, @@payload_options)
  parser.parse
end