Method: Endpoint::Stub#add_record

Defined in:
lib/endpoint/stub.rb

#add_record(attrs) ⇒ Object

Adds a record to the stub, automatically assigning an id as though it were in a database.



99
100
101
102
103
104
105
106
107
# File 'lib/endpoint/stub.rb', line 99

def add_record(attrs)
  unless attrs.is_a? Hash
    raise "Endpoint::Stub#add_record expects a Hash. Got #{attrs.class.name}."
  end
  attrs[:id] = current_id
  attrs.merge!(@defaults) { |k,a,b| a }
  @records << attrs
  attrs
end