class Dao::Repository::Base

Public Class Methods

all() click to toggle source
# File lib/dao/repository/base.rb, line 19
def all
  scope.all.apply
end
build(record = nil) click to toggle source
# File lib/dao/repository/base.rb, line 47
def build(record = nil)
  gateway.map(record, {})
end
by_criteria(criteria) click to toggle source
# File lib/dao/repository/base.rb, line 77
def by_criteria(criteria)
  criteria.filter(scope)
end
by_criteria_count(criteria) click to toggle source
# File lib/dao/repository/base.rb, line 81
def by_criteria_count(criteria)
  criteria.count_of_result_items(scope)
end
count() click to toggle source
# File lib/dao/repository/base.rb, line 43
def count
  scope.count.apply
end
delete(domain) click to toggle source
# File lib/dao/repository/base.rb, line 61
def delete(domain)
  delete_by_id(domain.id) if domain
end
delete_by_id(domain_id) click to toggle source
# File lib/dao/repository/base.rb, line 65
def delete_by_id(domain_id)
  gateway.delete(domain_id)
end
entity(entity) click to toggle source
# File lib/dao/repository/base.rb, line 5
def entity(entity)
  @entity = entity
end
find(id, with: nil) click to toggle source
# File lib/dao/repository/base.rb, line 23
def find(id, with: nil)
  if with
    scope.find(id, with: with).apply
  else
    scope.find(id).apply
  end
end
find_by_id(id) click to toggle source
# File lib/dao/repository/base.rb, line 31
def find_by_id(id)
  scope.find_by_id(id).apply
end
gateway(gateway = nil, source = nil, transformer = nil) click to toggle source
# File lib/dao/repository/base.rb, line 9
def gateway(gateway = nil, source = nil, transformer = nil)
  if gateway && source && transformer
    @gateway = gateway
    @source = source
    @transformer = transformer
  else
    @gateway.new(@source, @transformer.new(@entity))
  end
end
last(with: nil) click to toggle source
# File lib/dao/repository/base.rb, line 35
def last(with: nil)
  if with
    scope.last(with: with).apply
  else
    scope.last.apply
  end
end
save(domain, attributes = {}) click to toggle source
# File lib/dao/repository/base.rb, line 51
def save(domain, attributes = {})
  gateway.save!(domain, attributes)
end
save_all(domains) click to toggle source
# File lib/dao/repository/base.rb, line 55
def save_all(domains)
  with_transaction do
    domains.map { |domain| save(domain) }
  end
end
with_lock(id, *args, &block) click to toggle source
# File lib/dao/repository/base.rb, line 73
def with_lock(id, *args, &block)
  gateway.with_lock(id, *args, &block)
end
with_transaction(&block) click to toggle source
# File lib/dao/repository/base.rb, line 69
def with_transaction(&block)
  gateway.with_transaction(&block)
end

Protected Class Methods

scope() click to toggle source
# File lib/dao/repository/base.rb, line 87
def scope
  Scope.new(gateway)
end