Sha256: b9a3a005f6b3241b517843ed37b1643e30b93c3c4956528d97eb205a4c6a7ae2
Contents?: true
Size: 934 Bytes
Versions: 4
Compression:
Stored size: 934 Bytes
Contents
require 'active_support/concern' module Ardm module ActiveRecord module Repository extend ActiveSupport::Concern def repository(name=nil, &block) self.class.repository(name, &block) end module ClassMethods def repository(name=nil, &block) if name && name != :default raise Ardm::NotImplemented, "Alternate repository names not supported" end if block_given? yield else Ardm::ActiveRecord::Repository::Proxy.new self end end end class Proxy def initialize(model) @model = model end def adapter self end def select(*args) array_of_hashes = @model.connection.select_all(@model.send(:sanitize_sql_array, args)) array_of_hashes.map { |h| Hashie::Mash.new(h) } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems