Sha256: 97e6e931b1b6edc6254e79d72e2d0d4d55438b775c485fa6e12f679cc5ec7536

Contents?: true

Size: 652 Bytes

Versions: 1

Compression:

Stored size: 652 Bytes

Contents

class Deposit
  class << self
    def instance
      @instance ||= (find || create)
    end

    private

    def find
      repository.find
    end

    def create
      deposit = new(repository)
      deposit.cache_pieces = []
      repository.insert(deposit)
    end

    def repository
      @repository ||= Vendra.repositories[:deposit]
    end
  end

  attr_accessor :cache_pieces

  def initialize(repository)
    @repository = repository
  end

  def insert(value)
    cache_piece = CachePiece.new(value)
    cache_pieces << cache_piece
    update
  end

  def update
    repository.update(self)
  end

  private

  attr_reader :repository
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vendra-0.1.0 lib/vendra/domain/models/entities/deposit/deposit.rb