class Adalog::InMemoryRepo

Attributes

storage[R]

Public Class Methods

new(**repo_options) click to toggle source
# File lib/adalog/in_memory_repo.rb, line 6
def initialize(**repo_options)
  @storage = Array.new
end

Public Instance Methods

all() click to toggle source
# File lib/adalog/in_memory_repo.rb, line 33
def all
  storage.dup
end
clear!() click to toggle source
# File lib/adalog/in_memory_repo.rb, line 27
def clear!
  @storage = Array.new
  :ok
end
fetch(**options) click to toggle source
# File lib/adalog/in_memory_repo.rb, line 11
def fetch(**options)
  all
end
insert(entry = nil, **options) click to toggle source
# File lib/adalog/in_memory_repo.rb, line 16
def insert(entry = nil, **options)
  converted_entry = Adalog::Entry.build(entry = nil, **options)
  if converted_entry.valid?
    storage.unshift(converted_entry)
    [:ok, converted_entry]
  else
    [:error, converted_entry.errors]
  end
end