class Mockolate::Request::DSL

Attributes

attributes[RW]
options[R]

Public Class Methods

new(options) click to toggle source
# File lib/mockolate/request.rb, line 39
def initialize(options)
  @attributes = []
  @options    = options  
end

Public Instance Methods

hash(*args, &block) click to toggle source
# File lib/mockolate/request.rb, line 44
def hash(*args, &block)
  raise Mockolate::Errors::MissingHashBlockError unless block_given?
  method_missing(:hash, *args, &block)
end
method_missing(type, *args, &block) click to toggle source
# File lib/mockolate/request.rb, line 49
def method_missing(type, *args, &block)
  metadata   = Mockolate::Register.get(type)
  field_name = args.first
  type_options    = args[1]
  
  attibute = metadata.create(name: field_name, options: type_options)
  if block_given?
    attibute.children = Mockolate::Request.payload_parser(options, &block)
  end
  attributes << attibute
end